Repository navigation
fix(agents): a subagent's previous result is lost when its next turn starts quickly - #163352
Conversation
Keep completed subagent results and their parent-delivery custody across ordinary next-turn admission. Fence predecessor session effects while preserving exact execution guards, independent receipts, and fresh successor authority. Paused continuation and steer retain replacement semantics. Regression proof uses registered agent admission with paused transcript and delivery boundaries, distinct turn outputs, durable receipts, restored pending delivery, and replay deduplication. Focused announce, reactivation, registry, type, lint, and formatting checks passed; independent review found no actionable P0-P2 findings.
|
🦞👀 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 maintainer review before merge. Reviewed October 2, 2026, 4:32 AM ET / 08:32 UTC (Revision 3). ClawSweeper reviewWhat this changesPreserves each completed subagent turn’s parent announcement and receipt when a quick follow-up starts, while giving the new turn independent delivery authority. Merge readiness✅ Ready for maintainer review This fix remains necessary on current main. The new production-boundary evidence resolves the previous authority-proof blocker; no actionable introduced defect was found. Priority: P1 Review scores
Verification
How this fits togetherSubagents report completed work back to their parent through the Gateway and persistent run registry. Follow-up admission must preserve outstanding results while preventing older turns from changing the continuing child session. flowchart TD
A[Child turn completes] --> B[Persistent run registry]
C[Follow-up admission] --> B
B --> D[Independent turn custody]
D --> E[Exact turn result]
E --> F[Current requester authority]
F --> G[Parent input and receipt]
B --> H[Latest turn owns session cleanup]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +31, Tests +824, Docs +8, Other 0. Total +863 across 29 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep completion custody and receipts independent per execution while restricting child-session cleanup to the latest turn. Do we have a high-confidence way to reproduce the issue? Yes: source establishes predecessor deletion during completed-child follow-up admission, and supplied real Gateway before-and-after observations demonstrate the loss. This read-only review did not execute tests. Is this the best way to solve the issue? Yes: the existing registry owner preserves exact execution delivery while separating session cleanup and successor authority; the new boundary cases directly cover the earlier review concern. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4ad3766a2169. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Update sibling expectations for retained completed runs, keep requester completion task-scoped, and wait for the real Gateway dispatch signal in the admission regression. Migrate the benchmark to the cleanup ownership callback.
…ctivation-keeps-delivery
|
Live proof, run on an isolated Gateway with a real OpenAI model, the embedded runtime, and real SQLite workers. Turn 2 of a visible managed-worktree child is admitted through the real admission path before turn 1's parent delivery settles. Each turn emits a distinct output, and results are reconciled against the stopped databases.
Each turn produced exactly one announcement with its own terminal row and receipt, and worktree ownership was preserved. The regression sweep on the same build passes: concurrency (6/6 results plus the parent final), both |
…ctivation-keeps-delivery
Exercise real child Gateway admission and requester input writes with independently revoked predecessor and successor sources. Assert persisted receipts, transcript attribution, exact source identity, and replay deduplication. All three cases reject a borrowed-authority negative control.
|
Merged via squash.
|
…agent follow-up (#163814) * fix(agents): stale pause notice wakes the requester after a quick subagent follow-up A follow-up admitted while a child is still yielding with waitFor "message" registers as its own task at the next session generation, because adoption only matches rows that are already paused. Since #163352 a newer task can no longer revoke another task's requester custody, so the paused row's pause notice stayed current and woke the requester with a "paused awaiting continuation" turn after the follow-up had already continued the child. A yield-paused row holds no result, only its continuation: treat any newer execution of its session as superseding it. Completed rows keep the same-task rule that preserves retained delivery from #163352. Fixes the Gateway E2E shard 1/4 failure in plugin-subagent-self-yield-followup.e2e.test.ts. * fix(agents): keep requester-bound siblings from cancelling a paused child's notice A plugin follow-up that names its own requester is an independent sibling with its own completion delivery; by contract the original paused task stays resumable and its pending pause notice is still owed. Supersede a yield-paused row only by a newer execution of the same task or one without its own completion audience (a default follow-up that continues the child).
…starts quickly (openclaw#163352) * fix(agents): preserve completed turn delivery during follow-up Keep completed subagent results and their parent-delivery custody across ordinary next-turn admission. Fence predecessor session effects while preserving exact execution guards, independent receipts, and fresh successor authority. Paused continuation and steer retain replacement semantics. Regression proof uses registered agent admission with paused transcript and delivery boundaries, distinct turn outputs, durable receipts, restored pending delivery, and replay deduplication. Focused announce, reactivation, registry, type, lint, and formatting checks passed; independent review found no actionable P0-P2 findings. * test(agents): align follow-up delivery CI coverage Update sibling expectations for retained completed runs, keep requester completion task-scoped, and wait for the real Gateway dispatch signal in the admission regression. Migrate the benchmark to the cleanup ownership callback. * test(agents): prove independent completion delivery authority Exercise real child Gateway admission and requester input writes with independently revoked predecessor and successor sources. Assert persisted receipts, transcript attribution, exact source identity, and replay deduplication. All three cases reject a borrowed-authority negative control.
…agent follow-up (openclaw#163814) * fix(agents): stale pause notice wakes the requester after a quick subagent follow-up A follow-up admitted while a child is still yielding with waitFor "message" registers as its own task at the next session generation, because adoption only matches rows that are already paused. Since openclaw#163352 a newer task can no longer revoke another task's requester custody, so the paused row's pause notice stayed current and woke the requester with a "paused awaiting continuation" turn after the follow-up had already continued the child. A yield-paused row holds no result, only its continuation: treat any newer execution of its session as superseding it. Completed rows keep the same-task rule that preserves retained delivery from openclaw#163352. Fixes the Gateway E2E shard 1/4 failure in plugin-subagent-self-yield-followup.e2e.test.ts. * fix(agents): keep requester-bound siblings from cancelling a paused child's notice A plugin follow-up that names its own requester is an independent sibling with its own completion delivery; by contract the original paused task stays resumable and its pending pause notice is still owed. Supersede a yield-paused row only by a newer execution of the same task or one without its own completion audience (a default follow-up that continues the child).
What Problem This Solves
Fixes: when a completed subagent (for example a visible child in a managed worktree) is given its next turn before its previous result has been announced, the previous turn's announcement to the parent is dropped. The log shows
Subagent announce failed: ... transcript identity changed during announcement., and the parent only ever hears about the later turn.User Impact
Each completed turn keeps its own parent announcement and receipt while the child continues working, so parents no longer miss results from quick follow-ups. Child transcripts were never affected.
Why This Change Was Made
Ordinary follow-up admission in
reactivateCompletedSubagentSessionwent through steer replacement, which retired the completed run's registry row along with its pending delivery owner. Follow-ups now preserve the completed execution through the registry row owner (mutateSubagentRuns). A superseded run that still owes its completion is announced instead of retired, and the new turn gets independent successor authority. Delivery stays bound to the exact execution, and the predecessor's session effects stay fenced from the newer turn. Paused continuation and steer keep their replacement behavior. No schema change. Production LOC +96/-65.Evidence
761171d03b00, 846 focused announce/reactivation/registry cases passed across 18 files.pnpm tsgo:core, all 27 affected test type graphs, typed lint, oxfmt, deslop, andgit diff --checkpass. Codex autoreview through P2 is scoped-clean.CI follow-up
The initial CI run 36977686534 exposed stale retirement expectations in four sibling suites, a benchmark caller still using the renamed cleanup callback, and a fixture dispatch-pump race in the new Gateway regression. The assertions now require retained predecessor custody and independent successor identity; the Gateway fixture waits for the actual command-entry signal instead of pumping fake timers over real worker persistence. No runtime behavior or timeout budget was changed by these repairs.
The unrelated worker-placement lint failure was repaired on main by
95a67da528c7; main was merged without conflicts. The reviewed PR patch has the same stable patch ID before and after that merge. Fresh Codex autoreview through P2 is scoped-clean. All 27 affected test type graphs, script types, typed lint, formatting, and diff checks passed for the repaired candidate; the inherited lint check also passed after integration.The integrated head
fe4a273af918929f93e5ce5d6310d57077813734passes 445 focused tests across five files with--maxWorkers=1. Gateway methods took 82.92 s; announcement-worker and steering tests together took 55.44 s; cancellation publication took 37.68 s; requester-wake commit took 9.92 s (Vitest wall times). Individual pre-integration one-worker file times were 79.44 s, 17.11 s, 62.59 s, and 17.17 s for announcement-worker, steering, publication, and requester-wake respectively. These existing integration fixtures exercise registered admission, worker settlement, or the parent turn and were updated without adding cases. The recovery-sweep benchmark also passed (1.71 s, zero session effects).The inherited duplicate logger field, Doctor fixture lint errors, and custody import cycle were subsequently repaired on main by
d81a2d8b7294and0f470aecdc12; those fixes are included through a conflict-free main merge.Final-effect authority proof
server.native-completion-authority.test.tsnow exercises two registered executions in one child session through real Gateway admission. Both completion announcements are held immediately before the real requester input writer, after the successor was admitted. Each execution has a separately revocable operator source. The test controls model output; child transcript writes/reads, announcement dispatch, requester authorization, input/transcript persistence, dedupe, and delivery receipts use the production owners.All three cases pass. Resuming both completed runs produces no duplicate requester input or command. A temporary borrowed-authority mutation failed all three cases for the intended reasons: wrong source identity with both sources live, zero deliveries instead of one after predecessor revocation, and two instead of one after successor revocation. The production file was restored byte-for-byte; no production defect or additional runtime change was needed.
Validation: 43 focused tests passed across native completion, registered custody, and reactivation suites. The final native file replay passed all 12 cases after the assertion lint correction. Affected
gateway-servertsgo graph, typed lint, oxfmt,git diff --check, and fresh delta autoreview through P2 pass. With--maxWorkers=1, the three new cases initially took 1.90 s / 2.25 s / 1.14 s; the final full-file run took 95.45 s wrapper wall (91.05 s Vitest wall) under concurrent local validation. The suite reuses one Gateway; this contract needs real admission and persistence to observe revoked final effects. No timeout, retry, or worker configuration was relaxed.Current head:
6695946a45fb05b10352d7a1f74d711102ff01e7. Exact-head CI run 36983990346 passed. The three new cases also passed in CI in 2.433 s / 1.120 s / 0.975 s (4.528 s combined case time). ClawSweeper revision 3 explicitly resolves the authority-proof blocker and reports no actionable findings or remaining pre-merge items. Native preparation is complete at this head. No merge has been submitted; the external exact-head live-proof gate remains in force.