Repository navigation
refactor(subagents): centralize requester turn custody - #206286
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: needs changes before merge. What this changesThis PR centralizes repeated subagent pause, requester-turn binding, pending-result, and yield-intent predicates. Example: A child has pauseReason="sessions_yield".
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: it is a useful maintainer-directed consolidation, and source review found no definite introduced bug. Reviewed head: Before merge
FindingsNone. Agent review detailsHow this fits togetherThe subagent registry consumes recorded child and requester state to decide completion delivery, cleanup, recovery, and status presentation. flowchart TD
A[Recorded subagent state] --> B[Requester custody predicates]
B --> C[Completion and delivery]
B --> D[Cleanup and recovery]
B --> E[Status presentation]
F[Live requester and frozen cohort owners] --> C
Technical reviewBest possible solution: Retain the shared recorded-state predicates and existing specialized owners, then complete validation before merging. Do we have a high-confidence way to reproduce the issue? This is a behavior-preserving refactor with no reported defect to reproduce; no target code was executed during this read-only review. Is this the best way to solve the issue? The small shared module consolidates repeated recorded-state conditions without replacing liveness, cohort currency, persistence, or authority owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3ffd7660334a. Provenance checked
TestingProof path: none. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +85. Total +85 across 37 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 26, 2026, 9:00 PM ET / November 27, 2026, 02:00 UTC. |
|
|
Merged via squash.
|
* refactor(subagents): centralize requester turn custody predicates * fix(subagents): preserve existing requester identity boundaries
What Problem This Solves
Subagent completion, cleanup, recovery, and status paths repeat the same recorded pause, pending-result, and requester-yield decisions.
User Impact
No intended behavior change. Existing pause, delivery, cancellation, and requester-turn semantics are preserved.
Why This Change Was Made
Adds one runtime-free owner for three predicates:
isSubagentPausedByYield,hasPendingRequesterTurnResult, andhasRequesterTurnYielded. Migrates matching decisions in the allowed callers while preserving the separate live-requester and frozen-cohort owners.Exact requester-turn ID comparisons remain at their existing sites. The original extraction moved one existing equality into the new module, which failed the session-identity per-file ratchet (
2 > 0). The follow-up restores those expressions and removes both binding helpers; it changes neither the ratchet nor its allowlist and adds no alternate comparison syntax.The kill files and
announce/subagent-announce*.tsflows are unchanged. No state, schema, public API, configuration, or dependency changes.Evidence
2ab7b31a13d95bbbb62596679b130445c4c9d3d1; current head:cc429cf90829a20753598a1004ff3863bd3e10bd.tbx_01m8dn540ww4hbw6xjkskwr4x8: wrapper verified the current source and frozen dependencies; observed 4 CPUs and 15 GB RAM. 316 focused tests and all 2,260 subagent tests passed, with zero failures and one existing opt-in benchmark skipped.pnpm tsgo:core, allpnpm tsgo:test:srcshards, and changed-file oxlint passed (zero warnings/errors).git diff --checkpassed. Current-head GitHub CI is green, including the session-identity ratchet and required CI gate. The standalone ratchet probe rejected an unsupported--base=argument before inspecting source; this accounts for the Testbox command's combined exit 1. Its test, typecheck, and lint checks all exited 0. Ratchet proof is the successful exact-head CI job, not the rejected probe.1078eff569cc190788a30693e30ed3a5c54f5c82: 316 focused tests passed on base and head; full subagent suite had 2,260 passed, zero failed, one opt-in benchmark skipped; core and source-test typechecks and changed-file lint passed. This is historical proof, not a current-head CI claim.The campaign's known baseline failure was reproduced by running
preserves routed native Stop authority and existing receipts (consumed-session)alone on base: expectedaborted: false, receivedaborted: true. It passed in both head runs' full suites. This refactor does not claim to repair that failure; no behavior-fix red/green claim is made.Measurements and retained semantics
Counts use
git grep -coversrc/agents/subagents,src/agents/tools/subagents-tool.ts, andsrc/gateway/session-restart-*.ts, excluding*.test*. Counts are matching lines, not AST reads; field access includes writes, projections, and parameters.requesterTurnRunId/requesterTurnYieldedproperty-access linespauseReason ===/!== "sessions_yield"decision linesThe six remaining caller pause comparisons are in excluded kill and announce-flow files. The new owner has three functions with CC 1, 2, 1.
Code-sloppiness scans 15 → 32 cover the same 36 caller files; scan 33 covers the new owner. No parse failures. Largest-function CC remains unchanged:
startSubagentAnnounceCleanupFlow98,scheduleRequesterSettleWake94,planTerminalCompletion94,settleRequesterTurnAfterSessionSpawns86. Caller score 39.0223 → 39.0307; clone SLOC 47 → 47. This centralizes decisions without claiming a complexity-score improvement. Production diff: +141 / -85 across 36 files; test diff: 0.Retained raw fields serve normalization, writes, forwarding, projections, exact frozen identities, or different presence rules. Memory retirement distinguishes explicit false from an absent completion flag; recovery can require no binding regardless of completion; registry retirement also recognizes frozen membership. Inline acknowledgement keeps its existing truthy yield check; the shared predicate serves strict-true sites.
subagent-requester-turn-liveness.tsremains the physical live-requester owner.subagent-requester-settle-identity.tsremains the frozen-cohort owner. Follow-up through the owning lanes: migrate the excluded kill/announce pause checks. No unrelated behavior repairs are included.Open PR overlap
Searched open subagent PRs before implementation. Known intersecting changes include:
#194275,
#200231,
#199455,
#201097,
#194732,
#186845,
#197335,
#153550,
#197123,
#183715,
#188492,
#136554,
#140956,
#201774,
#191857,
#201613,
#201315,
#150933,
#121309,
#164366,
#179902,
#203303,
#192845.
These are overlap notices; no unrelated fixes are incorporated.