Repository navigation
fix(agents): avoid repeating delivered child results on settle - #178104
Conversation
Retire fully delivered non-yielded waves without dispatching another requester turn. Mixed and yielded continuations reference consumed children and include only undelivered payloads, using existing batch delivery facts. Preserve explicit yield resumption and document the single-delivery contract.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef61cfa9f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| : await readChildCompletionFindings( | ||
| completionRows.filter((entry) => entry.delivery?.status !== "delivered"), | ||
| ); |
There was a problem hiding this comment.
Revalidate delivery state after reading findings
If an individual announcement commits delivery.status = "delivered" while readChildCompletionFindings is awaiting transcript reads, this snapshot still includes that child's payload. PreparedAnnounceResult.isCurrent() validates only run ownership and outcome, and the later refreshBatch() does not rebuild completionRows or preparedFindings, so settlement can dispatch the stale payload—or dispatch after every member has become delivered—and reproduce the duplicate completion this change is intended to prevent.
Useful? React with 👍 / 👎.
| : await readChildCompletionFindings( | ||
| completionRows.filter((entry) => entry.delivery?.status !== "delivered"), | ||
| ); |
There was a problem hiding this comment.
Base mixed-batch reply policy on the remaining results
For a non-yielded mixed cohort where a private child is already delivered and a public sibling remains pending, this filter removes the private payload but resolveRequesterSettlePolicy has already inspected all completionRows and set parentOnly because of that delivered private row. The resulting continuation therefore contains only the public sibling's result while being dispatched as a private completion, whose delivery classifier accepts silent internal consumption without a visible receipt; the still-undelivered public result can consequently never reach the original conversation.
Useful? React with 👍 / 👎.
|
Landing stopped at reviewed head Gateway job 118472594679 fails A separate test-types job reports TS2367 at |
|
Codex review: needs changes before merge. What this changesThis PR suppresses already-delivered child results when settling grouped or yielded subagent work. Example: A parent retries children run-a and run-b during a settle-wake turn, and both results arrive before that turn ends.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Needs changes before merge - 3 items remain Keep this PR open for repair: preventing duplicate completions is useful, but the patch removes actionable restart-recovery guidance and leaves affected recovery tests failing. Priority: P2 Before merge
Findings
Provenance
Agent review detailsHow this fits togetherThe subagent registry supplies completion and delivery facts to requester settlement, which prepares one parent continuation through the session mailbox and Gateway. flowchart TD
A[Child executions] --> B[Registry completion facts]
B --> C[Individual announcements]
C --> D[Delivery receipts]
D --> E[Requester settlement]
B --> E
E --> F[Session mailbox and Gateway]
F --> G[Parent continuation]
Technical reviewBest possible solution: Suppress repeated result payloads in the existing settlement owner while preserving unfinished-child recovery guidance and meaningful recovery coverage. Do we have a high-confidence way to reproduce the issue? Current main only suppresses fully delivered single-child waves, establishing the grouped-duplicate path; the author reports live reproduction, and exact-head CI independently demonstrates the introduced recovery failure. Is this the best way to solve the issue? Using existing delivery receipts and settlement ownership is appropriately small, but notification delivery cannot determine whether interrupted child work still needs reconciliation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 555c0182e4d0. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +14, Tests +73, Docs +9. Total +96 across 8 files. Added test files: 0. View PR surface stats
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 October 20, 2026, 1:47 AM ET / 05:47 UTC. |
Keep restart-interrupted child findings and the requester-scoped recovery roster even when an earlier result has a delivery receipt. Use the same rule when retiring fully delivered waves so unfinished recovery still reaches the requester. Normal completed results retain the no-repeat contract. Preserve the existing Gateway replay assertions and add a regression for a delivered interrupted child in a non-yielded wave.
Use the production restart marker in interrupted custody fixtures. Keep undelivered custody pending, hold requester preparation for capacity tests, and assert delivered waves retire without another payload.
|
Merged via squash.
|
…law#178104) * fix(agents): avoid repeating delivered child results on settle Retire fully delivered non-yielded waves without dispatching another requester turn. Mixed and yielded continuations reference consumed children and include only undelivered payloads, using existing batch delivery facts. Preserve explicit yield resumption and document the single-delivery contract. * fix(agents): preserve interrupted child settlement recovery Keep restart-interrupted child findings and the requester-scoped recovery roster even when an earlier result has a delivery receipt. Use the same rule when retiring fully delivered waves so unfinished recovery still reaches the requester. Normal completed results retain the no-repeat contract. Preserve the existing Gateway replay assertions and add a regression for a delivered interrupted child in a non-yielded wave. * test(agents): align settle fixtures with delivered results Use the production restart marker in interrupted custody fixtures. Keep undelivered custody pending, hold requester preparation for capacity tests, and assert delivered waves retire without another payload.
…ns in gateway lane FRV tests (#187589) * fix(sessions): keep malformed rows out of the legacy transcript locator projection The #181247 backport (08ee066) adapted the main change for the release branch's legacy sessionFile locator by projecting json_extract(entry_json, '$.sessionFile') on every selected row. SQLite raises 'malformed JSON' for an unreadable entry_json before parseSessionEntryJson can apply its skip/reject policy, so ordinary selected listings and gateway lookups failed with a raw SQLite error. Project the locator only for transcript selections and only for valid JSON rows. Release-only: main retired the sessionFile locator. * test(logging): isolate log-tail prefix cases from cached inode (#173376) (cherry picked from commit 40806cf) * test(gateway): realign sessions_send owner continuation to the #181373 backport 9b8ee9c (#181373 backport) adopts timed sessions_send children into the requester turn and changes the inline wait to waitForAgentRunReply. The backport dropped a8a3680's matching fixture changes, so the test spied on the old SessionFollowupCompletion.take and waited forever. Apply main's fixture hunk (observe waitForAgentRunReply and registry persistence). The release branch has no session-controller liveness check (#175837), so a claimed result is handed back only by the requester run's settlement; the synthetic original run now performs the settleRequesterRun call its embedded runner makes on completion. Adapted from a8a3680 * test(agents): keep six-outcome settle fixture undelivered after consumed-cohort backport The 2f7589a backport of #181260 filters delivered child findings from settle wakes (needsRequesterSettleFindings). On main, #178104 moved the shared makeSettledChild default to pending delivery; the release fixture still defaults to delivered, so this case lost every finding. Mark its children pending, as the backport did for its other undelivered fixtures. * test(gateway): keep progress-only settle recovery undelivered after #181260 backport Backport 2f7589a dropped the source commit's fixture change because main had moved the recovery case into server.subagent-settle-replay-recovery.test-support.ts. Apply the same 'progress only' pending-delivery setup to the inline release copy. (adapted from commit 535989c) * test(agents): keep private settle policy fixtures undelivered after #181260 backport Backport 2f7589a filters delivered child findings from settle wakes. On main, #178104 moved the shared fixture default to pending and renamed these cases to pending pairs; the release fixture still defaults to delivered, so the private marker was filtered. Mark the children pending. * test(agents): mock retireRequesterFollowupAuthority in settle retry fixture Backport 9b8ee9c (#181373) made execution cleanup call retireRequesterFollowupAuthority. This release-only fixture mocks requester-cron-authority.js without that export, so the retry wake threw and warned. Main no longer has this mock. * fix(subagents): keep queued collectors out of operator completion custody The release adaptation 4643f86 of #181373 started capturing the operator continuation context for every spawn so collectors also record their original requester source. It dropped the collect guard on binding completion authority, so a queued collector retained an operator source hold after its parent completed or stopped. Main binds only non-collect runs (authority && !registerParams.collect); restore that guard here and keep completionAuthorityRequired aligned with it. * test(agents): mark settle retry cron-authority mock as isolation The added retireRequesterFollowupAuthority export changed the grandfathered factory hash. Name the isolation reason and prune the stale baseline entry. --------- Co-authored-by: Patrick Erichsen <[email protected]>
… after #181260 backport Backport 2f7589a (#181260) filters delivered child findings from settle wakes (needsRequesterSettleFindings), so this delivered-row case no longer reads the child transcript where it injected worker capacity and failed with 'expected findTranscriptEvent to be called'. Main realigned the same case in 411b2e6 (#178104): inject capacity at captureRequesterSessionEntryCurrent and assert the delivered result is not repeated in the resumed wake. Apply that realignment; the 'Already delivered child results' wording that main also asserts belongs to #178104's message change, which this branch does not carry. (adapted from commit 411b2e6)
…eadcode after backports (#187570) * refactor: keep Teams allowlist sentinel private (#185484) The Microsoft Teams fail-closed allowlist sentinel now remains module-private while preserving its exact restrictive projection and lifecycle coverage. (cherry picked from commit 59b1ddd) * test: teach the live-wrapper fake Bun to answer --revision Partial cherry-pick of the test/scripts/test-live.test.ts hunk only. #173807 (backported as e72f868) made the CI Bun --revision probe mandatory; the fake Bun fixture must answer it from the checkout pin. (cherry picked from commit 08dd80a) * test(ci): expect watchdog exit 124 from wedged run-tsgo #184639 (backported as d9a91b5) intentionally changed the run-tsgo watchdog exit from 1 to 124 so CI collectors stop admitting work. Main realigned this case in run-tsgo-worktree.test.ts (9b14a38); on the release branch the same watchdog case lives in run-tsgo.test.ts and was not realigned by the backport. * test(vitest): keep gateway database-worker routes in canonical order The beta.5 adaptation of #178415 (23a2bcd) prepended three integration proofs to gatewayDatabaseWorkerTestFiles. Canonical project ownership compares that list against sorted discovery, so the out-of-order entries failed vitest-cli-ownership. Move them to their sorted positions; routing membership is unchanged. * refactor: keep Slack reconnect policy private (#181690) Keeps Slack reconnect policy details module-private while preserving the exact invalid-auth cutoff, reset, and blocked-status behavior. (cherry picked from commit cd65901) * fix: keep retired Telegram throttler release private Telegram hunk of 09f9ec8 (#183086) only. The release-only test called the private helper directly; its surviving-alias case is already asserted through releaseRemovedTelegramAccountThrottler, so drop the duplicate direct call. (cherry picked from commit 09f9ec8, partial) * refactor: keep Claude partial-message measurement private src/agents/cli-output-stream-limits.ts hunk of 28e2774 (#184686) only; the backport of #184352 left this export without a consumer. (cherry picked from commit 28e2774, partial) * refactor: keep managed plugin cache selector private src/plugins/management-catalog.ts hunk of 2c0c30b (#185269) only; the backport of #184921 left this export without a consumer. (cherry picked from commit 2c0c30b, partial) * refactor(agents): keep requester settle batch callbacks type private The backport of #181260 (2f7589a) moved RequesterSettleWakeParams into the state module, leaving RequesterSettleWakeBatchCallbacks exported only for a test fixture. Main keeps it module-private; type the fixture through RequesterSettleWakeParams instead. * refactor(infra): drop unconsumed streaming UTF-8 decoder The minimal backport of #180861 (8d3183d) added decodeUtf8Chunks as a prerequisite, but its main consumers (streaming state-migration importers) were intentionally not backported, so production Knip flags it. Remove the export and its unit case; decodeUtf8Input is unchanged. * refactor(scripts): keep pinned Bun CI detection private The minimal #172625 backport (e6c3639) deferred the dev-tool, test-runtime and run-format callers that consume isCiEnvironment on main, so the export has no consumer on the release branch. * test(update): drop orphaned recovery version-mismatch fixture The #185692 backport in 39f9bde removed the last consumer of recoveryVersionMismatch from update-cli.plugin-convergence.test.ts. Main removed the same fixture in eae9bc4 (#181717). * test(gateway): type config removal mocks through inline module imports The release adaptation of #152052 (41aa7a6, de41770) typed its partial mocks through type-only namespace imports. Knip treats the secrets runtime namespace as the only consumer of its exports, so the full-tree scan reported prepareSecretsRuntimeSnapshotRestore and SecretResolverWarning as unused. Use main's inline typeof import() form. * refactor(shared): drop unconsumed async-store helper The backport of #179213 (6d9852d, plus f3fb0e9 registering it as a wrapper component) took the runWithAsyncStore helper and its test without the plugin-instance-invocation consumer, leaving src/shared/async-store.ts unused in production. Remove the helper, its test and its wrapper-components entry rather than complete a perf change during beta stabilization. * chore(knip): model backported perf scripts and Telegram worker fixture Mirror main's Knip entries for files added by beta.5 backports: - scripts/perf/{node-event-session-source-measure.mjs, stream-dispatch-scope-measure.ts,system-prompt-report-retention.ts} as path-invoked script roots (#183931, #183552, #183010); - the Telegram ingress context Worker fixture loaded by URL (#178909) in production ignoreFiles. Also register scripts/test-security-mail-parser.mjs, the standalone nodemailer sender-parsing regression added by #187301 (release-only). * refactor(doctor): keep dashboard migration guard at the repair boundary Release adaptation of 50b532d (#183153). The backport of #182345 (51f63cb) exported isUnstampedDashboardRoot only for its unit test. Main made it private and drove the eligibility cases through repairLegacyDashboardChatTypes using a canonical-repair fixture this branch does not carry. Keep every accepted and rejected row case, now asserted through the repair boundary with the branch's session accessor. * test(agents): hold requester preparation for the settle capacity case after #181260 backport Backport 2f7589a (#181260) filters delivered child findings from settle wakes (needsRequesterSettleFindings), so this delivered-row case no longer reads the child transcript where it injected worker capacity and failed with 'expected findTranscriptEvent to be called'. Main realigned the same case in 411b2e6 (#178104): inject capacity at captureRequesterSessionEntryCurrent and assert the delivered result is not repeated in the resumed wake. Apply that realignment; the 'Already delivered child results' wording that main also asserts belongs to #178104's message change, which this branch does not carry. (adapted from commit 411b2e6) --------- Co-authored-by: Shakker <[email protected]>
What Problem This Solves
A requester that spawns new children during a settle-wake turn receives their results twice. This is the normal way a parent retries failed children: the first batch settles, the parent is woken, it spawns replacements and keeps working.
subagent_settlecontinuation.The settle path only suppressed already-delivered children for single-child waves (
requiredSettled.length < 2).Live, on the Codex app-server route with Codex, parents retrying two impossible modules saw the duplicate in 2 of 3 runs on main. The second
announce:requester-settle:…wake carried exactly the two retry run ids, and both results were already present as in-turn completion events in the Codex rollout. The model replied, for example, "Correction — machinery: duplicate completion announcements arrived for both retries." That cost one extra model turn and produced a misleading machinery report. The owner is shared, so embedded OpenClaw and Claude CLI steering are affected too.User Impact
The requester that already knows is not woken. Batch ownership and the existing delivery receipts are unchanged. Restart-interrupted children stay in the recovery roster and keep their retained findings, because a delivery receipt does not discharge reconciliation of interrupted work. CI caught this on the first head:
server.startup-recovery-webchat.test.tsand three saved-batch replay cases. The second commit fixes it with a shared predicate, and those Gateway tests pass unchanged.Why This Change Was Made
sessions_yieldstill owes exactly one continuation, under the same no-repeat rule.docs/concepts/subagent-yield-handoff.mddocuments the single-delivery contract.Evidence
server.startup-recovery-webchat.test.ts(1/1) andserver.subagent-settle-replay.harness.test.ts(18/18) pass, with the four first-head failures reproduced red. A new regression covers an interrupted child whose earlier result was delivered.subagent-announce.requester-settle-ownership.test.ts: red on base (4 failed, including "Unexpected wake; consumed retry result repeated") and green with the fix (10 passed). 18 focused announce/registry files pass (212 tests).[8]only, the retry wave retired after in-turn delivery, and every final machinery line was clean. An Opus control parent was also clean.CI follow-up
CI run 39377981609 passed the static and Gateway gates but found 15 registry fixture assertions that still assumed delivered results would be loaded or repeated. The test-only follow-up marks interrupted fixtures with the production restart reason, leaves undelivered custody pending, and holds requester identity preparation instead of unnecessary transcript loading. The end-to-end test now requires delivered waves to retire without a second wake. No production logic changed in this follow-up.
Focused local verification covers all 125 cases in
subagent-registry.completion-authority.test.tsandsubagent-registry.requester-wake.e2e.test.ts: 92 custody cases passed; 30 wake cases passed and the three changed worker-capacity cases passed on the targeted rerun. Changed-file formatting and lint pass. Independent review found no actionable P0–P2 findings in the fixture repair.