Repository navigation
fix(subagents): late older completion receipt delivers the superseded child answer - #166139
Conversation
An older equivalent terminal receipt kept the newer end time but replaced the stored reply, so a late replay could deliver the superseded child answer. Co-authored-by: fangyun1008 <[email protected]>
|
@clawsweeper re-review Older equivalent completion receipts now keep a newer visible answer or intentional silence. Proof is in the PR body, on head fcb88a1. |
|
🦞👀 Re-review progress:
|
|
🦞👀 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 8, 2026, 4:06 AM ET / 08:06 UTC (Revision 5). ClawSweeper reviewWhat this changesPreserves accepted subagent replies when older or equal-time completion receipts arrive, while allowing newer corrections and first reply evidence. Example: A child’s older completion receipt arrives while its newer answer awaits delivery.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a remaining current-main defect and has sufficient real Gateway proof. No introduced correctness finding remains; the prior conflict blocker is resolved. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherSubagents report completed work through a shared registry before OpenClaw delivers the result to their parent. This owner combines producer reply evidence, completion timing, persistence, and cleanup. flowchart TD
A[Child completion receipts] --> B[Shared completion owner]
C[Accepted reply and end time] --> B
B --> D{Existing evidence and incoming time}
D -->|Older or equal| E[Retain accepted reply]
D -->|Newer or first evidence| F[Merge producer reply]
E --> G[Persist registry and finish cleanup]
F --> G
G --> H[Deliver result to parent]
Technical reviewBest possible solution: Keep receipt freshness at the shared completion owner, preserving intentional silence, newer corrections, and existing cleanup and generation fencing. Do we have a high-confidence way to reproduce the issue? Yes: process a newer then older same-run receipt while delivery is pending and the full transcript is unavailable. Supplied Gateway before/after output demonstrates the failure on pinned main, and fetched current-main source retains the same mechanism; this review did not execute it. Is this the best way to solve the issue? Yes: the guard repairs freshness where producer evidence is accepted, without weakening terminal-evidence precedence or adding another ordering owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bf67191c52e0. Provenance checked
TestingProof path: shipped entry point. Added test files: 1. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +5, Tests +60, Docs +5. Total +70 across 3 files. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label 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 HistoryReview history (4 earlier review cycles)
|
Keep accepted producer reply evidence when an older or equal-time receipt arrives, while allowing newer corrections and first evidence after terminal timing. Duplicate receipts still drain the existing cleanup tail. Cover visible, silent, and empty replies plus first producer evidence, and consolidate completion-state/capture handling in the same owner. Fixes openclaw#142850 Original fix by @Yun-0000; maintainer cleanup and ordering coverage. Co-authored-by: Yun. <[email protected]>
Merge main at a066127 while preserving contributor ancestry and the same-run receipt ordering guard and regressions. Keep main's ACP/CLI transcript and per-run answer text together with the producer end-time ordering paragraph.
|
Merged via squash.
|
… child answer (openclaw#166139) * fix(subagents): keep newer completion text when an older receipt arrives An older equivalent terminal receipt kept the newer end time but replaced the stored reply, so a late replay could deliver the superseded child answer. Co-authored-by: fangyun1008 <[email protected]> * fix(subagents): retain newest same-run completion reply Keep accepted producer reply evidence when an older or equal-time receipt arrives, while allowing newer corrections and first evidence after terminal timing. Duplicate receipts still drain the existing cleanup tail. Cover visible, silent, and empty replies plus first producer evidence, and consolidate completion-state/capture handling in the same owner. Fixes openclaw#142850 Original fix by @Yun-0000; maintainer cleanup and ordering coverage. Co-authored-by: Yun. <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: fangyun1008 <[email protected]> Co-authored-by: Yun. <[email protected]>
… child answer (#166139) * fix(subagents): keep newer completion text when an older receipt arrives An older equivalent terminal receipt kept the newer end time but replaced the stored reply, so a late replay could deliver the superseded child answer. Co-authored-by: fangyun1008 <[email protected]> * fix(subagents): retain newest same-run completion reply Keep accepted producer reply evidence when an older or equal-time receipt arrives, while allowing newer corrections and first evidence after terminal timing. Duplicate receipts still drain the existing cleanup tail. Cover visible, silent, and empty replies plus first producer evidence, and consolidate completion-state/capture handling in the same owner. Fixes #142850 Original fix by @Yun-0000; maintainer cleanup and ordering coverage. Co-authored-by: Yun. <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: fangyun1008 <[email protected]> Co-authored-by: Yun. <[email protected]> (cherry picked from commit 4dc4755)
Fixes #142850
What Problem This Solves
Fixes: a requester can receive superseded child text when an older completion receipt for the same run arrives after a newer one.
User Impact
Pending completion delivery retains the newer answer or intentional silence. Equal producer end times retain the first accepted reply; corrections with a newer end time can replace it. Different child runs retain their existing generation fencing.
Why This Change Was Made
The completion owner already preserves newer terminal timing for an older equivalent receipt, but previously merged the older receipt's reply into both stored reply fields. Reply selection now respects that existing producer end-time ordering while duplicate callbacks can still finish cleanup. First producer evidence remains admissible when terminal timing exists without a reply.
The maintainer revision also consolidates duplicate completion-state access and identical capture-failure handling in the same owner. No schema, public protocol, configuration, or receipt-revision contract changes.
Original fix by @Yun-0000; maintainer cleanup by @steipete adds timestamp-tie coverage, first-evidence coverage, documentation, and isolated runtime verification. Contributor commit and verified human credit are preserved.
Evidence
Candidate:
3427c68a01086341c6257487b417ebb7bd8b72d2, after merging maina06612710e674f493a3ae8fe1158f60bb56d3924without rebase or force-push. The docs conflict preserves main’s ACP/CLI and per-run answer wording together with receipt ordering. Original before-fix baseline:bddfdd59022dd71421ce7b6a6b7e6406bf5e69f4. Node 24.21.0, pnpm 12.5.1. All contributor-code execution used fresh Untrusted AWS leases, the trusted main bootstrap, exact-head verification, IMDS no-role admission, public networking without Tailscale, and no credential hydration.0a0d7caaeb54), retaining the new tests and reverting only production: 6 expected failures, 5 passed; 30.94 s wall time. Older/tied visible, silent, and empty replies expose the defect.0a0d7caaeb54: 1,415 passed, one existing opt-in 5,000-session benchmark skipped, across 78 discovered files. The sibling invocation took 2,054.02 s including its full E2E build prerequisites; no unexpected test failures occurred.pnpm tsgo:corepassed in 16.58 s;pnpm tsgo:core:test --ci-graphs-json '["core-test-agents-sessions"]'passed in 15.56 s. The earlier docs link audit checked 14,921 internal links with zero broken links; this merge adds no links, and formatting/whitespace checks passed.git diff --checkpassed locally; no contributor runtime code ran on the maintainer host.3427c68a01086341c6257487b417ebb7bd8b72d2.Fresh merge validation: one new secretless AWS lease,
cbx_c273a343f8dc(r7a.4xlarge, 128 GiB nominal; 129,108,512 KiB reported), ran all three requested commands and the fixed live comparison sequentially. Runrun_6598439f0220bf3b0faae5661b509c4aexited 0 withMERGED_PROOF_PASS 3427c68a01086341c6257487b417ebb7bd8b72d2. The three real-Gateway cases passed again in 101.98 s: the parent received onlyRECEIPT-NEWERfor the older receipt, onlyRECEIPT-FIRSTfor a tie, andRECEIPT-CORRECTEDfor the newer receipt. Main changed receipt publication and announcement composition, so the live fixed proof was rerun; the original failing-main comparison below remains historical evidence. The lease was released after proof. The first release request timed out; a fresh coordinator read confirmed it remained active before the successful retry.The merged-head commands were:
The launch used the clean trusted-main bootstrap with
--provider aws --id cbx_c273a343f8dc --fresh-pr openclaw/openclaw#166139 --no-hydrate --script scripts/crabbox-untrusted-bootstrap.sh -- 3427c68a01086341c6257487b417ebb7bd8b72d2. Its first coordinator lookup timed out before admission; empty lease history was verified before retrying the same lease. No test or live failure occurred in this merge validation.Original real Gateway before/after at
0a0d7caaeb54: leasecbx_21b67824feca, runrun_8a42e5253ec5a560e0dc3421003b3df5, exit 0. Three cases passed on the fixed head (115.21 s), then the same fixture reproduced the old behavior on pinned main (113.79 s). Each case verifies both the persisted registry result and the parent's persistedchat.history.RECEIPT-OLDER(superseded answer)RECEIPT-NEWERonlyRECEIPT-TIE-LOSERRECEIPT-FIRSTonlyRECEIPT-CORRECTEDRECEIPT-CORRECTEDThe fixture starts a real Gateway on an ephemeral loopback port with an isolated state directory and the QA mock OpenAI provider. Real RPC and
sessions_spawncreate the parent and child; the child reads a synthetic workspace file and completes. The publicsessions.compactRPC withmaxLines: 1removes that child's full transcript, and the native announcement reader verifies that delivery will use the retained receipt. This is a relevant supported path: when a full transcript is available, it can mask a bad bounded receipt.For deterministic receipt ordering, a scheduling wrapper delays the target child's real
runSubagentAnnounceFlow, then calls the original with unchanged arguments and returns its actual result. A passive native lock-release observer joins the injected lifecycle receipt. Neither persistence nor delivery is mocked; native authority checks, SQLite, announcement, the parent model, and transcript persistence all execute. The fixture then releases delivery and asserts that the losing marker is absent from the parent history. No new production seam was added.Sanitized excerpts:
Proof limits: lifecycle receipt replay and scheduling are synthetic fault injection; the child execution and full requester-delivery stack are real. This tests same-run ordering, not network transport reordering. Two discarded fixture attempts exposed that intact transcripts mask receipt text and that a synthetic descendant causes another child turn; neither was counted as bug reproduction. The final fixture removes that descendant and proves the supported retained-result path. Fleet admission initially returned 429; two later coordinator lookup timeouts were reconciled before retrying. No bootstrap or product failure was hidden by retries.
Commands and cost
Unit lease:
cbx_7dd97f17265b.The second command is the negative control and pinned-main reproduction. The remaining registry files were selected with the following command (the changed file had already run in full):
Original live fixture commands, on the original exact-head untrusted lease:
The original lanes launched from a clean trusted main worktree using
crabbox run --provider aws --fresh-pr openclaw/openclaw#166139 --no-hydrate --script scripts/crabbox-untrusted-bootstrap.sh -- 0a0d7caaeb5453b037efad1f9e4c414f6200a765 .... Unit run:run_71636731b8f42bcd0e209c3714b8e455, exit 0. Both task-owned leases were released after proof.The eleven ordering/first-evidence cases measured 5–7 ms each. These owner-boundary cases protect publication behavior rather than helper implementation; existing persistence/lifecycle cases dominate the full-file cost. The broad sibling cost is existing module coverage, not new test startup.
Exact numstat against the merged main base (main now contains the earlier cleanup, so the unchanged ordering guard is +5 production lines):
subagent-registry-lifecycle-completion.ts(production)subagent-registry-lifecycle.test.tsdocs/tools/subagents/announce.mdPrior-head CI timings include shared setup and additional tests; they are not attributable per-file costs. Selected changed-test jobs took 138–217 s; production typecheck 239 s; test-type coordinator 202 s; docs 177 s.
Review decisions
The earlier full ClawSweeper review (revision 3, head
0a0d7caaeb54, October 8 at 06:39 UTC) reported no introduced correctness finding. Its two blocking asks required current-head real persistence/requester-delivery proof and a corrected body. The evidence above supplies that proof, and this body now describes equal-time retention and current-head validation.Fresh independent Codex review of the merged candidate was scoped-clean, with no actionable P0–P2 findings.
The earlier independent Codex review identified a valid edge case: terminal timing may exist before the first producer reply. The guard now requires existing reply evidence, with older/equal first-evidence regressions. A second suggestion to introduce separate ordering against the accepted reply's own timestamp was rejected: the selected contract uses the retained run receipt
endedAt. For example, a correction at 3999 is still older than the retained receipt at 4000, even if missing reply evidence was first filled by a receipt at 3998. Changing that watermark would expand the ordering contract beyond this repair. No accepted actionable review finding remains.