Repository navigation
fix(codex): use Responses WebSocket for managed ChatGPT sessions - #3
Merged
Merged
Conversation
The managed token-sharing provider disabled WebSockets, so every sampling request re-uploaded the full conversation, including every image a tool had returned. Image-heavy Codex turns grew to ~100 MB per request and took minutes per step on ordinary uplinks. With supports_websockets=true Codex sends continuations over the Responses WebSocket instead of the whole history, and falls back to HTTP for the session if the WebSocket cannot be used.
nazedeshouu
force-pushed
the
naze/codex-managed-websockets
branch
from
November 17, 2026 04:03
dfee72a to
0236bbc
Compare
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.
Codex threads that use a connected ChatGPT account got slower with every image they opened. A motion review that opened 40 filmstrips took 45–180 minutes, and some reviews failed partway through. Claude reviewers working from the same images finished in about 5 minutes.
The managed provider started Codex with
supports_websockets=false, so Codex sent every request as a fresh HTTP POST carrying the whole conversation. Each image fromview_imageis about 2.5 MB of base64, so 40 images in, every request uploaded about 100 MB. One review re-uploaded 2.6 GB for about 170k tokens of actual input. On a 17.7 Mbps uplink shared with other Codex threads doing the same, uploads ran at about 4–6 Mbps. The OpenAI response stream didn't start until about 3 minutes after a step's request was sent; the model then took about 5 seconds to answer. Large uploads also hitidle timeout waiting for SSEand connection failures, and each retry sent the full body again.With
supports_websockets=true, Codex sends each request over a Responses WebSocket as a continuation, so a step uploads only what is new. In each benchmark run, Codex opened two connections: a warm-up when the session started, and one for the turn about 80 ms later. The managed token works over the WebSocket: Codex gets it from the same auth helper when it connects (status=101, providerOpenAI Token Sharing). A comment above the provider now says why the flag is on, so a later upstream sync doesn't quietly turn it off again.Evidence
The benchmark ran
codex exec0.166.0, the version T3's managed app-server runs, with a freshCODEX_HOMEper run. Each run used T3's provider string, copied from the running app-server, with onlysupports_websocketschanged. The task was 20 filmstrips from a real motion-review pack, opened one per step, on gpt-6.1-sol at low effort. Uploaded bytes come from sampling per-connection counters withnettopevery 0.5 s, so they're close estimates.Tests
CodexManagedRuntime.test.tsassertssupports_websockets=truein the managed launch args. The same test still checks that the provider string parses, the provider ID is unchanged, and the helper renews the token.vp check,knip:checkandgenerate --checkpass.naze/main: both give 8,695 passed, 31 failed, 23 skipped. The 31 failures are the same tests on both sides, and all come from this machine's setup, for example: missing Node runtime APIs, npm-global install detection, macOS/privatesymlink paths, local Claude plugin files, browser recording, and launcher, port and setup-script checks. None of them involve this change.blacksmith-2vcpu-ubuntu-2404runners, which only upstream has, so they stay queued. PR fix(web): themed composer card no longer turns plain when a banner attaches #2 andnaze/file-mentionsare stuck the same way.Agent context budgetcompares against the fork'smainrather thannaze/main, so it fails on every PR intonaze/main. This change doesn't touch agent context.Rollout
503, and the turn still connected over WebSocket.recover_from_unauthorizedpath as HTTP, which calls the auth helper again. Connections are keyed by auth revision, so a renewed token gets a new socket. The server also closes sockets after 60 minutes and Codex reconnects. The case that isn't proven live is a reconnect that first tries an expired cached token.~/.codex/logs_2.sqliteand the app-server's stderr forfalling back to HTTP,provider authentication recovery failed, or errors fromcodex_api::endpoint::responses_websocket. Accounts with their own Codex home write their logs there too, because those homes link to the shared one. The existing401s there come from model discovery and are unrelated.codex. Only 0.166.0 was benchmarked; the HTTP fallback covers older versions.Review
Rounds: 2
Neither reviewer raised a blocker in either round. Round 1 asked for a comment on why the flag is on, and for more precise wording in this description. Round 2 asked for small wording fixes: the connection pattern, the effective upload rate, the failing-test categories, and where shadow homes write logs. Both rounds' changes are in. Both reviewers re-ran the focused tests (78–80 passing) and checked the benchmark and full-suite numbers against the raw reports.