Repository navigation
Allow idle threads to prewarm and repair WebSocket connections - #47701
Merged
copyberry[bot] merged 1 commit intoSep 24, 2026
Conversation
## Why A previously used WebSocket can close while a thread is idle. Hosts need a way to prepare the connection before the next turn without repeating warmup on a healthy connection. ## What changed - Expose `CodexThread::prewarm()` using the existing startup warmup and next-turn handoff. - Reuse healthy connections and pending warmups, retry failed warmups, and repair closed connections. Treat a finished WebSocket reader task as a closed connection. - Skip scheduling during an active turn or shutdown, and stop warmup admission before shutdown takes the pending task. - Expose `active_turn_environment_selections()` so hosts can inspect the environments captured by the active turn, including those still starting or failed, when authorizing steering. ## Testing Add regression coverage for repeated idle prewarm calls, healthy connection reuse with preserved response continuation, reconnection with `generate: false`, and warmup rejection after shutdown. Update delayed MCP discovery coverage to verify prewarm repairs an eagerly closed socket and the first turn reuses it. GitOrigin-RevId: aa164b91a399de2375eda3bf28397725439fce93
copyberry
Bot
force-pushed
the
copyberry/codex-internal-to-codex-oss/aa164b91a399de2375eda3bf28397725439fce93
branch
from
September 24, 2026 00:38
95c63e0 to
d838c23
Compare
Contributor
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
copyberry
Bot
deleted the
copyberry/codex-internal-to-codex-oss/aa164b91a399de2375eda3bf28397725439fce93
branch
September 24, 2026 00:38
This branch was successfully deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Allow idle threads to prewarm and repair WebSocket connections
Why
A previously used WebSocket can close while a thread is idle. Hosts need a way to prepare the connection before the next turn without repeating warmup on a healthy connection.
What changed
CodexThread::prewarm()using the existing startup warmup and next-turn handoff.active_turn_environment_selections()so hosts can inspect the environments captured by the active turn, including those still starting or failed, when authorizing steering.Testing
Add regression coverage for repeated idle prewarm calls, healthy connection reuse with preserved response continuation, reconnection with
generate: false, and warmup rejection after shutdown. Update delayed MCP discovery coverage to verify prewarm repairs an eagerly closed socket and the first turn reuses it.