Skip to content

fix(codex): keep peer turns alive when thread startup times out - #149393

Merged
fuller-stack-dev merged 3 commits into
mainfrom
fix/codex-startup-cancellation-containment
Sep 15, 2026
Merged

fuller-stack-dev merged 3 commits into
mainfrom
fix/codex-startup-cancellation-containment

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes unrelated Codex turns closing together when one shared client's thread startup times out or is canceled after dispatch.

User Impact

Healthy peer turns can continue, start a same-home helper after the delayed startup response arrives, and complete normally. An indeterminate startup retires its client from new acquisition while existing leases drain. If native startup never settles, same-home startup remains fenced until physical exit; each caller still has its own bounded deadline.

Why This Change Was Made

Caller cancellation does not establish that Codex finished loading native configuration. Keep the exact written request until its response or physical exit, and use the existing shared-client retirement owner. A late response can release the config fence but cannot resume the abandoned caller or gain authority over its replacement. Stateful startup requests remain independent.

Computer Use config mutation and compaction have separate completion contracts and remain outside this change. This repairs a reproduced failure mechanism; the incident's exact outstanding RPC was not recorded.

Evidence

Published head 3637c94883fe830812136beb720e39cf4315dbac includes the reviewed callback correction and canonical lint repairs through 6c28739b1aca420df0c753acb79f065085cc7229. Supplemental proof, independent report and manifest include the source identity and canonical impact assessment. All 19 published supplemental files and the manifest were downloaded and verified. Required exact-head CI passed on 3637c94883fe830812136beb720e39cf4315dbac.

  • Untouched canonical base: all three guarded methods failed healthy-peer survival; ordinary cancellation passed. Shared-client red.
  • Real Codex 0.154.0: native red, graceful-only retirement falsifier, and retained-response candidate green. The latter lets all three peers fork, complete, and exit after lease drain.
  • 120 focused tests passed, including late response/notification containment through real attempt/router ownership, stale tool rejection, replacement isolation, pending acquisition, overload, abort, and physical exit. Both extension type-check lanes passed. Independent autoreview found no actionable P0–P2 issues.

Exact-head evidence and inspected red/green recordings include the downloadable manifest, 239 raw source-blind API records, and independent review receipts. Head e5836380260f13ae2667d54037fd4e819dc93a21 passed real native proof for all three methods. Source-blind validation passed 11 clauses with no failures or blockers; binding/router authority and unrelated behavior are explicitly assigned to separate proof/scope. Native preparation completed on published head 3637c94883fe830812136beb720e39cf4315dbac using successful exact-head hosted CI. Merged through the native workflow as 4343400a52b40dfa010d4427a0ef35b8670511ef.

Combined Gateway and Control UI proof uses combined tree 9e94735e3724d33d801c4cc4c32f3e68251400e1, containing cancellation e5836380260f13ae2667d54037fd4e819dc93a21. Its source-blind checks observe a helper timeout on the shared process, peer survival and completion, original request completion, and a successful follow-up. The parent verified all 36 published artifacts. This combined tree predates the callback correction.

The callback correction has separate proof on exact proof head e63d6a91ac39175cfb3a9447f1d06ff9b2a3a300: real native 0.154.0 and independent API validation. All three startup methods preserve peer follow-up and completion after a late response. API validation passes 11 clauses with no failures or blockers and two explicit scope exclusions; its 237 raw records have SHA256 b90b93789f7381fc0d8516805218e5dd6ed1ffdace531d8b9e8ca975ed2e9b9d. The correction also passes 194 affected tests, extension test types, targeted lint/format, zero Madge cycles and scoped-clean autoreview.

@clawsweeper

clawsweeper Bot commented Sep 15, 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.

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review September 15, 2026 20:09
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 6:44 PM ET / 22:44 UTC (Revision 3).

ClawSweeper review

What this changes

The Codex plugin preserves healthy peer turns when thread startup times out by retiring the shared client while retaining response tracking until native completion or process exit.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main and in the latest release. No actionable introduced defect was found; the native proof supports the repair, and the previous review reported no code findings.

Priority: P2
Reviewed head: 3637c94883fe830812136beb720e39cf4315dbac

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with strong native behavior evidence, meaningful regression coverage and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The supplied maintainer evidence exercises the production client with real Codex 0.154.0, delayed startup responses and explicit aborts, observing peer follow-up, completion and final lease-drain exit. Supplemental attempt/router coverage checks stale binding and tool containment; independent video/raw-artifact inspection was limited by reviewer infrastructure.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The supplied maintainer evidence exercises the production client with real Codex 0.154.0, delayed startup responses and explicit aborts, observing peer follow-up, completion and final lease-drain exit. Supplemental attempt/router coverage checks stale binding and tool containment; independent video/raw-artifact inspection was limited by reviewer infrastructure.
Evidence reviewed 11 items Pinned introduction and merge result: Read the complete introduced production diff from the pinned base to the checked-out head. Raw commit records confirm the original head's two parents and the test merge's base-then-head parents; both head and test merge have tree 4a8d8c0c688ee446020b2caf78faa4fc9b673f3d.
Current main still closes peer transport: Current main handles an indeterminate written startup by calling closeAndRunAfterExit, closing the shared transport despite unrelated active leases.
Latest release retains the old path: GitHub source inspection of v2026.9.4 confirms the guarded startup path still calls closeAndRunAfterExit. The local release blob was unavailable, so the successful GitHub contents read supplied this verification.
Findings None None.
Security None None.

How this fits together

OpenClaw's Codex plugin sends thread and turn requests through a shared native app-server process. Its request and lease lifecycle determines whether one canceled startup interrupts other conversations or permits unsafe overlapping configuration work.

flowchart TD
 A[Thread startup request] --> B[Configuration fence]
 B --> C[Shared native client]
 C --> D{Caller times out?}
 D -->|No| E[Return startup result]
 D -->|Yes| F[Retire from new acquisition]
 F --> G[Existing peers continue]
 C --> H[Native response or process exit]
 H --> B
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +50, Tests +374. Total +424 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 69 19 +50
Tests 3 402 28 +374
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 471 47 +424

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +50 lines; tests net +374 lines Production growth extends existing request and retirement owners; the larger test addition covers peer survival and late-response containment.

Technical review

Best possible solution:

Keep cancellation local to its caller, preserve peer leases, and release configuration exclusion only on the exact native response or physical exit.

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

Yes: current main closes the shared transport when a written guarded startup times out while a peer holds a lease. The supplied native red/green report exercises that mechanism; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: extending response correlation and using the existing retirement owner preserves native configuration exclusion without terminating healthy peers or creating a competing lifecycle manager.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 14b8ad1d1871.

Labels

Label justifications:

  • P2: This repairs a bounded Codex concurrency failure where one startup timeout interrupts unrelated peer turns.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The supplied maintainer evidence exercises the production client with real Codex 0.154.0, delayed startup responses and explicit aborts, observing peer follow-up, completion and final lease-drain exit. Supplemental attempt/router coverage checks stale binding and tool containment; independent video/raw-artifact inspection was limited by reviewer infrastructure.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied maintainer evidence exercises the production client with real Codex 0.154.0, delayed startup responses and explicit aborts, observing peer follow-up, completion and final lease-drain exit. Supplemental attempt/router coverage checks stale binding and tool containment; independent video/raw-artifact inspection was limited by reviewer infrastructure.

Evidence

What I checked:

  • Pinned introduction and merge result: Read the complete introduced production diff from the pinned base to the checked-out head. Raw commit records confirm the original head's two parents and the test merge's base-then-head parents; both head and test merge have tree 4a8d8c0c688ee446020b2caf78faa4fc9b673f3d. (extensions/codex/src/app-server/client.ts:455, 3637c94883fe)
  • Current main still closes peer transport: Current main handles an indeterminate written startup by calling closeAndRunAfterExit, closing the shared transport despite unrelated active leases. (extensions/codex/src/app-server/client.ts:531, 14b8ad1d1871)
  • Latest release retains the old path: GitHub source inspection of v2026.9.4 confirms the guarded startup path still calls closeAndRunAfterExit. The local release blob was unavailable, so the successful GitHub contents read supplied this verification. (extensions/codex/src/app-server/client.ts:507, 3a9d69db306c)
  • Cancellation and completion remain separate: Written guarded requests retain correlation after their waiter detaches. Only a correlated response invokes the completion callback; logical transport closure does not release the native configuration fence. Pre-write ownership checks remain, and stateful requests are not deduplicated. (extensions/codex/src/app-server/request-attempt.ts:98, 3637c94883fe)
  • Existing retirement owner and stale-route containment: The injected callback uses the existing shared-client lifecycle owner, preserving pending acquisitions and active leases while removing the client from future acquisition. The added attempt regression checks stale responses, notifications, binding writes and tool requests against a replacement, including a positive replacement-tool control. (extensions/codex/src/app-server/attempt-startup-lifetime.test.ts:91, 3637c94883fe)
  • Affirmative native dependency signal: The changed guard applies directly to Codex thread/start, thread/resume and thread/fork RPCs, and the PR claims compatibility with real Codex 0.154.0. This makes native request completion semantics relevant to the review. (extensions/codex/src/app-server/client.ts:452, 3637c94883fe)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-15T20:24:32.777Z sha e583638 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T20:46:08.576Z sha e583638 :: blocked before merge. :: none

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

The same native fixture is red on base 35a716797719def47366cf78a20cfc81bfd8f83e and green on head e5836380260f13ae2667d54037fd4e819dc93a21 with actual Codex 0.154.0.

  • Raw red recording: thread/start, thread/resume and thread/fork timeouts each close the active peer's shared client and exit native.
  • Raw green recording: each caller settles in 301 ms; the peer stays connected, forks after late response delivery, completes its native turn, and exits after final lease drain.
  • Artifact manifest: exact commands, source/native identities, checksums, raw logs, fixture, contract and review receipts.
  • Independent source-blind report: 11 clauses passed, no failures or blockers, 2 explicit scope exclusions. All six method/trigger combinations passed, plus prewrite and invalid-resume controls. 239 raw API records and independent probes are included.

AWS lease cbx_91d9fb067018, Node 24.18.1, pnpm 12.3.4, native source 6b9826e3aa83b1a5947db50f4332cb9c65f1b340. Exact-head native run: https://crabbox.openclaw.ai/portal/runs/run_1e62638611a2. Source-blind run: https://crabbox.openclaw.ai/portal/runs/run_125a4f776c2c. Both succeeded. Videos and outcome frames were inspected; all prompts/state/provider responses are synthetic. Downloaded publications matched their checksums. Signed artifact links expire September 22; the evidence bundle is retained.

Graceful-only retirement was rejected by a real native falsifier: the existing peer's same-home follow-up fork remained fenced after late completion. Keeping exact response correlation releases that fence without reviving the canceled caller. Stateful startup is never deduplicated. The real attempt/router regression additionally checks late thread/started, no stale binding/inference/tool execution or replacement unsubscribe, and a positive replacement tool control.

120 focused tests passed, with 34 startup tests passing again after the mechanical test split. Both extension typecheck lanes and final five-file lint/format passed. Final autoreview is scoped-clean, with no P0-P2 findings. ClawSweeper's exact-head review found no issues; this downloadable bundle addresses its portal-access limitation. There are no unresolved review threads.

A permanently stuck native operation still fences same-home startup until physical exit; each caller retains a bounded deadline. Computer Use config mutation and compaction retain their existing paths and need separate completion contracts. The incident's exact outstanding RPC remains unknown. Required CI is still running; merge remains under maintainer coordination.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 15, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

The callback correction is published at 3637c94883fe830812136beb720e39cf4315dbac, tree 4a8d8c0c688ee446020b2caf78faa4fc9b673f3d. This append-only update preserves the original PR head and merges canonical 6c28739b1aca420df0c753acb79f065085cc7229, including the managed-update lint repair.

The correction removes the static client/lifecycle import cycle by supplying retirement from the existing shared owner and capturing it with the selected guard before awaits. It preserves the reviewed request, fence and lease behavior. Publication identity records the verified parents and human signature. Canonical impact assessment explains why the intervening changes do not invalidate the direct startup/native/attempt proof.

Evidence for exact proof head e63d6a91ac39175cfb3a9447f1d06ff9b2a3a300, whose containment bytes are unchanged in the published tree:

  • Native 0.154.0 raw results: start, resume and fork callers time out in 300–301 ms; healthy peers fork after the late response, complete, then exit after final lease drain.
  • Independent source-blind report and raw API records: 11 clauses pass, no failures or blockers, two explicit exclusions. Six method/trigger combinations cover deadlines and aborts, same-home fencing, peer completion, replacement ownership and exit isolation. The 237-record SHA256 is b90b93789f7381fc0d8516805218e5dd6ed1ffdace531d8b9e8ca975ed2e9b9d. Binding and stale-tool authority are covered by the separate real attempt/router regression.
  • Focused check log: 194 tests pass, extension test types and targeted lint/format pass, Madge reports zero cycles. Final autoreview is scoped-clean with no actionable P0–P2 findings.
  • Supplemental artifact manifest: all 19 published files and the manifest were downloaded and checked against local bytes. Signed links expire September 22; originals are retained.

Original paired red/green recordings and manifest remain labeled with their actual base and e583 head. Combined Gateway/Control UI proof uses tree 9e94735e3724d33d801c4cc4c32f3e68251400e1, containing cancellation e5836380. It proves helper timeout on the shared PID, peer survival/final, original request final and follow-up with controlled protocol/provider fixtures. It predates this callback correction, which has the separate exact native/API proof above.

Review follow-up to ClawSweeper’s media-inspection limitation: the raw paired recordings were inspected during capture, and their downloaded hashes verified. The independent source-blind report and the supervisor’s inspection of native milestones and raw API checksums provide separate behavior evidence. No code or security finding was reported. The reviewer’s missing ffprobe and artifact-host access remain documented as reviewer infrastructure limits.

All owned proof processes and leases are stopped; final AWS lease cbx_fa7f13e6435c reports hasHost=false. Computer Use config mutation and compaction remain outside this startup contract. The incident's exact outstanding RPC remains unknown. Required exact-head CI is pending; no merge has been attempted.

@fuller-stack-dev
fuller-stack-dev merged commit 4343400 into main Sep 15, 2026
107 of 109 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the fix/codex-startup-cancellation-containment branch September 15, 2026 23:00
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
…claw#149393)

* fix(codex): keep peer turns alive when thread startup times out

* fix(codex): inject retirement from shared startup owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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