Repository navigation
fix(codex): the turn after an interrupt waits for every other active Codex chat - #165487
Conversation
Use the resource owner's cleanup authority for thread unsubscription. An interrupted foreground run no longer rejects its required cleanup before the native request and needlessly retires the app-server shared with other chats. Keep host/session lineage checks and genuine unsafe-subscription retirement. Prove that the next turn resumes the same thread while a sibling stays active. The regression fails with the production change reverted; 196 related tests and the Codex package typecheck pass. Document the parallel-chat behavior.
|
🦞👀 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. Reviewed October 5, 2026, 5:44 AM ET / 09:44 UTC. ClawSweeper reviewWhat this changesThe PR lets interrupted Codex chats release their subscription without retiring the app-server shared with other chats, and adds regression coverage and documentation. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main. The focused repair and supplied live evidence support the intended behavior, and no blocking patch defect was found. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw's Codex plugin sends chat turns to a shared Codex app-server. Attempt cleanup releases thread subscriptions and client leases so subsequent turns can resume without disrupting other chats. flowchart TD
A[Chat interrupted] --> B[Attempt cleanup]
B --> C[Host and session authority]
C --> D[Thread unsubscribe]
D --> E{Cleanup confirmed?}
E -->|Yes| F[Keep shared client and resume chat]
E -->|No| G[Retire unsafe client]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests +73, Docs +3. Total +76 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use the existing resource-owned cleanup authority to preserve concurrent chats while retaining retirement for genuinely unsafe cleanup. Do we have a high-confidence way to reproduce the issue? Yes: interrupt one Codex chat while a sibling holds the shared client, then send a replacement turn. Current-main source and the supplied live trace establish the path; this review did not execute it. Is this the best way to solve the issue? Yes: reusing the existing cleanup authority repairs cancellation handling at its owner without adding another lifecycle mechanism or weakening host/session lineage validation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 500c95aaa373. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…claw#165487) Use the resource owner's cleanup authority for thread unsubscription. An interrupted foreground run no longer rejects its required cleanup before the native request and needlessly retires the app-server shared with other chats. Keep host/session lineage checks and genuine unsafe-subscription retirement. Prove that the next turn resumes the same thread while a sibling stays active. The regression fails with the production change reverted; 196 related tests and the Codex package typecheck pass. Document the parallel-chat behavior.
) Use the resource owner's cleanup authority for thread unsubscription. An interrupted foreground run no longer rejects its required cleanup before the native request and needlessly retires the app-server shared with other chats. Keep host/session lineage checks and genuine unsafe-subscription retirement. Prove that the next turn resumes the same thread while a sibling stays active. The regression fails with the production change reverted; 196 related tests and the Codex package typecheck pass. Document the parallel-chat behavior. (cherry picked from commit 4c34d8e)
What Problem This Solves
Fixes: interrupting one Codex-runtime chat (Stop + send, or
queueMode: "interrupt") makes the follow-up turn wait until every other active Codex chat on the same app-server finishes — 84 s, and once 215 s, in live runs — because cleanup retires the shared app-server process after a perfectly normal interrupt.User Impact
User impact: after an interrupt, the replacement turn starts right away (0.7 s live) even while other Codex chats keep working, and those other chats are no longer pushed onto a retired process. Genuinely failed cleanup still retires the client as before.
Why This Change Was Made
Interrupted turns intentionally leave
settledTurnStatusunset, so attempt cleanup releases their thread subscription. That unsubscribe ran under the attempt's foregroundconnection.withCurrent, whose authority is already cancelled by the interrupt, so the unsubscribe reported "not released" and cleanup treated it as an unsafe subscription: it closed and retired the shared client. The next turn on that thread then waited for the retired process to exit, which cannot happen while sibling chats hold leases. Unsubscribe now runs under the attempt's existing cleanup authority (cleanupAuthority.withCurrent), which keeps the host/session lineage checks and still retires the client when an unsubscribe genuinely fails. Writer barrier and ring-zero/client-bound rules are unchanged.Evidence
Live, dev Gateway (OpenAI provider,
@openai/codex0.160.0 managed app-server): Codex session Y runs a 90 ssleep; Codex session X is interrupted mid-turn.Instrumented main showed the precursor exactly: interrupt confirmed in 13 ms, then
cleanupCodexAttempt → releaseThreadSubscription → closeCodexStartupClientBestEffort → retireSharedCodexAppServerClientIfCurrent; the replacement's resume then waited inprevious.release(true)for the retired process exit. Native 0.160.0 semantics forthread/unsubscribeandthread/closedwere checked against the Codex source.196 related Codex plugin tests pass (interrupt cleanup, client runtime, shared client, compaction). Codex package types, extension lint, formatting, docs checks pass.
Production +1/−1; tests +73; docs +3.