Repository navigation
fix(codex): next turn stalls after Stop during session handoff - #173580
Conversation
…ndoff A Codex startup that was waiting for a retired predecessor client to exit retired its own newly acquired client when the caller stopped it, even though that client had not written any thread state. Peers sharing the healthy client were stranded and the next turn had to start a new process. The predecessor-exit wait now reports, during abort dispatch, that it was canceled before this client wrote thread state; startup then releases its lease without retiring the client. The old owner's writer fence is unchanged: the next writer still waits for its physical exit. Startup timeouts, in-flight requests, and the post-start configured-MCP handoff keep retiring the client. Related: openclaw#167280
|
🦞👀 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: needs maintainer review before merge. What this changesPreserves the healthy shared Codex app-server when Stop cancels a predecessor-exit wait before thread writes. Example: Stop interrupts startup while a peer keeps the predecessor app-server alive.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR repairs a current-main cancellation bug and has no actionable findings; the new native-runtime evidence resolves the previous proof blocker. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Codex plugin turns session startup and cancellation into native thread lifecycle operations, managing shared-client leases and predecessor writer fencing. flowchart TD
A[Session turn or Stop] --> B[Attempt startup]
B --> C[Shared client lease]
C --> D[Thread lifecycle]
D --> E[Predecessor physical exit]
E --> F[Native thread resume]
D --> B
Technical reviewBest possible solution: Merge the focused pre-write cancellation repair while retaining deadline retirement and predecessor writer fencing. Do we have a high-confidence way to reproduce the issue? Current-main cleanup exposes the reported retirement path, and the supplied native base-versus-head trace demonstrates its observable consequence; no target code was executed during this review. Is this the best way to solve the issue? The lifecycle owner reports the precise safe cancellation boundary to startup cleanup, avoiding a broad relaxation of retirement or writer-lock safeguards. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5462f7f14643. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +36, Tests +179. Total +215 across 6 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 HistoryReview history (1 earlier review cycle)
Reviewed October 15, 2026, 10:57 PM ET / October 16, 2026, 02:57 UTC (Revision 2). |
|
Maintainer proof for exact head Native runtime proof (pinned Codex 0.161.0 binary, before/after)A temporary native test (not committed) drove the production
PR head: Stop settles with the replacement still healthy; the successor reuses it, and Base Committed regression, negative control
Codex dependency checkInspected Autoreview (gpt-6.1-sol, branch vs origin/main, P1 threshold): scoped-clean, no findings. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…ndoff (#173580) Backport (partial): keeps the production change and the thread-lifecycle regression test; main-only attempt-startup harness tests stay on main. A Codex startup that was waiting for a retired predecessor client to exit retired its own newly acquired client when the caller stopped it, even though that client had not written any thread state. Peers sharing the healthy client were stranded and the next turn had to start a new process. The predecessor-exit wait now reports, during abort dispatch, that it was canceled before this client wrote thread state; startup then releases its lease without retiring the client. The old owner's writer fence is unchanged: the next writer still waits for its physical exit. Startup timeouts, in-flight requests, and the post-start configured-MCP handoff keep retiring the client. Related: #167280 Co-authored-by: LLagoon3 <[email protected]> (cherry picked from commit 0169c8a)
|
Follow-up contribution-gate refresh for exact head
The PR body now records these results. @clawsweeper re-review |
|
ClawSweeper could not start a re-review for this item. |
…ndoff (openclaw#173580) A Codex startup that was waiting for a retired predecessor client to exit retired its own newly acquired client when the caller stopped it, even though that client had not written any thread state. Peers sharing the healthy client were stranded and the next turn had to start a new process. The predecessor-exit wait now reports, during abort dispatch, that it was canceled before this client wrote thread state; startup then releases its lease without retiring the client. The old owner's writer fence is unchanged: the next writer still waits for its physical exit. Startup timeouts, in-flight requests, and the post-start configured-MCP handoff keep retiring the client. Related: openclaw#167280 Co-authored-by: LLagoon3 <[email protected]>
…ssion handoff (#173580)" This reverts commit b2190df. FRV #1 for 2026.10.5 failed every Docker live Codex lane with "thread ... already has an active writer" during session handoff, the path the partial backport changed. #173580 is a P1 fix, not a 10.5 regression; it stays on main and is dropped from this stable.
…ndoff (#173580) A Codex startup that was waiting for a retired predecessor client to exit retired its own newly acquired client when the caller stopped it, even though that client had not written any thread state. Peers sharing the healthy client were stranded and the next turn had to start a new process. The predecessor-exit wait now reports, during abort dispatch, that it was canceled before this client wrote thread state; startup then releases its lease without retiring the client. The old owner's writer fence is unchanged: the next writer still waits for its physical exit. Startup timeouts, in-flight requests, and the post-start configured-MCP handoff keep retiring the client. Related: #167280 Co-authored-by: LLagoon3 <[email protected]> (cherry picked from commit 0169c8a) Release adaptation: 2026.10.10's predecessor-exit wait also races exact thread closure and stops its watcher; the cancellation hook now wraps that existing race.
Related: #167280
What Problem This Solves
Fixes: the next Codex turn can stall for minutes when Stop interrupts startup while it is waiting for a retired predecessor app-server to exit.
User Impact
User impact: a pre-write Stop now releases the interrupted attempt without retiring the healthy app-server needed by peers and the next turn. Startup deadlines, in-flight native requests, and post-
thread/starthandoffs keep the existing conservative retirement behavior. No migration or user action is required.Why This Change Was Made
The predecessor-exit wait now reports the narrow case where cancellation happened before the current client wrote thread state. Startup preserves its healthy client only for that case while leaving the predecessor writer fence in place, so a successor still waits for the old process to physically exit before
thread/resume.Evidence
git diff --checkpassed.pr-simplifyaudit: no redundant implementation or tests were found. The three regression boundaries independently cover pre-write Stop preservation, deadline retirement, and post-thread/startcleanup.pnpm test:extension codexcompleted all 25 chunks. All 12 database-worker chunks passed; all 13 app-server chunks completed with one failure inclient-catalog-preview.test.ts. The same test fails identically on the untouched base commitf1d0c07dfa7, so it is unrelated to this change. The startup/abort regressions passed in both execution variants.rust-v0.161.0source.Native runtime proof
An isolated Docker proof exercised the production
startCodexAttemptThreadpath with the shipped pinned Codex app-server binary, a local scripted provider, and no operator credentials. The binary identified itself as0.161.0with SHA-2569a820c17865fa825d04db416818679a9d63bd72e50835c396f496e5684626c9c.The proof passed as one native test in 11.3 seconds. The predecessor's physical-exit event was sequence 14 and the replacement's native
thread/resumewas sequence 15, demonstrating that Stop preserved the healthy client without weakening the writer fence. The proof harness was temporary and was removed after the run; the committed regression remains the deterministic synthetic-transport test.