Skip to content

TD-5299: a delegated child can run in the background, for the rest of the turn - #124

Merged
captcrock merged 1 commit into
mainfrom
td/5299-background-delegates
Nov 23, 2026
Merged

captcrock merged 1 commit into
mainfrom
td/5299-background-delegates

Conversation

@captcrock

Copy link
Copy Markdown
Contributor

Milestone: background delegates scoped to the turn (owner decision row 17; design section 4.3 of the sub-tasks note).

  • delegate takes background: true (and label). The child runs as a task the session owns, and the call returns at once.
  • A writer always gets its own worktree, opened at spawn. Where there can't be one, the call is refused with a hint to run it in the foreground.
  • Scoped to the turn. A settled worker's summary reaches the parent model as a note at the next tool-batch boundary. If the model stops calling tools while a worker is alive, the turn waits without calling the model, then hands over the note. _emit_turn_complete stops any worker still alive, so none outlives its turn.
  • Stopping. Stop and cancel end every worker. delegate_stop, or the window's worker_stop, ends one. A stopped writer leaves no worktree folder.
  • Limits. Beyond max_running (2), workers wait in a queue. Beyond max_per_turn (8), the call is refused. Each worker has its own ceilings: 24 calls, 30 minutes, and $5 but never more than its share of what the spend cap has left. Workers honour the session caps even under skip-all.
  • Refusals. Background workers are refused from a child, autonomy runs, scheduled runs and deny-and-continue runs.
  • Restart. Live workers become interrupted. Each one's worktree is committed to its branch and the folder removed. Nothing is re-run.
  • Protocol. New events worker_jobs and worker_result, a worker_stop verb (open to a phone, since it only stops), and two Class A builtins: delegate_output and delegate_stop.
  • UI. The Plan pane lists workers with Stop and each finished worker's steps.
  • The DECISIONS.md entry revises TD-4602 and TD-5195 on the two points the design names.

Not in this story: the optional per-worker check, and steering a running child (4.4).

Checks

  • Core: 9012 passed, 13 skipped with TST_REQUIRE_SANDBOX=1. ruff and mypy are clean.
  • UI: tsc, svelte-check, vitest (2880) and build are clean.

🤖 Generated with Claude Code

… the turn

delegate gains background: true (and label). The child starts as a task
the session owns (worker_jobs.py, delegate_background.py) through the same
run_child_task as a foreground child, and the call returns at once. A
writer always gets its own worktree, opened at spawn; where there can be
none the call is refused with a hint to run it in the foreground.

The worker belongs to its turn. A settled worker's summary reaches the
parent model as a note at the next tool-batch boundary (worker_turn.py);
when the model stops calling tools with a worker alive, the turn waits
with no model call for a worker to settle, a steer or Stop, then gives the
note. _emit_turn_complete stops any worker still alive, so none outlives
its turn. Stop, cancel, delegate_stop and the window's worker_stop end
workers; queued past delegate.background.max_running, refused past
max_per_turn, and refused from a child, autonomy, a scheduled run or a
deny-and-continue run. Each worker has its own call, time and spend
ceiling and honours the session caps even under skip-all. After a restart
live workers are interrupted, their worktree is committed to its branch
and removed, and nothing is re-run.

New events worker_jobs and worker_result, verb worker_stop, Class A tools
delegate_output and delegate_stop (rule delegate-job, plan mode allowed,
never a child's). The Plan pane lists workers with Stop and their steps.
Class B entry in DECISIONS.md revising TD-4602 and TD-5195 on two points.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@captcrock
captcrock merged commit 02de371 into main Nov 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant