Repository navigation
fix(codex): session handoff stalls when a retired writer stays loaded - #196172
Merged
RomneyDa merged 6 commits intoNov 23, 2026
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Contributor
Author
|
@clawsweeper re-run |
Contributor
|
🦞👀 Re-review progress:
|
Contributor
|
Codex review: stale review; fresh review needed. Summary Next step |
Contributor
Author
|
@clawsweeper re-review |
Contributor
|
🦞👀 Re-review progress:
|
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 23, 2026
…#196172) * fix(codex): bound stalled session handoff from a retired process * fix(codex): explain how to recover from a handoff timeout * test(codex): reuse empty config responses in handoff fixtures * fix(codex): allow slow thread shutdown during handoff * test(codex): enforce model policy at admission in native config fixture --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 1d409a2) Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 24, 2026
…#196172) * fix(codex): bound stalled session handoff from a retired process * fix(codex): explain how to recover from a handoff timeout * test(codex): reuse empty config responses in handoff fixtures * fix(codex): allow slow thread shutdown during handoff * test(codex): enforce model policy at admission in native config fixture --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 1d409a2) Release adaptation: As in 2026.11.8 stable ed39478, preserve the stronger existing mid-preparation policy regression; omit the upstream admission-only rewrite. The handoff implementation and its regressions apply unchanged. Companion audit: #204249 is a separate authority refactor, not applicable. Verified sibling Codex d32063f96c2d, codex-rs/app-server/src/request_processors/thread_processor.rs:1153-1183 and rollout/src/writer_lock.rs:226-238. Co-authored-by: RomneyDa <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 24, 2026
…openclaw#196172) * fix(codex): bound stalled session handoff from a retired process * fix(codex): explain how to recover from a handoff timeout * test(codex): reuse empty config responses in handoff fixtures * fix(codex): allow slow thread shutdown during handoff * test(codex): enforce model policy at admission in native config fixture --------- Co-authored-by: Dallin Romney <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #167280. Follow-up to #173580.
What Problem This Solves
A Codex follow-up can spend its entire startup budget waiting for a retired stdio process that another session still uses. If the target thread's release stays unconfirmed, startup cleanup can then close a healthy replacement client shared by other sessions.
User Impact
The handoff now reports a timeout after the existing ten-second thread-unload confirmation budget (distinct from the five-second unsubscribe-request budget). A failure before a thread write leaves the replacement client available for a later attempt. The timeout tells the user to retry the message shortly or continue in a new chat if the conversation still cannot resume. Resuming on another writer still requires proof that the old process exited or the exact thread unloaded.
Why This Change Was Made
The process-exit wait already respected caller cancellation. This change uses the existing timeout helper and pre-write cancellation callback at that same wait. A shorter whole-startup deadline still controls startup cleanup. The change adds no config, transport, or new source of ownership state. Native Codex acknowledges unsubscribe separately from shutdown and emits
thread/closedafter teardown completes. Native teardown at 0.164.0Evidence
CI fixture repair (
3d134196a0583)The conflict-repaired head failed
checks-node-changed-extensions-bundle-3inthread-lifecycle.native-config.test.ts: its policy-change fixture expected already-admitted work to be revoked. Main's admission change in #202513 snapshots operator policy, including through the public plugin test host. The fixture now supplies the restricted policy at admission and retains both rejection assertions: a visible model-policy error and no native thread/turn dispatch. Missing-issuer coverage remains. Production code and the ten-second handoff/seven-second closure regression are unchanged.Focused static lint, pinned formatter/pre-commit, and diff checks passed. A local baseline test attempt could not reach tests because the shared dependency installation lacks the TypeScript
./fsexport. No passing local runtime or typecheck claim for this repair; fresh fork CI is required. Prior-head CI failed in this one test shard; all other non-aggregate jobs passed or were intentionally skipped.Shutdown budget follow-up (
071f3c870422e)The retired-owner handoff now shares the existing ten-second thread-unload confirmation constant with configuration adoption. This avoids rejecting legitimate slow shutdowns while keeping bounded failure and healthy-client preservation. Unsubscribe RPCs retain their five-second limit; shorter whole-startup deadlines still take precedence.
A new production-startup-boundary regression delivers
thread/closedafter seven simulated seconds while a peer keeps the old process alive. It fails withtimed_outonc3ebf5981fc4and passes with this follow-up, with no resume before closure. Startup and adoption suites: 29 tests passed, 34.52 seconds wrapper wall time (30.75 seconds Vitest). Native seven-second teardown was not independently reproduced; this delayed-closure proof uses the existing synthetic native transport. Earlier native traces below remain evidence for their explicitly named older heads, not the updated ten-second timing. Current-head CI timing is pending.The added test protects successful slow shutdown, which the never-closes timeout controls do not cover. The separate test-line allocation grants exactly 21 net lines for this regression.
Focused lint, extension production typecheck, formatting, and diff checks passed. Local ClawSweeper reviewed
c3ebf5981fc4..071f3c870422eand found no actionable correctness or security defects.Earlier-head evidence
Recorded native stdio trace on
87ddb73527d5(macOS arm64, Codex 0.164.0). The managed launch usedthread_unload_delay_secs=0. In the existing native test fixture, two app-server processes ran on stdio with disposable state and a loopback model. The following is terminal output from the deliberately unconfirmed sibling handoff. The old process answered for the same loaded thread after rejection. The same replacement client issued zero resume requests during the wait and then completed a fresh turn on its already-resumed conversation.The startup regression separately exercises caller cleanup and checks that the healthy client's input stays open. To repeat the native trace, apply the patch below to the test fixture at
87ddb73527d5(the current head instead uses ten seconds). The provider count includes earlier fixture turns.Repeat the historical five-second trace on `87ddb73527d5`
Save the following diff to
trace.diffand run:Hosted CI for
a798639084d5passed. The required CI and security gate also passed on that commit.Red on
6edcaa28edb7, green ona798639084d5. With a 60-second startup budget and a live peer holding the retired process, the new test advances five seconds and then releases the peer. On the base, startup was still waiting and could resume. With the fix, it has already rejected and preserved the healthy client. The existing one-second startup-timeout control passes on both.Real stdio, managed settings, macOS arm64, Codex 0.164.0. Upstream's native test uses two real app-server processes, disposable state,
thread_unload_delay_secs=0, and a loopback model fixture. The ordinary resume succeeded. For the deliberately untracked, still-loaded sibling, the handoff remained pending through an extra 65-second observation on the base. With the fix, the equivalent handoff rejected about five seconds after the sibling's successful turn. This exercises unconfirmed release. An ordinary managed unsubscribe separately completed in 2–12 ms.Six focused suites, 120 tests passed on
c3ebf5981fc4, covering native handoff, startup, adoption, cancellation, and configured-MCP ownership. Focused typecheck, lint, formatting, diff, and test-line checks passed. Both deadline cases retain their explicit cleanup assertions. Sharing the test config responder reduces counted test lines by six versus the base and removes the need for an allocation. The production change remains +17 lines.Repeat the 65-second observation on the base
In a disposable checkout of
6edcaa28edb7817efda38eccc4f0c7fd13ad148c, install withpnpm install --frozen-lockfile. Extend the observation in the existing native test:The
expect(settled).toBe(false)assertion passed after 65 seconds, then the fixture explicitly canceled the wait. On the PR branch, run the committed short regression: