Client or integration
Codex App
Area
Streaming
Summary
After upgrading from OpenCodex v2.28.0 to v2.31.0, one existing long-running Codex App task consistently fails through the canonical ChatGPT Responses route.
The request is approximately 18.2 MB as JSON. On v2.28.0, the same task and essentially the same request size completed successfully over the HTTP/SSE upstream path. On v2.31.0, the request is routed through the upstream Codex WebSocket and fails before any terminal Responses event:
Upstream stream terminated unexpectedly: codex websocket closed before a Responses terminal event
OpenCodex records status 502. I expected either the WebSocket path to complete successfully or OpenCodex to choose HTTP/SSE before opening the WebSocket when the outbound request is too large for the WS path.
Reproduction
- Run OpenCodex v2.31.0 with its bundled Bun 1.4.0.
- Use Codex App with the main ChatGPT account and the canonical ChatGPT Responses endpoint.
- Resume an existing tool-heavy task whose streaming
/responses request body is approximately 18.2 MB.
- Send a short message.
- Codex App retries 5 times. Each upstream attempt closes before a terminal Responses event and OpenCodex returns 502.
Control observation:
- OpenCodex v2.28.0 bundled Bun 1.3.14.
- The same task, model, account, and approximately 18.2 MB request completed with HTTP 200 over HTTP/SSE.
- The successful request was approximately 18,200,828 bytes before compression and 11,513,677 bytes after zstd.
- After v2.31.0 starts with Bun 1.4.0, requests of approximately 18,197,133 bytes consistently fail on the upstream WebSocket path.
- Other shorter conversations using the same account and model still succeed on v2.31.0, so the failure appears request-size/task-state specific rather than a general account, model, or network outage.
- Setting
websockets: false only disables the inbound Desktop-to-OpenCodex WebSocket and does not disable this upstream OpenCodex-to-ChatGPT WebSocket path.
The runtime gate appears relevant:
- v2.28.0 package dependency: Bun 1.3.14
- v2.31.0 package dependency: Bun 1.4.0
MIN_BOUNDED_CODEX_WS_BUN_VERSION = "1.4.0"
shouldUseCodexWsUpstream(...) therefore becomes active after the upgrade.
- The upstream implementation sends the complete JSON request as one
response.create WebSocket message.
- I did not find an outbound body-size gate before selecting WS.
A safe mitigation may be a pre-send size-based fallback to HTTP/SSE, or an explicit upstream transport setting. Retrying over HTTP only after an opened WS closes may risk duplicate generation, so a decision before opening WS seems safer.
Version
2.31.0
Operating system
macOS 26.5.2 (Build 25F84), Apple Silicon
Provider and model
OpenAI ChatGPT account / gpt-5.6-luna / Responses
Logs or error output
OpenCodex: 2.31.0
Bundled Bun: 1.4.0
Codex CLI embedded in App: 0.149.0-alpha.4.1
Codex App:
stream disconnected before completion:
Upstream stream terminated unexpectedly:
codex websocket closed before a Responses terminal event
OpenCodex:
status: 502
first output: none
close reason: upstream WebSocket closed before a Responses terminal event
repeated attempts: approximately 3.8-5.3 seconds each
Screenshots and supporting files
No payload or screenshots attached because the request contains private task history. The sizes, version comparison, and redacted error above are reproducible from local logs.
Relevant release/runtime evidence:
Redacted configuration
{
"port": 10100,
"defaultProvider": "openai",
"websockets": false,
"providers": {
"openai": {
"adapter": "openai-responses",
"baseURL": "https://chatgpt.com/backend-api/codex"
}
}
}
Checks
Client or integration
Codex App
Area
Streaming
Summary
After upgrading from OpenCodex v2.28.0 to v2.31.0, one existing long-running Codex App task consistently fails through the canonical ChatGPT Responses route.
The request is approximately 18.2 MB as JSON. On v2.28.0, the same task and essentially the same request size completed successfully over the HTTP/SSE upstream path. On v2.31.0, the request is routed through the upstream Codex WebSocket and fails before any terminal Responses event:
Upstream stream terminated unexpectedly: codex websocket closed before a Responses terminal eventOpenCodex records status 502. I expected either the WebSocket path to complete successfully or OpenCodex to choose HTTP/SSE before opening the WebSocket when the outbound request is too large for the WS path.
Reproduction
/responsesrequest body is approximately 18.2 MB.Control observation:
websockets: falseonly disables the inbound Desktop-to-OpenCodex WebSocket and does not disable this upstream OpenCodex-to-ChatGPT WebSocket path.The runtime gate appears relevant:
MIN_BOUNDED_CODEX_WS_BUN_VERSION = "1.4.0"shouldUseCodexWsUpstream(...)therefore becomes active after the upgrade.response.createWebSocket message.A safe mitigation may be a pre-send size-based fallback to HTTP/SSE, or an explicit upstream transport setting. Retrying over HTTP only after an opened WS closes may risk duplicate generation, so a decision before opening WS seems safer.
Version
2.31.0
Operating system
macOS 26.5.2 (Build 25F84), Apple Silicon
Provider and model
OpenAI ChatGPT account / gpt-5.6-luna / Responses
Logs or error output
OpenCodex: 2.31.0 Bundled Bun: 1.4.0 Codex CLI embedded in App: 0.149.0-alpha.4.1 Codex App: stream disconnected before completion: Upstream stream terminated unexpectedly: codex websocket closed before a Responses terminal event OpenCodex: status: 502 first output: none close reason: upstream WebSocket closed before a Responses terminal event repeated attempts: approximately 3.8-5.3 seconds eachScreenshots and supporting files
No payload or screenshots attached because the request contains private task history. The sizes, version comparison, and redacted error above are reproducible from local logs.
Relevant release/runtime evidence:
Redacted configuration
{ "port": 10100, "defaultProvider": "openai", "websockets": false, "providers": { "openai": { "adapter": "openai-responses", "baseURL": "https://chatgpt.com/backend-api/codex" } } }Checks