Subagent yield handoff
The subagent registry owns completion acrosssessions_yield. A yielded
execution ends; the delegated task and its completion audience remain. The
registry’s requester settlement batch starts a successor turn after the
children settle. Gateway admission attaches that successor to a paused
subagent when necessary, preserving its original requester.
This design applies equally to an orchestrator spawned from an interactive
session and one spawned from an isolated cron run. Cron owns delivery of the
scheduled result, while the registry owns the nested orchestrator’s continuation.
Ownership through the handoff
The implementation owners are
subagent-registry-requester-yield.ts,
subagent-announce.requester-settle-wake.ts, and
agent-task-tracking.ts. adoptPausedSubagentRunForFollowUp uses the existing
registry replacement operation; it does not create a second delegated task.
Settlement dispatch uses subagent_settle input provenance. Individual
announcements and the older descendant-wake path retain subagent_announce:
the latter already owns its run replacement after dispatch and must not trigger
paused-run adoption at admission. Provenance classifies the handoff; live
Gateway admission and registry ownership still authorize it.
An explicit yield batch must be eligible at any requester depth. The ordinary
nested-wave exclusion remains: nested runs without a yielded batch use the
existing descendant-settle path. The top-level cron exclusion also remains;
starting an independent requester-settle turn for the cron session would compete
with its scheduler-owned continuation.
Invariants
- One completion owner. Yield transfers ownership before closing the old execution. An existing visible-final receipt for the exact turn and child batch prevents rearming an already fulfilled obligation. Successful batch settlement retires that generation; a repeated callback cannot finalize it again.
- No revived authority. Neither a stored run ID nor provenance revives a closed execution. The successor passes normal Gateway admission and receives fresh execution authority. Adoption preserves task lineage, not old tool, approval, channel, or worker callbacks. Cancellation, reset, and owner replacement retain their existing admission and cleanup gates.
- Stable audience. A nested wake uses internal delivery. A settlement
continuation targeting a live
sessions_yield-paused row adopts that row; ordinary inter-session messages remain untracked. Explicit plugin follow-ups naming a new requester continue to create their own delivery obligation. - Deterministic batches. Frozen run IDs are sorted. Findings use creation time, completion time, and child session identity as tie-breakers. Superseded child rows are excluded. Batch identity includes requester identity, child IDs, and yield generation.
- Bounded delivery. Existing limits remain: three attempts, three ambiguous transport replays, and ten stale deferrals. Active descendants do not consume the stale-deferral budget. Findings are capped at 4,096 characters, individual results at 512, and route notices at 1,024. Ambiguous replay reuses its attempt key; it does not assert global exactly-once delivery across Gateway restarts.