Codex gets stuck after "Error running remote compact task: stream disconnected before completion"
What version of Codex CLI is running?
v0.130.0
What subscription do you have?
Codex frequently gets stuck during normal use. The terminal shows: Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact) After this happens, Codex stops responding. Sending more messages does not work, and I have to terminate the session and start a new one.
Which model were you using?
gpt-5.5
What platform is your computer?
windowsx86
What terminal emulator and version are you using (if applicable)?
_No response_
What issue are you seeing?
Description
Codex frequently gets stuck during normal use. The terminal shows:
Error running remote compact task: stream disconnected before completion: error sending request for url
(https://chatgpt.com/backend-api/codex/responses/compact)
After this happens, Codex stops responding. Sending more messages does not work, and I have to terminate the session and start a new one.
Environment
- OS: Windows 10 / Windows 11
- Shell: PowerShell
- Codex version: [paste output of
codex --version] - Installation method: npm / other
- Project type: Node.js / Electron / Egg.js backend
- Project path example: D:\cashier\backend or D:\cashier\desktop
Steps to reproduce
- Open Codex in a project directory.
- Ask Codex to inspect or modify project files.
- After running for a while, Codex tries to compact the conversation/context.
- It fails with the error above.
- Codex becomes stuck and no longer responds.
Expected behavior
Codex should recover from the failed compact request or retry automatically.
Actual behavior
Codex becomes stuck and requires restarting the session.
Logs
[paste full terminal log here]
Additional context
This happens repeatedly, especially in larger Node/Electron projects. I have already tried restarting the session and reducing the scope of prompts.
What steps can reproduce the bug?
- Open Codex in a project directory.
- Ask Codex to inspect or modify project files.
- After running for a while, Codex tries to compact the conversation/context.
- It fails with the error above.
- Codex becomes stuck and no longer responds.
What is the expected behavior?
_No response_
Additional information
_No response_
4 Comments
I am seeing what looks like the same class of failure on a remote Codex CLI session.
Environment:
The session is started from a large project on the remote host:
In a long-running remote session, automatic remote compaction failed with this log line:
After upgrading the remote CLI from 0.130.0 to 0.133.0, I also had to restart stale remote codex app-server / codex app-server proxy processes. Before restarting them, the TUI connected to the old app server and failed with:
Restarting the stale app-server fixed that startup/protocol error, but the remote auto-compaction timeout above still appears to be a separate long-session reliability issue.
Current workaround:
Workaround report: compact hang improved after pinning Desktop/VS Code extension versions
I am reporting a workaround that made my long-running remote Codex sessions usable again. I do not think this proves the root cause is fully fixed, but it may help narrow the regression window.
Symptom
In long-running Codex sessions, especially with
gpt-5.5, automatic context compaction could hang or fail around the/responses/compactstep. The session would stop making progress during "Automatically compacting context" / "thinking", or eventually fail with an error such as:or:
Normal responses and websocket traffic could still work, while the compaction path remained unreliable.
Environment
codex-cli 0.134.0gpt-5.5 prox5Workaround that is currently stable for me
I downgraded/pinned the local client components to:
openai.chatgpt-26.506.31004-win32-x64OpenAI.Codex_26.506.3741.0_x64__2p2nqsd0c76g0.Msixcodex-cli 0.134.0Current result
After pinning the local Desktop/VS Code extension versions above, my remote Codex workflow is usable again.
This looks like a workaround, not a confirmed fix. Based on other related reports, I suspect the failure may involve a combination of:
/responses/compactbeing a separate and more fragile path than normal response websocket trafficgpt-5.5remote compaction behaviorRelated issues I found
#22309: remote compact task stuck/disconnected#24618:/responses/compactcan hang 30-60 minutes or return 504 while normal websocket responses work#23951: retry remote compaction v2 requests, included in0.134.0#21911: VS Code extension26.506.31421feature negotiation mismatch with Rust app-server#22091: Desktop26.506.31421rapidly bloats context from retained tool outputs and can freeze old sessions#19400:gpt-5.5remote compaction may be brittle when the compact endpoint does not support the same model path as normal responsesRequest
Could maintainers confirm whether there was a Desktop/VS Code extension regression after the
26.506.xbuilds, or whether/responses/compacthas different timeout/model handling from the normal response websocket path?It would also help if Codex exposed:
Adding a current high-signal data point from macOS where this is reproducible enough that I had to install a local guard.
Environment
codex-cli 0.137.0model = "gpt-5.5",model_reasoning_effort = "xhigh"258400195306 / 258400input tokens, ratio0.7558https://chatgpt.com/backend-api/codex/responses/compactchatgpt.comviautun5, MTU1380; Surfshark WireGuard process active. Public IP and home path are intentionally redacted.scutil --proxyonly reported passive FTP, so this appears route-level VPN/tunnel behavior rather than an HTTP proxy.What happens
When Codex reaches remote compaction, the remote compact stream can fail with:
The important operational problem is not only that the stream disconnects. It is that the session can be left non-recoverable/inert from the user’s perspective unless the user already has an out-of-band handoff. For long coding sessions, this is effectively context loss.
Useful comparison/control
On the same Mac mini and same VPN/tunnel route, Claude Code Sonnet 4.6 can compact successfully near very high context usage. That does not prove Codex should share Claude's implementation, but it does suggest this machine/network path is not generally incapable of long coding-agent compaction. Codex's
/backend-api/codex/responses/compactrequest/stream/recovery path appears more fragile.Local mitigation I had to add
I added a local PreCompact guard that:
{"continue": false}before the hard danger zone so Codex does not attempt the fragile huge compact stream.Current local mitigation thresholds:
This makes Codex more survivable locally, but it is a workaround. The upstream behavior should be better.
Upstream ask
Please make remote compact resilient and recoverable:
/backend-api/codex/responses/compactstream disconnects, retry/resume the compact operation instead of wedging the thread.Expected behavior: failed remote compact should degrade into retry/fallback/recovery, not force the user to terminate and manually reconstruct context.
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.