Repository navigation
fix(codex): preserve warm sessions and approvals across conversations - #120405
Merged
Merged
Conversation
steipete
marked this pull request as ready for review
August 8, 2026 01:05
steipete
marked this pull request as draft
August 8, 2026 01:22
steipete
marked this pull request as ready for review
August 8, 2026 01:22
steipete
force-pushed
the
codex/codex-multi-session-lifecycle
branch
from
August 8, 2026 01:28
0cbde66 to
bea3fce
Compare
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 8, 2026
This was referenced Oct 8, 2026
This was referenced Oct 19, 2026
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: #115089
What Problem This Solves
Fixes an issue where people alternating between independent Codex-backed conversations repeatedly cold-restarted native sessions and lost session-scoped file-change approvals. The previous implementation retained only one subscribed native thread per shared Codex app-server, so finishing conversation B evicted conversation A even though the upstream protocol supports many concurrent subscriptions.
Why This Change Was Made
Replace the single retained-thread slot with a physical-client-owned registry that preserves independently owned native sessions while bounding retention to 64 unprotected idle threads and 30 minutes. Protect parents with unfinished native children, transfer ownership safely through compaction and transient restricted turns, and retire only the exact native thread and physical client belonging to a reset, deletion, session end, or terminal upstream notification.
Separate immutable native-thread identity from settings Codex can update through
turn/start, including same-generation model selection, approval policy, sandbox, working directory, and service tier. Preserve model-generation boundaries, synchronize authoritative session/model/workspace metadata, document the lifecycle, and explain the non-obvious ownership and approval invariants beside the code.Follow-up: transfer retained native subscriptions explicitly when a session moves into bound-conversation ownership, and release bound subscriptions on detach.
User Impact
Separate chats keep their own native conversation, warmed resources, workspace, and session-scoped native file-change approvals while sharing the intended authenticated app-server. Switching between chats no longer discards one conversation's runtime just because another finishes, while idle/LRU eviction remains bounded and resetting one conversation does not disturb its siblings. Existing native command approval and durable exec-policy behavior are unchanged; no new production configuration, environment variable, storage schema, or dependency is introduced.
The public Codex harness documentation now explains retention limits, protected native-child parents, reset behavior, and when evicted sessions may need approval again.
Evidence
0.146.1source was inspected directly: one client can subscribe to many threads inthread_state.rs, idle unloading requires zero subscribers inthread_lifecycle.rs, incompatible resumes reconstruct idle unsubscribed sessions inthread_processor.rs, and native file-change approvals remain session-scoped inapply_patch.rs.tbx_01kzf8m1efea13w0n2vjv59dwp: 592 passing tests across 13 focused files, covering alternating pooled sessions, exact-thread reset, incognito teardown, 64-session LRU/30-minute expiration, protected native-child parents, compaction ownership, transient restricted turns, mutable model/approval/workspace/service-tier settings, conversation-only model commands, plugin hooks, and real WebSocket approval capability negotiation. Testbox-backed Actions run.0.146.1->openai/gpt-5.6-solprovider proof: four actual native file changes inA -> B -> A -> Border, two distinct stable native thread IDs, one physical app-server client, and exactly two independentacceptForSessionapproval decisions with observed counts1 -> 2 -> 2 -> 2; live test passed in 199.46 seconds.[codex-session-proof] A=019fdeaf-44a2-77f3-913c-2232b47320c2 B=019fdeaf-55ea-7812-aa8e-492b2c25ae40 client=656d4cf8-5b53-44b8-aeac-14be3431ab1b approvals=2 turns=4..agents/skills/autoreview/scripts/autoreview --mode uncommitted --max-priority P1exited successfully; TruffleHog was clean and no actionable P0/P1 findings remained.pnpm build, all-projectpnpm check:changed, complete TypeScript project graph, production/full-tree dead-export checks, all three lint shards with zero findings, and runtime import-cycle detection with zero cycles.