Repository navigation
refactor(subagents): centralize completion delivery decisions - #206383
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: passed. What this changesThis PR centralizes subagent completion policy while retaining the existing transport and lifecycle persistence owners. Example: A parent silently consumes child result ALPHA.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR implements the requested ownership consolidation, and the pinned diff contains no actionable regression. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherSubagent announcement code receives child outcomes and requester receipts, chooses delivery or handoff outcomes, and passes them to existing transport, history, and registry owners. flowchart TD
A[Child terminal outcome] --> B[Child result preparation]
B --> C[Completion obligation]
C --> D[Transport adapters]
D --> E[Requester receipts]
E --> C
C --> F[Lifecycle cleanup]
F --> G[Registry and requester history]
Technical reviewBest possible solution: Land the completion-decision cutover with its existing transport and persistence boundaries once the required current-head checks pass. Do we have a high-confidence way to reproduce the issue? This is a behavior-preserving ownership refactor, with no new user-facing defect claimed; source inspection confirms the distributed decisions it consolidates, and no target code was executed. Is this the best way to solve the issue? The cutover fits the requested scope: it removes the previous decision implementations, preserves existing helper consumers, and leaves transport execution and durable writes with their established owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against df78bb4a3ac7. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +339, Other -1. Total +338 across 8 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 27, 2026, 12:05 AM ET / 05:05 UTC. |
|
Merged via squash auto-merge.
|
…aw#206383) * refactor(subagents): centralize completion delivery decisions * docs(subagents): explain trusted delivery receipt assertion
Preserve the existing requester restart reason in announce classification so unconsumed completed results remain pending for startup custody. Existing consumption receipts prevent replay; permanent refusals, explicit cancellation, and ambiguous sends retain their policies. (cherry picked from commit b8b06c4) Follow-ups: fca5133 fix: preserve child completion inputs across Gateway restarts (#208367) [not selected for this narrow backport]; b7967b2 fix: deliver a saved child answer after a Gateway crash (#207706) [not selected for this narrow backport]; 17e2ec9 fix: tell the user when a finished subagent's report can't start in their chat (#207194) [not selected for this narrow backport]; 811f999 refactor(subagents): centralize completion delivery decisions (#206383) [not selected for this narrow backport]; 50a6774 fix: retain channel requester when child completion resumes parent [separately ordered lane row]; d2699a8 chore: carry and enforce participant limits on admitted runs (#204847) [not selected for this narrow backport]; 57dd84b fix(agents): settle every undelivered child completion into history; drop delivery dispositions (#204260) [separately ordered lane row]; cded11f fix(agents): deliver a child's end state as parent history, not a turn obligation (#204178) [not selected for this narrow backport]; 92e92d7 fix: preserve restarted child results and gateway test ownership (#203839) [not selected for this narrow backport]; 09d956b fix(subagents): wake a yielded requester for each ready child result (#203176) [not selected for this narrow backport]; 9f35510 fix: retain child results behind live requester turns (#203198) [separately ordered lane row]; c23cd7f fix: preserve private child results during restart (#203156) [separately ordered lane row] Release adaptation: Keep stable requester fixture setup and insert the two consumed/unconsumed restart cases without moving its existing lost-yield test. Co-authored-by: RomneyDa <[email protected]>
Closes #206373
Related: #204178
What Problem This Solves
Maintainers currently have to follow subagent completion decisions through direct response classification, announce-flow reporting, and lifecycle cleanup. The same delivery obligation is interpreted in several places, making receipt precedence and fallback changes difficult to review.
This is the maintainer-requested cutover to one completion-decision owner.
User Impact
No intentional user-visible behavior change. Direct delivery, queue custody, requester handoff, and requester-history settlement retain their existing behavior. The legacy
suspended,failed, anddiscardedreaders and active admission expiry remain intact.Why This Change Was Made
The obligation module owns reply policy, response/fallback decisions, once-only receipt reporting, and cleanup outcomes. Transport adapters execute those decisions and return receipts; the existing lifecycle owners still persist state. Child-result preparation is separated from dispatch. Existing import surfaces used by
sessions_sendcontinue to expose the same implementations.The explicit decision and fact contracts add 286 production SLOC in the measured scope while reducing the large functions below. No stored-state format or configuration is added.
Evidence
Pinned base:
2ab7b31a13d95bbbb62596679b130445c4c9d3d1Current head:
41a93922a7d9133306268d767bb7d1894f3f9d14Runtime-proof head:
5639d82df867f6078604bec1df5611609770b839Validation ran on Blacksmith Testbox
tbx_01m8dj32n7ns87rv8wnj2zynme(4 CPUs, about 16 GB RAM, Node 24.22.1, pnpm 12.15.0), using the repository source-capsule wrapper. Allocation workflow; the command receipts verified the runtime-proof head above independently of the allocation workflow.sessions_send, and prompt-prefix coverage: 434 tests passed in 37 files, five shards.pnpm tsgo:core: passed.pnpm tsgo:test:src: passed.pnpm test src/agents/subagents --maxWorkers=2: all six shards passed; existing skips were retained.preserves routed native Stop authority and existing receipts (consumed-session)case passed in this run. The previously reported failure did not reproduce here; this PR does not claim to fix it.git diff --check: passed. Live-provider tests were not run.code-sloppiness0.2.0+vk.4, identical scope/engine, complete coverage with no parse failures:runSubagentAnnounceFlowBoundsendSubagentAnnounceDirectlyBoundcreateDirectAnnounceResponseClassifierstartSubagentAnnounceCleanupFlowThe new response-decision functions have CC 45 and 35; classification complexity was split along evidence and outcome boundaries, not discarded. Measured production SLOC: 5,178 → 5,464.
git grep -cover production announce files and the two cleanup files, using\.delivered|delivery\??\.status|announceOutcome ===: 45 → 43 matching lines. Legacy-state predicates insubagent-delivery-state.ts: 5 → 5.Open overlap: #198204 — completion review no longer repeats a result the user already saw also changes the announce flow. This branch remains pinned to its reviewed base; integration belongs to the coordinator.