Repository navigation
fix(codex): keep late worker notices from completing a newer task - #206080
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 prevents delayed contextual worker notices from completing or acknowledging a newer identified task. Example: Worker child-thread starts followup-turn before a delayed notice containing “previous answer” arrives.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a source-confirmed result-assignment bug that remains on main. No actionable defects were found, and the reviewed head’s CI gate passes. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Codex plugin’s native subagent monitor consumes app-server events and history, associates results and receipts with task assignments, and hands completed results to Gateway delivery. flowchart LR
A[Codex app server] --> B[Notification parser]
B --> C[Native subagent monitor]
D[Native turn history] --> C
B --> E[Assignment receipt tracker]
C --> E
C --> F[Gateway completion delivery]
E --> F
Technical reviewBest possible solution: Keep completion and acknowledgment tied to the identified child’s evidence within the existing monitor and receipt tracker. Do we have a high-confidence way to reproduce the issue? Current main permits a thread-only assignment with a known nativeTurnId to accept an older contextual result, while its single-outcome receipt shortcut can acknowledge that assignment early; the supplied controlled Gateway traces demonstrate both effects. Is this the best way to solve the issue? The change repairs both completion and acknowledgment at their existing owners, preserves the other receipt families, and adds no parallel mechanism or public contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d344e991bd7a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource 0, Tests +23. Total +23 across 4 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, 1:01 PM ET / 18:01 UTC. |
|
Merged via squash.
|
…06080) (cherry picked from commit 47027a2) Release adaptation: No source or test changes from main. Stable already carries prerequisite #206014 as 2940130, so the monitor and both regressions apply cleanly. Later same-file #206447 (a9569e9) centralizes completion delivery; it is not needed for the native-turn and contextual-receipt guards and is not included. Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit a3ed12c) Companion disposition: #206080 is a same-owner follow-up separately assessed for release compatibility. Co-authored-by: RomneyDa <[email protected]>
…06080) (cherry picked from commit 47027a2) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
A parent can reuse a worker while a notice from the previous task is still in flight. The notice identifies the worker but omits the child turn ID. If the monitor has rediscovered the worker under a thread-only assignment, it can announce the previous answer under the new turn's ID. It can also mark the new answer as received before the worker finishes.
User Impact
A goal can continue with the new answer. No configuration, permission, storage or protocol change. When a completion event is missing, the parent may have to wait for native history. If neither source is available, a contextual notice alone cannot finish a known child turn.
Why This Change Was Made
Use the child's turn event or history to finish an identified turn. Defer a contextual receipt until its result matches, even if a fresh observer knows only one assignment. Preserve native wait and V2 agent-message receipts, which can render errors differently.
The delivery ID in #206014 distinguishes successive turns. This fix checks the result assigned to that ID. The separate proposal in #149490 concerns whether a foreground model response consumed a receipt. A notice cannot distinguish identical results after the previous assignment is gone. The fallback for workers with no known turn remains.
Evidence
On the original monitor, both known-turn cases delivered the old answer. With only the child-turn guard, the active-parent case delivered nothing. The complete fix passed 142 tests across the monitor, receipt and notification files with one worker per shard, plus type-aware lint and formatting. The two test shards took 215 seconds including compilation. The new case took 9 ms. The reattach cases took 6–18 ms and the existing native relay case took 7.1 seconds. Local tests used cached dependencies.
Isolated Gateway trace
One Linux amd64 Gateway and real Codex 0.164.0 used synthetic inference. Both builds used
82b682c6with the goal repair from #193024, its queue prerequisites and the turn-ID fix. The only code difference between the two builds was this patch.First, the monitor delayed processing an actual parent notice until the next worker task started. The notice was unchanged. A second control changed only the notice's parent turn ID to simulate receiving that fragment during a later parent turn. These are controlled timings. They do not establish the cause of an earlier untraced timeout.
Selected trace fields below use elapsed milliseconds. B identifies the worker’s second turn. Answer 0 came from the completed first task. The fixture withheld answer 1 until release. A delivery entry means the Gateway acknowledged the announcement for B.
Both repaired runs verified all six native worker turns. A separate run without instrumentation passed one image test with no skips. Its final counters were
{"event": "gateway-model-admission", "ok": true, "status": "complete", "overlaps": 5, "workerTurns": 6, "observed": {"active": false, "status": "complete", "pendingInputs": 0, "continuations": 11, "announcements": 5, "completions": 1}, "freshAnswers": 5, "distinctReceipts": 5}No production rollout or external inference.