Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20436,3 +20436,34 @@ nothing until it is signed by `start_autonomy`; deleting a job stops runs.
**Rejected:** a separate permission for editing jobs (one switch is what
the owner's list names); comparing a pause's other fields with the stored
job (it would need the store in the pure policy table).

## 2026-11-23 — TD-5299: background delegates, scoped to the turn (Class B)

**Decision:** `delegate` gains `background` and `label`. A background
child is a `WorkerJob` on the parent session (`worker_jobs.py`), run as a
task through the same `run_child_task` as a foreground child. The loop
puts each settled worker's note in at the tool-batch boundary a steer
joins, and at turn end waits (no model call) while a worker is alive or
its note is owed. `_emit_turn_complete` stops any worker still alive, so
none outlives its turn. Two events (`worker_jobs`, `worker_result`), one
client verb (`worker_stop`, open to a phone since it only stops), and two
Class A builtins (`delegate_output`, `delegate_stop`). Defaults:
`max_running` 2, `max_per_turn` 8, `max_iterations` 24, `max_minutes` 30,
`max_usd` 5.0 and never more than a `max_running` share of what the spend
cap has left.

**Rationale:** scoping to the turn keeps approvals, caps, Stop and the
session state machine as they are (owner decision row 17). This revises
two records on purpose. TD-4602 rejected timeline events for child steps:
a background call's `tool_result` returns at spawn, so the transcript
needs `worker_result` to ride on. TD-5195 rejected a model fan-out with
`delegate`: the shared limit, forced worktrees, prefixed call ids and Stop
answer each fault it listed. A background worker honours the session caps
even under skip-all, which is stricter than a foreground child, because it
is the closest an interactive session comes to an unattended run.

**Rejected:** workers that outlive the turn (design 4.8, later); refusing
at capacity instead of queueing (a small model handles "it starts when a
slot frees" better than "try again"); starting a writer from the latest
checkpoint instead of `HEAD` (it would need the checkpoint code reviewed;
the spawn note says uncommitted edits are not in the child's worktree).
34 changes: 34 additions & 0 deletions core/scripts/generate_protocol_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@
ValidateApiKey,
VerifyResult,
VerifyStarted,
WorkerJobInfo,
WorkerJobs,
WorkerResult,
WorkerStep,
WorkerStop,
WorktreeState,
build_hello_ack,
build_pair_ok,
Expand Down Expand Up @@ -670,6 +674,7 @@
"dismiss_schedule_proposal": DismissScheduleProposal(
session_id="sess-1", proposal_id="sp_0123456789ab"
),
"worker_stop": WorkerStop(session_id="sess-1", worker_id="w-1"),
# What a paired phone may change (TD-5279): on for an hour.
"set_phone_permission": SetPhonePermission(
capability="mcp_servers", enabled=True, expires_in_seconds=3600
Expand Down Expand Up @@ -1638,6 +1643,35 @@
"schedule_proposal_decision": ScheduleProposalDecision(
session_id="sess-1", seq=8, proposal_id="sp_0123456789ab", decision="saved", job_id="job-1"
),
# A background worker running and one settled (TD-5299).
"worker_jobs": WorkerJobs(
session_id="sess-1",
seq=9,
workers=[
WorkerJobInfo(
worker_id="w-1",
label="fix the date parser",
kind="worker",
task="Fix the date parser and run its tests.",
state="running",
calls=3,
cost_usd=0.0123,
started_at=1795400000.0,
branch="tst/child-1",
worktree_path="/work/.worktrees/child-1",
last_step="pytest tests/test_dates.py",
)
],
),
"worker_result": WorkerResult(
session_id="sess-1",
seq=10,
worker_id="w-1",
state="done",
summary="Fixed the parser; 12 tests pass.",
transcript=[WorkerStep(kind="reply", text="Fixed the parser; 12 tests pass.")],
branch="tst/child-1",
),
"phone_change": PhoneChange(
device_name="Pixel",
capability="mcp_servers",
Expand Down
Loading
Loading