Repository navigation
Remote compaction intermittently fails with stream disconnected before completion #17392
Description
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
Activity
github-actions commentedon Apr 10, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
RossRichardson commentedon Apr 25, 2026
Close, Restart OS and Run. It should fix it - more detail here: #19255 (comment)
JulienJBO commentedon Apr 26, 2026
Sorry, what is the "root" ticket for this ?
Thanks @RossRichardson for the workaround (didn't tried it yet)
eeeepie commentedon May 3, 2026
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.
presidenzo commentedon May 7, 2026
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).
ren1003497048-del commentedon May 17, 2026
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.
Super5280 commentedon May 22, 2026
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:
2026-05-21:
last_api_response_total_tokens=216558
failing_compaction_request_model_visible_bytes=947276
2026-05-17:
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.
Super5280 commentedon May 22, 2026
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.
toxic2040 commentedon May 22, 2026
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:
bogdanbaciu21 commentedon May 28, 2026
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.toxic2040 commentedon May 31, 2026
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.
mcfax-arch commentedon May 31, 2026
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.
carltonawong commentedon Jun 1, 2026
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.xiaocang commentedon Jun 1, 2026
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): xiaocang#1
garyfpga commentedon Jun 3, 2026
when will this bug being fixed? I see 2 other similar issues are closed as duplicate but this annoying bug is never being fixed...
EugeniSegarra commentedon Jun 6, 2026
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:
019e9b96-b829-7562-96bc-802310766d53019e9983-6d9f-7ca2-955f-0333080f5fdcmaybe_resume_success ... latestTurnStatus=interrupted markedStreaming=true; user had to interrupt/start over after the compact failure019e9739-ca62-7512-8fe5-aab13b3d4f11turn_aborted/interruptedstatesTwo 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.
garyfpga commentedon Jun 6, 2026
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
garyfpga commentedon Jun 6, 2026
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
essamgouda97 commentedon Jun 8, 2026
this is so disruptive to our flows ... I hope its fixed asap.
etraut-openai commentedon Jun 29, 2026
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.