Repository navigation
fix: prevent missed and duplicate parent turns after worker replies - #206529
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 clears finished delivery attempts sooner and suppresses parent wakes acknowledged before admission while preserving accepted handoffs. Example: A worker finishes with "saved answer" while its parent detaches.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses two concrete completion races still present on current main; no actionable introduced defect was found. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared completion owner receives worker results and consumption receipts, coordinates delivery through the harness adapter, and retires completed obligations. flowchart LR
Worker[Worker result] --> Owner[Shared completion owner]
Receipt[Consumption receipt] --> Owner
Owner --> Admission[Delivery admission]
Admission --> Transport[Harness delivery transport]
Transport --> Parent[Parent session]
Owner --> Retirement[Assignment retirement]
Technical reviewBest possible solution: Keep the focused repair in the existing completion owner and demonstrate both race outcomes through the production delivery boundary. Do we have a high-confidence way to reproduce the issue? Source inspection establishes both race windows, and the PR reports both focused regressions failing on the base; this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs attempt ownership and first-admission consumption in the existing owner without adding a competing lifecycle, public API, configuration, or persistence format. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e0a1193c02e0. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +19, Tests +97. Total +116 across 2 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: 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 (1 earlier review cycle)
Reviewed November 27, 2026, 6:15 AM ET / 11:15 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
What Problem This Solves
A worker can finish successfully and still leave its parent waiting. If the parent detaches just as a delivery attempt decides to wait, the next attempt can join one that has already finished. In another race, an acknowledgment arrives during requester lookup and the parent gets a redundant turn.
User Impact
A finished worker can reach the parent when it detaches. An answer already read by the parent can retire without another turn.
Why This Change Was Made
The shared completion owner now clears the finished attempt before its promise settles. It checks whether the parent consumed the result when delivery first requests admission. A later acknowledgment leaves an accepted handoff intact. Ownership checks still run at execution.
Please review the admission boundary before merging. The first revision could revoke an accepted handoff. An unchanged Codex contention test caught that regression. The second commit fixes it. The guard treats an exception after refusing an already consumed result as superseded. It doesn't cancel in-flight transport.
Evidence
5e245aa0. Detaching lost the reply. Acknowledging during lookup caused a duplicate delivery.544f90ba, all 43 SDK, authority and Codex contention cases passed in 269 seconds including compilation. The two regressions took 47 ms and 9 ms. Formatting and type-aware lint passed. The timing tests control the delivery boundary with mocks.wait_agent. The six later turns each produced one notification and one terminal reply, including a result saved during a disconnect. The goal completed once with no pending input. This development build also included fix: goals stop after native child-result handoffs #193024, fix: recover a completed Codex reply after a brief disconnect #205298 and fix(codex): keep remote workers when only the OpenClaw version changes #206231. It exercised the user flow without forcing either race.Local checks used older cached dependencies. The hosted CI run passed in 1,015 seconds.
Timing controls through the Gateway
Five isolated runs used the real Gateway, Codex CLI 0.164.0 and synthetic model replies. Each sent one chat request and started one worker. Test-only hooks controlled when the parent detached or when OpenClaw applied a genuine
wait_agentacknowledgment. The same development build selected the unchanged completion owner from either commit. It included none of the other pending fixes.5e245aa0544f90ba5e245aa0544f90ba544f90baAll five retained the original parent reply. I checked each worker’s saved answer, matched notification IDs to the native turn and checked parent history after a three-second observation window. The hooks forced these orderings. The trial does not measure how often they occur.