Skip to content

fix: deliver later answers from a reused Codex worker - #206014

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

freeqaz-openai merged 1 commit into
mainfrom
fix/reused-codex-worker-answers

Conversation

@freeqaz-openai

Copy link
Copy Markdown
Contributor

What Problem This Solves

A persistent Codex worker can complete several tasks while its parent works on a goal. When the monitor rediscovers that worker, two different results can share a delivery ID. The Gateway acknowledges the second delivery, but the parent keeps working without the new answer.

User Impact

The parent can receive each known worker turn. Retrying the same delivery keeps its ID. This fixes a lost answer independently of the goal scheduling repair in #193024.

Why This Change Was Made

Keep an existing turn-specific assignment ID. If the assignment identifies only the thread, use the observed native turn. Ignore a history read that finishes after the child became terminal, so it cannot change the ID on retry. Task ownership and permissions stay unchanged.

Upgrade note. Settle pending deliveries before upgrading. If the old Gateway accepted a thread-only ID but the monitor still considers it pending, retrying under a new ID can announce the answer again. When no turn ID is known, the old thread-only fallback still cannot distinguish successive results. No schema or configuration change.

Evidence

  • On 66397a57, two known turns produced the same thread-only ID. Adding just the new key exposed a second failure when a delayed history read changed the key between retries. All 22 monitor cases pass at 4de8f0f1. The three backoff cases took 7, 7, 8 ms. The cold command took 137.61 s.
  • In an isolated Linux x64 Gateway with Codex 0.164.0 and synthetic inference, the second and fourth follow-ups produced identical delivery IDs. The fourth returned success in 33 ms without a new parent acknowledgment. Native history confirmed both distinct completed turns.
  • The same setup with the fix used one worker for six turns. All five delayed replies had unique acknowledged IDs, and each subsequent automatic turn received its fresh answer. The original goal completed once with no pending input. The Gateway trial used 82b682c6 with the goal and worker-recovery changes from fix: goals stop after native child-result handoffs #193024 and fix: recover a completed Codex reply after a brief disconnect #205298. Diagnostic tracing was removed for the passing trial.

Ran pnpm test extensions/codex/src/app-server/native-subagent-monitor.test.ts --maxWorkers=1, type-aware lint and formatting checks. The isolated tests used cached dependencies. Full locked-dependency checks are left to hosted CI. Independent native Codex review covered the full diff at all priorities and cleared the late-read fix. The standalone review command could not start its reviewer on this host.

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

@freeqaz-openai
freeqaz-openai marked this pull request as ready for review November 26, 2026 15:31
@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. 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 gives rediscovered Codex worker completions turn-specific delivery IDs and prevents late history reads from changing their retry identity.

Example: Worker child-thread completes known turns first and second under parent-thread.

  • Before: Both results can use codex-native:parent-thread:child-thread:succeeded, causing the second answer to be deduplicated.
  • After: The results use distinct turn-specific IDs, while retries of each result retain their ID.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and source-consistent, but required shipped-path execution evidence is missing.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
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 silently misses a later answer from the same Codex worker because the Gateway treats it as an earlier delivery.
Reason: Distinct known worker turns must reach the parent, and the supplied maintainer-authored direction resolves product approval.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a concrete completion-ID collision still present on main, and no definite introduced correctness bug was found.

Reviewed head: 4de8f0f1cd3a6687f73846261d99fae4aabe3f4a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide a Gateway trace or copied live output showing distinct reused-worker turns acknowledged and received, with a stable ID on retry; redact IPs, API keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

The Codex plugin monitors native worker notifications and history, then hands completed answers to the Gateway's existing completion delivery and deduplication owners.

flowchart TD
  A[Codex worker turns] --> B[Notifications and history]
  B --> C[Native subagent monitor]
  C --> D[Completion delivery identity]
  D --> E[Gateway deduplication]
  E --> F[Parent receives answer]
Loading

Technical review

Best possible solution:

Keep completion identity selection in the existing delivery owner and freeze terminal observations against late history reads.

Do we have a high-confidence way to reproduce the issue?

Source shows different known turns sharing a thread-only announcement ID that reaches Gateway deduplication; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The focused repair reuses existing assignment and delivery owners, preserves turn-specific assignment IDs, and blocks the demonstrated late-read identity change without restoring broader recovery machinery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0ce45b70c5fd.

Provenance checked

  • Reusable assignment and completion identity keeps the original intent (41784ac: Preserve separate follow-up assignments, history locators, and delivery ownership while reusing the native conversation.)
  • Best-effort history reconciliation keeps the original intent (1746b63: Remove overlapping recovery state machines while retaining ordinary settlement and durable receipts.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +6, Tests +20. Total +26 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 12 6 +6
Tests 1 24 4 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 36 10 +26

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: Changing the delivery ID can duplicate an already-accepted pending announcement across upgrade; the owner-directed PR explicitly documents settling pending deliveries first.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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: Changing the delivery ID can duplicate an already-accepted pending announcement across upgrade; the owner-directed PR explicitly documents settling pending deliveries first.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach redacted output from the reported Gateway trial showing the distinct delivery IDs and fresh parent acknowledgments.

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, 10:48 AM ET / 15:48 UTC.

@freeqaz-openai

Copy link
Copy Markdown
Contributor Author

Gateway delivery trace for 4de8f0f1

One goal reused one worker for an initial task and five delayed tasks. Below are selected fields from an isolated Linux Gateway using real Codex 0.164.0 with synthetic inference. This build backported the fix to 82b682c6 alongside the queue, callback and goal repairs. It omitted the separate disconnect patch.

Times are milliseconds from the start of the trial. P and W denote the same parent and worker throughout. T1–T5 replace distinct accepted turn IDs verified in native worker history. Each answer had a fresh marker withheld until release. The last column records the first automatic parent request containing that marker.

runId                                           settlement releasedMs parentAnnouncementMs automaticWithAnswerMs
announce:codex-native:P:codex-thread:W:turn:T1:succeeded verified 29723 31360 32664
announce:codex-native:P:codex-thread:W:turn:T2:succeeded verified 35439 36814 38099
announce:codex-native:P:codex-thread:W:turn:T3:succeeded verified 40484 41827 43081
announce:codex-native:P:codex-thread:W:turn:T4:succeeded verified 45554 46805 48026
announce:codex-native:P:codex-thread:W:turn:T5:succeeded verified 50414 51659 52880
{"status": "complete", "active": false, "pendingInputs": 0, "completions": 1}

Retry was tested separately. The three reattach cases in the monitor test forced the first delivery to fail. Both calls kept the same ID and backoff for each known turn and for the unknown turn with a late history read. The Gateway run above observed one settled announcement per delayed answer. It did not force a retry or simulate an upgrade during delivery.

@freeqaz-openai
freeqaz-openai merged commit a3ed12c into main Nov 26, 2026
190 of 192 checks passed
@freeqaz-openai
freeqaz-openai deleted the fix/reused-codex-worker-answers branch November 26, 2026 15:54
@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
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]>
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. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS 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