Remote compaction intermittently fails with stream disconnected before completion
What version of the Codex App are you using (From “About Codex” dialog)?
26.406.31014
What subscription do you have?
Pro
What platform is your computer?
_No response_
What issue are you seeing?
Summary
Codex for macOS intermittently fails when attempting remote compaction of a long thread. The visible error is:
Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
This appears to happen during thread compaction near the context limit, not during ordinary local tool execution.
Environment
- Codex app:
26.406.31014 - Bundled Codex CLI:
0.119.0-alpha.11 - Auth mode:
ChatGPT - Model observed:
gpt-5.4 - Platform: macOS
- Observed: April 9-10, 2026
Frequency
Observed at least 7 times in local logs during the above window.
Expected behavior
When a thread needs compaction, Codex should either:
- complete compaction successfully, or
- fail gracefully with a retry/recovery path that preserves usability
Actual behavior
Compaction fails with:
stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
This interrupts the thread and forces the user to start over or move to a new thread.
Reproduction pattern
Not fully deterministic, but correlated with:
- long-running threads
- large accumulated tool output and/or long conversation history
- automatic remote compaction near the context window
This does not appear to be caused by local repo code, shell commands, or a project-specific setup issue.
Sanitized evidence
Example sanitized log lines:
remote compaction failed ... last_api_response_total_tokens=230780 ... all_history_items_model_visible_bytes=893315 ... model_context_window_tokens=258400 ... failing_compaction_request_model_visible_bytes=908574 ... compact_error=stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
remote compaction failed ... last_api_response_total_tokens=234880 ... all_history_items_model_visible_bytes=958429 ... model_context_window_tokens=258400 ... failing_compaction_request_model_visible_bytes=973688 ... compact_error=stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
Notes
- I observed at least one successful compact-related flow in a separate thread, so this looks intermittent rather than a permanent configuration issue.
- The failure seems specific to the remote compaction request path.
- All account IDs, thread IDs, session IDs, absolute paths, repository URLs, and raw transcripts have been removed.
What steps can reproduce the bug?
Uploaded thread: 019d79a8-88cf-7b32-a79d-97e9d303ea2d
What is the expected behavior?
_No response_
Additional information
_No response_
20 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Close, Restart OS and Run. It should fix it - more detail here: https://github.com/openai/codex/issues/19255#issuecomment-4310146804
Sorry, what is the "root" ticket for this ?
Thanks @RossRichardson for the workaround (didn't tried it yet)
I am seeing the same remote compaction failure repeatedly on a newer CLI version.
Environment:
codex-cli 0.125.0@openai/codexgpt-5.4-mini,gpt-5.4,gpt-5.2,gpt-5.5Observed error:
Full visible sequence:
Impact:
Expected behavior:
/compactshould complete, orThis has happened more than once, not a one-off transient failure.
Also seeing this on Codex Desktop for macOS.
Thread ID:
019e0390-d329-74c3-b8ab-13a32d339c9bCodex App:
26.429.61741 (2429)Error:
This is still happening today (2026-05-07).
Adding a consolidated signal update here because this issue appears to be the primary tracker for remote compaction failures with
stream disconnected before completion.A recent refresh found several adjacent reports with the same broader failure mechanism: long-running sessions approach the context window, remote compaction starts or is attempted, and the session either fails to compact, hangs, becomes unusable, or loses reliable continuity. Examples I found while de-duplicating include #22309, #22107, #19660, #19558, #19441, #19400, #19386, #18829, #18363, #17802, #14684, #11954, #10986, #9800, and #9198. #18838 also appears to have already been closed as a duplicate of this issue.
The pattern looks broader than a single transient network disconnect. Sanitized local evidence and community reports suggest several useful failure classes:
Expected upstream behavior, in my view, is not necessarily that every compact always succeeds. The more important recovery invariant is that a failed remote compact should not leave the active thread unrecoverable or stuck in a repeated failure loop.
Concrete improvements that would make reports and recovery much more actionable:
This comment intentionally avoids raw logs, local absolute paths, account IDs, thread IDs, session IDs, and full transcripts.
I am seeing the same issue in the Codex VS Code extension.
Error:
Error running remote compact task: stream disconnected before completion:
error sending request for url
(https://chatgpt.com/backend-api/codex/responses/compact)
It happens for both:
This has been recurring for me for more than 20 days.
Observed local log dates:
Relevant local logs show:
target=codex_core::compact_remote
Examples:
last_api_response_total_tokens=216558
failing_compaction_request_model_visible_bytes=947276
last_api_response_total_tokens=221908
failing_compaction_request_model_visible_bytes=995111
Environment:
openai.chatgpt-26.513.21555-linux-x64
codex-cli 0.130.0
I also tried increasing:
stream_idle_timeout_ms = 900000
That setting was applied on 2026-05-08, but compaction failures continued afterward.
I updated Codex CLI and reproduced the issue again manually in Codex TUI.
Latest reproduction:
stream disconnected before completion:
error sending request for url
(https://chatgpt.com/backend-api/codex/responses/compact)
Relevant log details:
The compact task itself ran for about 168 seconds before failing.
Adding another current reproduction from Codex CLI with the same failure signature.
Environment:
0.133.0@openai/codexgpt-5.5with high reasoningcodex doctor: install/auth/state/websocket healthy, 13 ok, 0 failObserved behavior:
Repeated local log examples:
Notes:
Expected recovery behavior:
Adding another current macOS datapoint with local logs, since this is now happening constantly on long Codex Desktop threads across multiple repos/dev environments.
Environment:
Observed pattern:
Request timing from trace-safe log lines:
/responses/compactfailures are after multiple attempts; examples show attempt=4 with duration_ms around 62,936 ms and 74,191 ms.I have not attached full logs because they include private prompt/thread content, but the sanitized numeric telemetry above is directly from
~/.codex/logs_2.sqlite. This looks like the same remote compact stream disconnect issue, currently reproducible on the latest installed macOS app line here.Adding a current Linux CLI datapoint after updating to Codex CLI
0.135.0.Environment:
0.135.0via npmgpt-5.5, xhigh reasoningcodex doctor: healthy; websocket check passes; no proxy env varscodex features list:remote_compaction_v2isunder development falseObserved behavior:
/responses/compact.0through4.error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)Final failure telemetry:
last_api_response_total_tokens=237419all_history_items_model_visible_bytes=801190failing_compaction_request_model_visible_bytes=822537model_context_window_tokens=Some(258400)estimated_tokens_of_items_added_since_last_successful_api_response=60Why this may be useful:
remote_compaction_v2=false, the v2 retry/fallback fixes may not cover this default path.This comment intentionally omits account IDs, email addresses, local paths, thread IDs, raw logs, and transcript content.
Codex Desktop remote compaction failures on Windows
Summary
Codex Desktop repeatedly fails when automatic remote context compaction is triggered for long-running threads.
Visible error:
This interrupts active work and can make long-running threads unusable.
Environment
26.527.3686.00.135.0-alpha.1openaigpt-5.5remote_compaction_v2:under development falseReproduction pattern
/backend-api/codex/responses/compactfails withstream disconnected before completion.Sanitized local evidence
The local Codex SQLite logs contain four
codex_core::compact_remotefailures on May 31, 2026:Local checks
Fresh bundled
codex doctor --summaryresult:Connectivity checks:
The endpoint is reachable from this machine. Ordinary turns and tool execution continue to work; the failures are specific to the remote compaction path near the context limit.
Related reports
Expected behavior
Remote compaction should complete reliably. If it fails, Codex should preserve thread usability and provide an automatic fallback or a clear recovery path instead of repeatedly breaking the active thread.
Privacy note
This report intentionally omits account identifiers, thread IDs, session IDs, local filesystem paths, repository details, raw logs, and transcript content.
I have a small behavior-preserving patch prepared for the failure-receipt side of this cluster. It does not attempt to fix the underlying
/responses/compactstream disconnect, but it makes the user-visible/task error receipt clearer when remote compaction fails before replacement history is installed.Branch:
https://github.com/carltonawong/codex/tree/carlton/remote-compaction-failure-receipt
Relevant scope:
codex-rs/core/src/compact_remote.rscodex-rs/core/src/compact_remote_v2.rscodex-rs/core/tests/suite/compact_remote.rsThe main invariant the patch adds to the error receipt is:
Why I think this is useful for this issue: several reports here mix two separate concerns — the actual remote compact failure, and whether the thread/history was lost or corrupted afterward. This patch keeps those concerns separate in the receipt so users and maintainers can tell that the compact attempt failed without implying that local history replacement happened.
Local validation on the branch:
I tried to open this as a PR, but the compare page reports that
openai/codexcurrently limits opening PRs to collaborators. If maintainers want this split out differently, I can adjust the branch to match the preferred shape.Looked into this. The
/responses/compactcall fails at the transport layer (error sending request for url ...→CodexErr::Stream), andrun_auto_compactthen aborts the turn. Since history is still over the limit, the next turn retries the same failing compaction — so the session stays stuck.Suggestion: when remote compaction fails with a retryable/transport error, fall back to the existing local summarization compaction (
run_inline_auto_compact_task, normal/responsespath) instead of aborting. It self-heals on a full window, so the session keeps going.Reference patch (both v1/v2 paths, with tests): https://github.com/xiaocang/codex/pull/1
when will this bug being fixed? I see 2 other similar issues are closed as duplicate but this annoying bug is never being fixed...
I’m seeing the same failure repeatedly in Codex Desktop, and it is now blocking completion of long-running projects because automatic compaction does not recover.
Environment:
26.602.40724(CFBundleVersion3593)0.137.0-alpha.426.5.1(25F80),arm64, Apple Silicongpt-5.5Codex Desktop,vscodeVisible error shown in the Codex UI in all three affected conversations:
Affected local thread IDs:
Observed pattern from the local session JSONL/logs:
| Thread | Started | Task shape | Local evidence |
|---|---:|---|---|
|
019e9b96-b829-7562-96bc-802310766d53| 2026-06-06T06:20:06Z | Long Penman/FSA workbook rebuild with subagents, web/data gathering, and checkpointing | session reached ~100,453 tracked tokens in ~329s; last assistant progress message was mid-pipeline rewrite; compaction failed in UI before the project could finish ||
019e9983-6d9f-7ca2-955f-0333080f5fdc| 2026-06-05T20:39:47Z | Long IHG Penman/FSA workbook/report export and visual QA | session reached ~578,944 tracked tokens; on resume the desktop log reportsmaybe_resume_success ... latestTurnStatus=interrupted markedStreaming=true; user had to interrupt/start over after the compact failure ||
019e9739-ca62-7512-8fe5-aab13b3d4f11| 2026-06-05T10:00:07Z | TAG/LEG Penman/FSA workflow, then continuation to inspect a Word framework including embedded images | first task completed; continuation later reached ~227,857 tracked tokens, then UI showed the same remote compact error and the JSONL records repeatedturn_aborted/interruptedstates |Two details that may help debugging:
event_msgwith the compact error. The JSONL mostly shows token growth and thenturn_aborted: interruptedor a resumed turn stayinginterrupted/markedStreamingin desktop logs. If the compact task is failing outside the normal event stream, that may make recovery/debugging harder.Expected behavior: automatic compaction should either complete, retry, or fail gracefully while preserving a usable/resumable thread. It should not leave the user forced to restart a multi-hour project in a fresh conversation.
Actual behavior: the thread becomes effectively unusable after the remote compact request disconnects, and the user has to start over or manually reconstruct state from local artifacts/checkpoints.
I forked codex to fix this problem using local compact
https://github.com/garyfpga/codex-compact-fix
if you don't mind the trouble give it a try
on my CLI I no longer have any problem
but still wish they will fix the remote compact or give back 1m context
FYI, one of the problem is actually the timeout of the http request / the websocket request
it usually happens when using VPN
and sometimes the problem is complicated due to cloudflare challenge in the middle....
changing to local compact solve the problem but not a good solution
this is so disruptive to our flows ... I hope its fixed asap.
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.