Repository navigation
Codex Desktop on macOS: automatic context compaction fails every time with “error decoding response body” #38969
Description
Summary
In Codex Desktop on macOS, automatic context compaction consistently fails whenever it is triggered. The task runs normally before compaction, but once the UI enters Context automatically compacting, it reconnects and then reports a remote compact transport/decode failure.
This is not an isolated one-off failure: in my sessions, it happens every time context compaction is triggered, making long-running conversations unreliable and difficult to continue.
Error
Error running remote compact task: stream disconnected before completion: Transport error: network error: error decoding response body
The UI shows:
Context automatically compacting
Reconnecting 2/2
and then the error above.
Environment
- Product: Codex Desktop
- Platform: macOS
- Subscription: ChatGPT Pro
- Model shown in the affected session: GPT-5.6 Sol Ultra
- App version: not visible in the captured screen; diagnostics were submitted from the affected session
Steps to reproduce
- Open or continue a long-running Codex Desktop conversation.
- Let Codex work normally until automatic context compaction is triggered.
- Observe
Context automatically compacting. - The compact operation enters a reconnect cycle (
Reconnecting 2/2). - It fails with:
Error running remote compact task: stream disconnected before completion: Transport error: network error: error decoding response body
- Continue using other sessions until compaction is triggered; the same failure recurs.
Actual behavior
- The remote compact task disconnects before completion.
- The response body cannot be decoded.
- The current task is interrupted during compaction.
- Long-running conversations become unreliable because the failure occurs at the exact point where compaction is required to continue safely.
Expected behavior
- Automatic compaction should complete successfully and preserve enough task state for the agent to continue.
- A transient transport failure should retry robustly or use a safe fallback.
- The thread should not become blocked or unreliable merely because it reached the compaction stage.
Diagnostics
Feedback was submitted from the affected session with diagnostics enabled.
Feedback ID: 01a00ebf-d399-7373-975c-c359138dd909
Related reports
Similar symptoms appear in #31375, #32545, #38434, and #38861. This report adds a current macOS Codex Desktop reproduction using GPT-5.6 Sol Ultra, with a fresh Feedback ID tied to the affected session and the observation that the failure occurs every time automatic compaction is triggered.
Activity
github-actions commentedon Aug 17, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
jdcodes1 commentedon Aug 17, 2026
Read through the remote-compaction failure handling on
main@ 1f41cc5 — the reason this is so damaging is structural: when remote compaction fails, there is no fallback to local compaction, and the only fallback that does exist is unreachable for transport errors.1. The compaction implementation is chosen one-way.
run_auto_compactpicks remote-v2 / remote-v1 / local once, from the provider's capability (core/src/session/turn.rs#L1183-L1236). OpenAI-backed threads always take the remote path; the local implementation (run_inline_auto_compact_task) exists in the same file but is never used as a fallback when the remote path fails.2. The only in-path fallback can't trigger on your error. Inside the remote path there is a model fallback (retry the remote compact with the current model), gated by
should_retry_with_current_model:codex/codex-rs/core/src/compact_model_fallback.rs
Lines 9 to 20 in 1f41cc5
The accepted list is
InvalidRequest / UnexpectedStatus / ContextWindowExceeded / UsageLimitReached / ServerOverloaded / InternalServerError / RetryLimit— transport/stream failures like yours (Transport error: network error: error decoding response body) are not in it. So after the visibleReconnecting 2/2retries,run_remote_compact_task_inner_implreturns the error hard (compact_remote.rs#L181-L189), the turn is interrupted, and the thread is stuck at exactly the point where compaction is mandatory. There's also no user-facing switch to force local compaction (the only related knob is theremote_compaction_v2feature flag, which toggles which remote implementation runs).3. About the error text. "error decoding response body" is the HTTP client's (reqwest's) generic wrapper for a body that ended prematurely or failed content decoding (e.g. truncated chunked/gzip stream) — the status code and headers that would identify the server-side cause are discarded when it's wrapped into
TransportError::Network. That your failure is deterministic per compaction attempt (not flaky) suggests something reproducible about these threads' compact responses — but with the current error surface, neither you nor the maintainers can see what. Capturing status +content-encoding/content-lengthon decode failures would make this class of report diagnosable.Fix outline:
run_inline_auto_compact_taskinstead of failing the turn. Local compaction is strictly better than a dead thread; the machinery is already present and selected today for providers without remote support.response.incompleteis treated as a retryable stream failure, causing unnecessary retries and transport fallback #38831/Long CLI threads exceed Responses WebSocket message limit before auto-compaction (close code 1009) #38846; a deterministic decode failure needs a different action, not the same request again.(1) alone converts this from "long conversations become unusable" into, at worst, "compaction quality falls back to the local summarizer" — and it's the smallest change of the three.
vforsh commentedon Aug 27, 2026
Additional reproduction on 2026-08-27, with the same exact remote-compaction error across three separate development threads.
Verified environment
--versionoutput and the affected sessions' metadata.Observed behavior
All three threads ended in
systemError, with their latest turns markedfailedand the identical error:The workflows were different. Ordinary local tool commands completed before the compaction failure, and earlier turns in these threads had completed successfully. This interrupts ongoing work during conversation-history maintenance rather than reporting a project build or command failure.
Observed sequence: work normally in an existing multi-turn thread, send a follow-up, allow local commands to execute, then receive the remote-compaction error and a failed turn. I do not have a minimal deterministic reproduction or a measured failure rate across all compaction attempts.
Impact and expected behavior
Repeated interruptions leave work and verification incomplete. Since earlier actions may already have taken effect, recovery requires checking existing state before rerunning anything. Compaction should complete reliably or provide a safe recovery path instead of repeatedly aborting the active turn.
I have not established whether the root cause is the desktop runtime, the compaction backend, or network transport, and cannot attribute it to a particular update. I have not verified this on runtime 0.150.1.
Project names, source code, local paths, screenshots, thread IDs, and raw session/log files are intentionally omitted from this public report. No in-app diagnostic upload was performed for this reproduction.
misiektoja commentedon Sep 5, 2026
I'm seeing the same issue. Auto-compaction starts, then Codex shows "Reconnecting..." and the session gets stuck or becomes unusable. Other chats work normally, so it seems specific to that session/compaction flow. I'm using GPT-6 Astra with Extra High reasoning, macOS Desktop client, latest version available.
chenweizhong-web commentedon Sep 7, 2026
I am experiencing the same issue on Codex Desktop for macOS.
The affected existing thread consistently fails with:
Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses)
Important detail: a new Codex conversation in the same project works normally, while the affected existing thread cannot continue. Updating ChatGPT Desktop to the latest available version did not resolve it.
I specifically need to recover and continue the existing thread rather than migrate the project to a new conversation.
I submitted diagnostics from the affected thread.
Feedback ID: 01a071ac-19be-7401-ae4e-326cc4b7a9fb
Please investigate whether this affected thread can be recovered and whether failed remote compaction can retry/fallback without leaving the existing thread unusable.
sharpkorn1993-ui commentedon Sep 7, 2026
Additional verified recurrence on 2026-09-07 in Codex Desktop on macOS: the two most recent consecutive turns of the same existing task both failed during remote compaction.
The stored task state is
systemError; both turns arefailedwith this identical error:Observations from the affected task's turn records
These durations cover the complete turns, not a measured compaction request or network retry.
The earlier failed turn produced task commentary and local tool activity before the compaction error. The next turn failed with the same error and has zero recorded task items. An earlier turn in this task had completed successfully. Continuing the existing task has therefore resulted in repeated failures, leaving the work unable to proceed in that task. A separate task can still read the affected task's status and use tools.
Environment and limits of this report
Impact and requested investigation
Repeated compaction failure interrupts an ongoing task even when prior work has already been performed. Please investigate recovery of affected existing tasks and a reliable retry/recovery path that preserves task state instead of repeatedly failing on continuation. More actionable compaction request/error diagnostics would also help distinguish backend failures from client or network transport problems.
This is a sanitized public recurrence report. Project names, source code, local paths, task/turn IDs, and raw task/log files are omitted. No new in-app diagnostics upload was performed for these two failures.
Yukioa2z commentedon Sep 9, 2026
Additional macOS reproduction on September 8–9, 2026, with correlated terminal turn states and transport retry logs. Posting the evidence here after checking existing reports, rather than opening another issue with the same error.
Environment
chatgpt.com/backend-api/codex/responses.gpt-6-astra,gpt-5.6-sol, andgpt-5.6-luna.Measured impact
The review covers retained local records from 2026-09-08 00:00:00 through 2026-09-09 23:56:54, UTC+08:00, across 27 user-facing tasks and 41 subagent tasks.
There were 11 terminal transport failures with this exact error:
Error running remote compact task:prefixEight of these failures occurred across seven user-facing tasks; three occurred in subagents. A separate model-capacity failure is excluded from these 11.
The same window contains 1,042 retry log records from
codex_core::responses_retry, including internal calls. These are not 1,042 failed tasks: 90 turns with retry records ultimately completed successfully. Interrupted turns were also kept separate from terminal failures.The retry records break down as:
close_notifytls handshake eoferror decoding response bodyCorrelated compaction failure
The repeated sequence is:
TLS/WebSocket failure → retries →
falling back to HTTP→ response-body decode failures → terminal failed turn.Eight of the 11 failed turns have an explicit HTTP fallback entry within that same turn. The other three belong to tasks that had already fallen back in an earlier turn.
One concrete example on 2026-09-09, with all times below in UTC:
There is also a repeat-failure example on September 8: continuing an affected task at 06:23:01 UTC led to another failure at 06:25:46 UTC, with
Failed to run pre-sampling compact. This can prevent the next turn from reaching normal generation.Reproduction and evidence limits
Observed workflow: perform a multi-step coding task, allow automatic compaction, encounter the reconnect/fallback sequence, then attempt to continue the task. The issue recurred across several tasks. This is an observational reproduction, not a deterministic minimal test or a measured failure rate over all compaction attempts.
The records establish the transport/fallback sequence and the failed turns. They do not establish whether the initiating cause is a proxy/VPN, network path, server/edge behavior, response encoding, or client implementation. There has been no controlled comparison using an alternate network route. Ordinary generation also failed, so this is not exclusively a compaction failure.
Expected behavior: preserve completed work and provide a usable retry/resume path after compaction transport failure; retain the initiating transport error and operation stage in diagnostics instead of exposing only the final generic decode error.
Related current reports: #44128 has the exact decode error on September 9, and #43517 describes WebSocket failures followed by HTTP fallback on runtime 0.153.4. #36059 also tracks the broader WebSocket-to-HTTPS failure sequence. These are symptom overlaps, not a claim of an identical root cause.
The evidence above was checked against local turn records and timestamped logs. Raw prompts, source code, local project paths, account details, and full logs are omitted. No diagnostic upload is implied by this comment.
wuxinxing5201314 commentedon Oct 1, 2026
Additional Windows reproduction with an in-app feedback ID:
I am seeing the same visible compaction error on Windows x64 across multiple long conversations. I cannot yet confirm whether the underlying cause is the same as this macOS report.
Environment:
In-app feedback ID:
01a0bf58-efbe-7811-8197-adc1a8e9e884
Observed reproduction:
Error running remote compact task: stream disconnected before completion: Transport error: network error: error decoding response body
This has occurred in at least three different long conversations. Retrying in an affected conversation reproduces the failure.
Control test:
A newly created short conversation successfully answered:
请只回复“测试正常”,不要访问文件,也不要执行工具或命令。
The same prompt failed during compaction in an affected long conversation. This does not rule out a connectivity problem affecting compaction requests.
Relevant local history:
One affected conversation previously required local file recovery and a stored-path change. Its history can now be read and the conversation can be loaded. Other affected conversations did not undergo that recovery procedure but show the same compaction error.
Expected behavior:
Compaction should complete and allow the existing conversation to continue. A recoverable transport failure should not leave the conversation repeatedly blocked at compaction.
The conversations contain unpublished research. I am not attaching complete transcripts, databases, or manuscript files to this public comment. Please advise what minimal, redacted diagnostic information would help investigate this Windows reproduction.
wzxsph commentedon Oct 3, 2026
Additional verified macOS recurrence on 2026-10-03 with codex-cli 0.160.0, including both mid-turn and pre-turn compaction. This adds current-version evidence and correlated retry timings to this existing report.
Environment
Observed workflow and impact
The work cannot reliably continue in the affected turn. Previously written project files remain available, and we were able to recover work from saved project notes in another conversation. This is an observational reproduction; I do not have a deterministic minimal transcript or a measured failure rate across all compaction attempts.
The terminal error is:
Correlated retries
Retries do happen. The retained
codex_core::responses_retryrecords show two automatic retries for each compaction operation (max_retries=2), followed by terminal failure.All times below are UTC on 2026-10-03:
These intervals run from the first compaction request to the enclosing turn ending; they are not measurements of server processing time.
Sanitized log excerpts, with context spans/identifiers omitted and timestamps normalized to second precision:
All six correlated requests logged HTTP 200 response status before the response-body stream failed. Receiving headers did not imply successful compaction. Request compression instrumentation reported approximately 1.84 MB before / 955 KB after compression, with local request compression taking only 3–5 ms. No request body was inspected or included here.
Mitigation and evidence limits
After these failures, we added project-scoped
model_auto_compact_token_limit = 160000andtool_output_token_limit = 6000to reduce accumulated context/output size. A read-only strict-config check confirms those values can load; it does not establish hot reload in an already-running task or prove that the transport failure is fixed. We did not increase the actual context window or override the built-in provider as part of that mitigation.A
model_catalog_jsonconfiguration was present, and its file changed after the two failure intervals. Its current contents therefore should not be treated as the incident-time model/context settings.The same response-body decode error also appears in ordinary generation logs on this host, so the underlying fault is not proven to be exclusive to compaction. We have not isolated client behavior, proxy/network path, or server/edge behavior with a controlled alternate-network test.
Requested recovery improvements
This is a sanitized public diagnostic summary. Project names/code, private prompts, transcripts, local account paths, credentials, and task/turn/request identifiers are omitted. No complete log archive or in-app feedback upload accompanies this comment.
VonC commentedon Oct 3, 2026
I have a related Windows/corporate-network datapoint for this compaction failure.
On codex-cli 0.160.0,
codex doctorshowed the Responses WebSocket failing TLS withUnknownIssuer, while HTTPS remained usable. After switching to a custom provider withsupports_websockets = false, the remote-compaction failure stopped occurring on that machine.I posted the configuration and A/B results in #46489, which is a closer match for the TLS/WebSocket side of the problem.
This does not imply that every
error decoding response bodyreported here has the same cause. It does show one case where forcing the Responses API to HTTPS is an effective workaround.1129678576 commentedon Oct 4, 2026
Additional verified recurrence on 2026-10-04 on macOS. An existing local coding conversation has two consecutive failed turns with the exact error tracked here:
Environment captured from the current installation and affected session metadata:
The latest continuation was a short question about project progress. It failed before normal response generation, during PreTurn auto-compaction with reason ContextLimit. Correlated local records show the following times, all UTC on 2026-10-04:
Failed to run pre-sampling compact; turn failed.The stored whole-turn duration is 387.472 seconds (~6 min 27 sec); this is not a measurement of server processing time. The preceding turn also failed with the same terminal error after having performed local project work. The conversation state is systemError. Another local conversation can read the affected conversation's records and execute tools, but that does not establish that the compaction network path is healthy.
Please investigate a supported recovery path for the existing conversation when compaction retries are exhausted, and make the operation stage/retry/failure details actionable. The work should be able to resume from preserved state rather than remain blocked behind repeated pre-turn compaction.
This is an observational recurrence, not a deterministic minimal reproduction. The root cause has not been isolated to client, backend, or network. This public report omits private prompts, project names/code, local paths, credentials, thread/turn identifiers, and raw logs. No new in-app diagnostic upload is implied.
1129678576 commentedon Oct 5, 2026
Same-history image/no-image experiment on runtime 0.160.0
Following up on my earlier report: a small A/B experiment reproduced the original response-body decode error with historical screenshots retained, while removing only image blocks allowed two compactions to complete without retries. This is a useful mitigation lead, not proof of a general failure rate or a confirmed root cause.
Environment and method (October 6, 2026, UTC+8):
codex-cli 0.160.0.gpt-6.1-sol, high reasoning, built-in OpenAI provider, existing ChatGPT authentication.thread/compact/start; subsequent trials did not compact an already-shortened result.model_auto_compact_token_limitwas 219640, but these trials explicitly triggered manual compaction.Observed results:
contextCompactionitem completion andturn/completedstatuscompleted,error=null. Neither had error/retry notifications or transport fallback. The third trial was stopped shortly after starting.Selected retained A-arm event times (UTC, October 5; October 6 locally):
Interpretation / requested investigation: removing historical images is a promising workaround for this particular history. Two successful controls do not establish long-term stability, and the interrupted A arm cannot yield a terminal failure-rate comparison. Payload size, image handling, current network/edge behavior and their interaction remain possible explanations. The runtime also reports
compaction_image_budgetenabled, so the baseline count should not be treated as a measured server-side image count or request-token budget.Please investigate image-bearing tool outputs in remote compaction, preserve actionable transport/encoding diagnostics, and consider a supported option to omit historical screenshots at compaction time while preserving text and tool-call integrity. Ordinary forks still inherit old images; merely forbidding new screenshots does not clean an existing history.
Raw transcripts, screenshots/Base64, project code, local paths, account details and thread/request identifiers are omitted from this public comment. The experiment was stopped; no additional trials or alternate-network tests are implied.