[Bug] Codex OAuth /responses can hang before first event; no bounded timeout in HTTP path
Is it a request payload issue?
[ ] Yes, this is a request payload issue. I am using a client/cURL to send a request payload, but I received an unexpected error. [x] No, it's another issue.
Describe the bug
Codex OAuth /v1/responses requests can hang before the first upstream response event. In the cleanest local case, CLIProxyAPI sent the request to:
https://chatgpt.com/backend-api/codex/responses
and waited until the client manually interrupted the turn. The upstream response never produced a first SSE event:
response.created = 0
response.in_progress = 0
response.output_item.done = 0
response.completed = 0
usage = None
The final proxy-side error appeared only after user interrupt:
Post "https://chatgpt.com/backend-api/codex/responses": context canceled
This looks like a pre-first-event / response-header wait rather than normal slow reasoning. The client UI remains stuck in "thinking/working" until manual interrupt.
The important implementation detail: in v7.1.19, the HTTP Codex executor appears to create the upstream HTTP client with no timeout:
helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0)
So if upstream does not return response headers or the first stream event, the proxy can keep waiting until the downstream client cancels.
Related reports:
- #3530 describes the same Codex OAuth + GPT 5.x hang class.
- #3506 shows long
/v1/responses/compactwaits ending incontext canceled. - Wei-Shaw/sub2api#2738 reports
http2: timeout awaiting response headersforchatgpt.com/backend-api/codex/responses. - earendil-works/pi#4945 reports
openai-codexhanging with zero usage before abort.
CLI Type
codex OAuth / file-backed auth.
Model Name
gpt-5.5
LLM Client
OpenAI Codex Desktop / Codex CLI:
Codex Desktop package: OpenAI.Codex_26.519.5221.0_x64__2p2nqsd0c76g0
Codex CLI: 0.133.0-alpha.1
Request Information
I cannot paste raw request logs publicly because they contain private workspace paths, prompt text, tool schemas, and account data. Sanitized structural fields from the cleanest local case:
CLIProxyAPI image: eceasy/cli-proxy-api:v7.1.19
request-log: true
endpoint: /v1/responses
model: gpt-5.5
reasoning.effort: medium
stream: true
Content-Length: 956521
request timestamp: 2026-05-24T20:16:18.576450162+08:00
response/log-close timestamp: 2026-05-24T20:31:29.660188037+08:00
duration: about 15m11s
final response section status: 200
upstream error after client interrupt: context canceled
SSE event counts: created=0, in_progress=0, output_item.done=0, completed=0
Comparable nearby request from the same thread completed normally:
Content-Length: 945992
duration: about 2s
response.completed = 4
This was not isolated to one auth file. In the same local log window, long /v1/responses requests happened across multiple Codex auth files:
>=60s long responses in main.log: 10
examples: 66s, 101s, 220s, 791s, 618s, 700s, 1433s
affected auth files: multiple codex OAuth auth files, not just auth.json
Current VPS connectivity to chatgpt.com was healthy when tested after the incident:
https://chatgpt.com/backend-api/wham/usage -> HTTP 401 in ~0.13s
https://chatgpt.com/cdn-cgi/trace -> HTTP 200 in ~0.05s
So this does not look like a constant TLS/network outage. It appears intermittent and tied to waiting for upstream response headers / first stream event.
Expected behavior
CLIProxyAPI should not leave Codex OAuth requests waiting indefinitely before the first upstream response.
Suggested behavior:
- Add a configurable response-header / first-event timeout for Codex OAuth
/responsesand/responses/compact. - If no headers or first stream event arrive within the timeout, return a clear error to the client instead of waiting forever.
- Optionally retry or fail over to another available Codex auth file when the timeout happens before the first event.
- Log timing fields separately:
- time to TCP/TLS connect
- time to response headers
- time to first SSE/WebSocket event
- selected auth file
- request size
- model/reasoning
- HTTP vs WebSocket path
This would turn the current "Codex stuck forever in thinking/working" behavior into a bounded, diagnosable failure.
Screenshots
N/A. Raw request logs are available locally but not suitable for public upload because they contain private context.
OS Type
Client:
Windows 10 Enterprise LTSC 2021
Codex Desktop 26.519.5221.0
Server:
Linux VPS
Docker container: eceasy/cli-proxy-api:v7.1.19
CLIProxyAPI request-log enabled
Additional context
One initially suspected factor was prompt-cache continuity because the affected Codex requests include a stable prompt_cache_key and very large context. However, after checking v7.1.19 source, prompt_cache_retention appears to be deleted in the Codex executor path, so I do not think prompt_cache_retention alone is a proven root cause.
The more actionable issue is the missing bounded timeout / retry behavior when upstream does not produce response headers or a first event.
You can try restarting the cpa service when codex gets stuck thinking
+1
You can try restarting the cpa service when codex gets stuck thinking
this does work, but i don't want to do it everytime
+1
Probably an OpenAI timeout problem. Running npx ai-doctor might point out missing timeout guards and unprotected requests.
I am also seeing this across OpenAI models on responses. Sometimes it is as often as 1 out of 3 requests have this problem and I am constantly restarting the proxy to get around the problem.
If the forked patch fixes the problem, it would be great for it to be merged into mainline.
We mitigated this locally without restarting the proxy by forcing the Codex path to use WebSocket end-to-end.
What changed in our setup:
-
Codex client/provider config:
- enabled
responses_websockets_v2 - set the
CLIProxyAPImodel provider to support WebSockets
- enabled
-
CLIProxyAPI auth files:
- added top-level
"websockets": trueto every activetype = codexOAuth auth file under the CPA auth directory - important: this must be applied to all active Codex auth files in the selection pool, not just one account
- added top-level
-
Verification:
- after the change, CPA logs showed the WebSocket executor path:
responses websocket: client connectedExecuting Codex Websockets stream requestcodex websockets: upstream connectedurl=wss://chatgpt.com/backend-api/codex/responses
- after the change, CPA logs showed the WebSocket executor path:
This stopped the old HTTP/SSE pre-first-event hang in our local setup.
However, I would separate this from a complete upstream fix. After switching to WebSocket, we still need to distinguish new WebSocket-path failures such as upstream close 1006 or i/o timeout from the old HTTP/SSE “no first event forever” symptom.
One operational gotcha: do not leave a mixed active Codex pool where some OAuth auth files have "websockets": true and others do not. If CPA falls back to an auth/provider that is not WebSocket-enabled, it can return to the HTTP path. This also seems related to #3556.
So the workaround that helped us was:
{
"type": "codex",
"disabled": false,
"websockets": true
}