Skip to content

fix(codex): keep late worker notices from completing a newer task - #206080

Merged
freeqaz-openai merged 1 commit into
mainfrom
fix/codex-stale-worker-notice
Nov 26, 2026
Merged

freeqaz-openai merged 1 commit into
mainfrom
fix/codex-stale-worker-notice

Conversation

@freeqaz-openai

Copy link
Copy Markdown
Contributor

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 82b682c6 with 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.

case                     noticeMs  releaseMs  resultForB  deliveryMs  parentUsedAnswer1
old turn, before         34556     34868      0           36624       False
old turn, fixed          34541     34858      1           36798       True
current turn, before     34493     34806      0           none        False
current turn, fixed      35070     35396      1           37156       True

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.

@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 26, 2026
@clawsweeper

clawsweeper Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This 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.

  • Before: The monitor can deliver the previous answer under the newer turn’s identity or suppress its eventual delivery.
  • After: The monitor waits for child-turn evidence and delivers “fresh answer” for followup-turn.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, worthwhile repair with production-path before/after evidence, regression coverage, passing exact-head gates, and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Public before/after traces exercise delayed contextual notices through a real Gateway and Codex app server with synthetic inference, showing fresh-result delivery and parent use in both timing cases; the trace uses the patch on an older composed build, supplemented by passing exact-head CI. The added contextual flag is runtime-only, with no persisted format or migration change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A parent reusing a Codex worker can receive an old answer as the new task’s result or never receive the fresh answer.
Reason: Correct assignment attribution is an existing contract, and the focused repair follows the supplied maintainer-approved direction.

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: e8f4d9a32e9368b607ac7a0c476a2a1aca017f06

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source 0, Tests +23. Total +23 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 22 22 0
Tests 2 25 2 +23
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 47 24 +23

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add merge-risk: 🚨 message-delivery: The patch changes when native results become deliverable or acknowledged; its documented, accepted tradeoff is that a known turn waits for child events or history instead of completing from contextual notice alone.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • merge-risk: 🚨 message-delivery: The patch changes when native results become deliverable or acknowledged; its documented, accepted tradeoff is that a known turn waits for child events or history instead of completing from contextual notice alone.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 26, 2026, 1:01 PM ET / 18:01 UTC.

@freeqaz-openai
freeqaz-openai merged commit 47027a2 into main Nov 26, 2026
126 of 127 checks passed
@freeqaz-openai
freeqaz-openai deleted the fix/codex-stale-worker-notice branch November 26, 2026 18:04
@freeqaz-openai

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
(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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant