Codex Desktop: /responses/compact can hang for 30-60 minutes or return 504 while normal responses_websocket works
What happened?
Codex Desktop can get stuck for a very long time at the automatic context compaction step (正在自动压缩上下文 / 正在思考). This is not the normal model response path: regular sampling is using responses_websocket and continues to work, but automatic compaction appears to use a separate HTTP endpoint:
POST /responses/compact
In one affected Codex Desktop thread, local rollout evidence shows a long blank interval around the compaction step:
2026-05-26T15:39:50.608Z last normal tool output before compact
2026-05-26T16:40:31.346Z type=compacted
2026-05-26T16:40:31.394Z type=context_compacted
That is about 60 minutes 40 seconds with no rollout progress before context_compacted was finally recorded.
Earlier in the same investigation, a /responses/compact request also returned a 504 after a very long backend wait:
HTTP 504 Gateway Timeout
endpoint: /responses/compact
duration_ms: 1776225 # about 29m 36s
cf-ray: a01de0246acef244-KHH
client log: "shouldn't retry!"
The UI remains stuck in a thinking/compacting state during this period, and the user cannot tell whether it is uploading, waiting on the backend, retrying, or dead.
Why this looks specific to compact, not local network or ordinary response streaming
Local checks on the same Windows machine showed:
- Normal Codex sampling path is using
responses_websocket. chatgpt.com:443is reachable.- WinHTTP proxy is direct access.
- No
HTTP_PROXY/HTTPS_PROXYstyle environment variables were set for Codex. - Cloudflare WARP was disconnected and its include routes did not cover
chatgpt.com. - An unauthenticated small POST to
https://chatgpt.com/backend-api/codex/responses/compactreturned401quickly. - An unauthenticated approximately 1 MB POST to the same endpoint also returned
401in a few seconds.
So this does not look like a general local network outage or upload throughput problem. It looks like the authenticated /responses/compact request can spend a very long time in the HTTP/backend path, while ordinary websocket responses are fine.
Thread size after compaction was not huge
After compaction completed, the same thread was well below the model context limit:
last_total ~= 109,177 tokens
model_context_window = 258,400
The local compacted rollout record itself was only about 83 KB. The problem is the time spent generating/returning the compacted result, not that the compacted result is enormous.
Environment
OS: Windows
Codex Desktop package: OpenAI.Codex_26.519.5221.0_x64__2p2nqsd0c76g0
Codex runtime / CLI: 0.133.0-alpha.1
Model: gpt-5.5
Reasoning effort: xhigh
Auth mode: ChatGPT
Normal response transport observed: responses_websocket
Problem endpoint observed: HTTP POST /responses/compact
Expected behavior
Automatic context compaction should not leave the UI stuck for tens of minutes with no actionable state.
At minimum, Codex should:
- expose clear progress/state for
/responses/compact, - have a bounded timeout with a recoverable error,
- avoid a no-progress spinner after a 504,
- allow the user to retry or continue from the last usable compacted/local state,
- preferably use the same reliable websocket transport/path as ordinary responses, or otherwise make the compact HTTP path resilient.
Actual behavior
Intermittently, automatic context compaction blocks the thread for 30-60 minutes or returns 504. Reconnecting/restarting can sometimes make progress again, but the issue recurs. This makes long-running Codex Desktop threads unreliable even when normal network access and ordinary websocket response streaming are working.
Showing cached comments. Read the full discussion on GitHub ↗
5 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Additional clarification after reviewing the automatically linked related issues (#24544, #24538, #24432, #24372): this report overlaps with the general compaction failures, but the distinguishing signal here is the transport/path split.
Local evidence from the affected Windows Desktop session:
transport="responses_websocket"withapi.path="responses"and continue to work.POST https://chatgpt.com/backend-api/codex/responses/compact.duration_ms=1776225(~29m36s), with client log textshouldn't retry!.context_compactedwas finally persisted.last_total=109177withmodel_context_window=258400; the persisted compacted record itself was only ~83 KB.chatgpt.com:443was reachable, and unauthenticated POSTs to the same/responses/compactendpoint returned fast 401 responses, including with an approximately 1 MB body.So from the local evidence this is not just "large thread reaches context limit" and not a general local network outage. It looks more like
/responses/compactHTTP-path reliability/timeout handling diverges from the normalresponses_websocketpath. The user-visible failure mode is that Codex Desktop stays in "正在自动压缩上下文" / thinking for tens of minutes, with no cancellable or recoverable UI state.Expected fixes would be along the lines of: bounded timeout, clear recoverable error, cancellation, retry/failover behavior, and/or making automatic compaction use the same reliable transport path as normal turns when possible.
I posted a related workaround report here: (https://github.com/openai/codex/issues/22309#issuecomment-4560402459). In short, pinning the local VS Code extension to
26.506.31004and Codex Desktop to26.506.3741.0made my long-running remote sessions usable again, while keeping the remote CLI at0.134.0.Additional reproduction on Codex Desktop 26.602.40724
I am seeing what appears to be the same long-session compaction/recovery failure family on a newer Codex Desktop build.
Environment
26.602.407243593codex-cli 0.137.0-alpha.4gpt-5.526.4.1, Darwin25.4.0, arm64019e96d3-e6ef-7123-bb9f-05b024bef389Local rollout evidence
Rollout file:
~/.codex/sessions/2026/06/05/rollout-2026-06-05T16-08-50-019e96d3-e6ef-7123-bb9f-05b024bef389.jsonlTimeline from the rollout:
2026-06-06T01:32:54.686Z: token count showedlast_token_usage.input_tokens = 219085,model_context_window = 258400.2026-06-06T01:33:44.104Z: token count showedlast_token_usage.input_tokens = 239755,model_context_window = 258400.2026-06-06T01:35:25.519Z: token count showedlast_token_usage.input_tokens = 244602,model_context_window = 258400.2026-06-06T01:40:31.158Z:task_completeemitted withlast_agent_message: null.2026-06-06T01:40:31.656Z: a new automatic task started for the same active goal.2026-06-06T02:12:32.112Z: I manually interrupted the follow-up turn after it had been stuck/running for about 31 minutes.The original active goal was not completed. The thread recovered neither with a visible assistant message nor with an actionable compaction error.
Related local prior evidence
This same machine saw a similar failure one day earlier in two other threads:
019e9650-7eaa-7c62-af5d-9544344a721c: null completion at2026-06-05T05:55:11.240Z; last high token samplelast_token_usage.input_tokens = 91847.019e965c-c94c-70c2-8b17-6a38c23921aa: null completion at2026-06-05T06:05:58.938Z; last high token samplelast_token_usage.input_tokens = 74723.The local handoff for those failures explicitly called out the symptom family:
responses/compact,last_agent_message:null, and repeated empty completion.Additional observation
~/.codex/process_manager/chat_processes.jsonstill contained 8 records for the affected conversation after the failure, all pointing at pytest commands from the same session. The recorded OS PIDs were no longer alive when checked withps, so there may also be stale process-manager cleanup state after this failure/abort path.Expected behavior
When a long thread approaches compaction/recovery conditions, Codex should either:
Please investigate why
task_completecan be emitted withlast_agent_message: nullnear the context limit and whether automatic goal continuation is waiting on/retrying remote compaction without surfacing a failure.Thanks for reporting this problem. Until recently, Codex used a separate endpoint and server-side logic for compaction. We recently switched to a more robust approach where the compaction logic is moved locally using the same endpoint as normal turns. This eliminates "remote compaction" errors and increases the stability and reliability of compaction operations. If you see further problems with compaction, please use
/feedbackand open a new bug report.