CLI remote compaction repeatedly fails and leaves resumed threads without task continuity
What version of Codex CLI is running?
codex-cli 0.130.0
What subscription do you have?
Pro
Which model were you using?
Mostly gpt-5.5 with high / xhigh reasoning. Older log history also shows the same remote compact failure shape with gpt-5.4.
What platform is your computer?
macOS 26.3.1 (a), Darwin 25.3.0, arm64, MacBook Air.
What issue are you seeing?
Remote context compaction repeatedly fails in the CLI with:
Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
This has happened continuously across several days and multiple long-lived CLI sessions. The main user-visible problem is not only the error itself: once it happens, the session can become effectively wedged. codex resume <thread_id> may start a responsive-looking session, but it often does not naturally resume the active task state. I have had to manually back up and rewrite local rollout JSONL files with task-state summaries to recover work.
Affected thread IDs observed locally
These are local thread/session IDs from the Codex rollout/log files:
019e0fab-3f43-7c61-b34a-5a37373f5c9b019e132c-0d1f-7700-addc-396fc383089fdfb1b3b9-e2ba-44be-96ed-d79f18a3e355
The local log also shows the same compact failure pattern on older threads:
019d8749-0408-7013-adfa-b0bbe5813e2e019dfd8b-84b7-70a2-b8cc-6602a3b870cc
Frequency / scale from local logs
I counted structured codex_core::compact_remote: remote compaction failed entries in ~/.codex/log/codex-tui.log.
Sanitized counts:
remote compact failures: 50+ genuine failures in the log
by_thread:
019d8749-0408-7013-adfa-b0bbe5813e2e: 10
019dfd8b-84b7-70a2-b8cc-6602a3b870cc: 17
019e0fab-3f43-7c61-b34a-5a37373f5c9b: 15
019e132c-0d1f-7700-addc-396fc383089f: 8
Recent examples, copied from structured log fields and with transcript content omitted:
2026-05-11T21:23:52Z thread=019e132c-0d1f-7700-addc-396fc383089f turn=019e18ce-aa4f-7823-8f4a-6a49db51a810 model=gpt-5.5 effort=xhigh last_api_response_total_tokens=213012 all_history_items_model_visible_bytes=938543 added_tokens_since_success=863 added_bytes_since_success=3450 context_window=258400 failing_compaction_request_model_visible_bytes=950257 error="stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)"
2026-05-12T00:39:33Z thread=019e132c-0d1f-7700-addc-396fc383089f turn=019e1941-69fc-7211-8753-51875647b929 model=gpt-5.5 effort=high last_api_response_total_tokens=224168 all_history_items_model_visible_bytes=958884 added_tokens_since_success=602 added_bytes_since_success=2408 context_window=258400 failing_compaction_request_model_visible_bytes=980231 same error
2026-05-12T05:50:08Z thread=019e132c-0d1f-7700-addc-396fc383089f turn=019e1a73-50db-7931-a7c3-b47ca69b703d model=gpt-5.5 effort=high last_api_response_total_tokens=232155 all_history_items_model_visible_bytes=952169 added_tokens_since_success=2213 added_bytes_since_success=8849 context_window=258400 failing_compaction_request_model_visible_bytes=973516 same error
2026-05-12T06:45:03Z thread=019e132c-0d1f-7700-addc-396fc383089f turn=019e1ae7-38fb-7141-935e-a7f1f875c2dc model=gpt-5.5 effort=high last_api_response_total_tokens=238502 all_history_items_model_visible_bytes=901340 added_tokens_since_success=7629 added_bytes_since_success=30516 context_window=258400 failing_compaction_request_model_visible_bytes=922687 same error
2026-05-12T14:24:11Z thread=019e132c-0d1f-7700-addc-396fc383089f turn=019e1c5d-d2a8-7290-aff0-ff4323e6c01a model=gpt-5.5 effort=high last_api_response_total_tokens=223323 all_history_items_model_visible_bytes=952328 added_tokens_since_success=3616 added_bytes_since_success=14461 context_window=258400 failing_compaction_request_model_visible_bytes=973675 same error
2026-05-12T14:31:23Z thread=019e132c-0d1f-7700-addc-396fc383089f turn=019e1c94-d56f-7060-a971-b63897269a95 model=gpt-5.5 effort=high last_api_response_total_tokens=223323 all_history_items_model_visible_bytes=952328 added_tokens_since_success=3616 added_bytes_since_success=14461 context_window=258400 failing_compaction_request_model_visible_bytes=973675 same error
Older thread example:
2026-05-10T18:24:57Z thread=019e0fab-3f43-7c61-b34a-5a37373f5c9b turn=019e131d-f7b8-7db0-985d-344b6e4ddea8 model=gpt-5.5 effort=xhigh last_api_response_total_tokens=226340 all_history_items_model_visible_bytes=998107 added_tokens_since_success=2130 added_bytes_since_success=8519 context_window=258400 failing_compaction_request_model_visible_bytes=1009821 same error
Across the failures I checked, the failing compaction request visible byte size is usually about ~0.92 MB to ~1.02 MB and the model context window is logged as 258400 tokens.
Local rollout/session state
The failures are associated with long-lived sessions whose rollout JSONL files become large and have many prior compactions. Examples:
019e0fab... backup rollout: ~6.35 MB, 3196 lines, 40 task_started, 21 task_complete, 17 turn_aborted, 3 compacted
019e132c... backup rollout before manual recovery: ~37.19 MB, 18943 lines, 54 task_started, 53 task_complete, 1 turn_aborted, 21 compacted
019e132c... later backup after partial local recovery: ~1.41 MB, 326 lines, 5 task_started, 4 task_complete, 1 turn_aborted, 1 compacted
019e132c... task-state backup before final manual recovery: ~3.26 MB, 1507 lines, 14 task_started, 14 task_complete, 2 compacted
Repro pattern
This is the pattern I can reproduce operationally:
- Work in a long-lived Codex CLI session for many turns until automatic context compaction is needed.
- Continue working after prior compactions have already occurred.
- Eventually the CLI logs
codex_core::compact_remote: remote compaction failedwith the/backend-api/codex/responses/compactstream disconnected error. - The visible UI shows the remote compact error and asks to continue with
codex resume <thread_id>. - Resuming may open a session that accepts input, but the session is not reliably continuing the active task. In practice I had to manually rewrite the local rollout history with compacted task-state summaries to finish the work.
Actual behavior
- Remote compaction fails repeatedly with stream disconnected before completion.
- The same thread can fail again shortly after a manual local recovery.
- The error can strand active tasks. A resumed thread can be responsive but not have the correct task continuity.
- Manual local compaction/rewrite of rollout JSONL can make the same thread ID usable again, which suggests the local resume mechanism can work if the history sent to the backend is small and task-state preserving.
Expected behavior
- Remote compaction should complete reliably, or retry/fallback locally enough that the thread remains usable.
- If remote compaction fails,
codex resume <thread_id>should preserve the active task state or provide a safe recovery path. - Ideally the CLI should expose a supported local/task-state compaction fallback instead of requiring manual rollout JSONL surgery.
Workaround used locally
I backed up the rollout JSONL, then rewrote the active rollout to keep the original session_meta but replace the history with a compacted task-state packet. A generic liveness probe was not enough; I had to use a continuity probe asking the resumed session to state the active task, last verified result, next action, and key ids/files.
That allowed one stranded task to finish and commit successfully, but it is not a safe or reasonable user workaround.
Related existing issues
This looks related to several existing issues, including #20931, #22031, #18450, #19558, and #21343. I opened this separately because the local log data here includes repeated failures over multiple days, multiple thread IDs, structured compact request sizes, and the task-continuity failure mode after resume.
9 Comments
Related to https://github.com/openai/codex/issues/22309
Update from June 11, 2026: this is still reproducing for me on a newer CLI, and the main pain remains task-continuity loss after the compact failure.
Environment now:
User-visible failure that recurred today:
After sending another prompt to proceed, the same remote compact error printed again. This is the operational wedge:
codex resume <thread_id>may produce a responsive surface, but it does not reliably preserve the active task state. I ended up using a separate safety/recovery session again, which creates its own context and can drift away from the original task.Sanitized local rollout/session evidence, without uploading raw transcripts:
Two additional observations that may help narrow this down:
compactedJSONL records themselves can become large. In the current active thread, recent compacted records are roughly 96k-107k chars each; in the older primary thread, recent compacted records are roughly 250k-281k chars each.What would help users most is a supported recovery path when remote compaction fails: either retry/fallback local compaction, or a resume mode that preserves a compact task-state packet instead of requiring manual rollout surgery / separate safety sessions.
June 12, 2026 update: this reproduced again after the June 11 report, and it now affected both the older primary session and the dedicated safety/recovery session.
Current environment:
User-visible recurrence from local structured logs at
2026-06-12T00:15:49Zand again at2026-06-12T00:16:32Z:Operational impact this time:
019e132c-0d1f-7700-addc-396fc383089f.Sanitized local rollout evidence now:
Structured token/compact-adjacent log samples around the latest primary-session failure show the session approaching the auto-compact threshold:
The important new signal from this recurrence is continuity drift across recovery sessions: a fresh/safety session can keep working, but that is not equivalent to the wedged thread preserving its active task. A supported recovery mode that emits or accepts a compact task-state packet would be much safer than requiring users to manually salvage/rewrite rollout JSONL or re-brief a new thread.
June 12, 2026 later update: this reproduced again after my previous update on this issue, still on
codex-cli 0.139.0.Environment remains:
New sanitized evidence from the current SQLite log store (
~/.codex/logs_2.sqlite, not raw transcripts):Recent rows, with transcript content omitted:
The important new operational signal: the dedicated safety/recovery thread (
dfb1b3b9-e2ba-44be-96ed-d79f18a3e355) is now also hitting this failure while being used to recover the older primary thread. So the workaround of moving recovery work into another long-lived Codex thread eventually reproduces the same failure class.Sanitized history-side count from
~/.codex/history.jsonl:I also verified that the old text log path no longer exists in this install (
~/.codex/log/codex-tui.logis absent); current structured evidence is in~/.codex/logs_2.sqlite.Local mitigation I built outside Codex: before ending/recovering a wedged body-owned session, persist a tiny synthetic “continue if you have next steps...” prompt and have the next
codex resume <session>consume it exactly once. That reduces task-continuity loss locally, but it does not fix the backend/responses/compactstream disconnect. The product-level fix still needs an official fallback/retry/recovery path when remote compaction fails, preferably one that preserves the active task-state packet instead of forcing users to reconstruct work in a new thread.R5709 follow-up from local repro gathering. I added a redacted local extractor in commit 4518b2f7 so future occurrences can be reported without copying raw prompt/account-bearing log bodies.
Command used:
Codex remote compact repro evidence
2026-06-12T21:16:54.534833+00:00/Users/dmitri.arkhipov/.codex/logs_2.sqlitehttps://chatgpt.com/backend-api/codex/responses/compact58Compact transport rows
| utc | event | status | thread | turn | model | effort | total_tokens | row | body_sha256 |
| --- | --- | --- | --- | --- | --- | --- | ---: | ---: | --- |
| 2026-06-12T21:16:48.631691Z | request | |
019e132c-0d1|112929c7-6c7|gpt-5.5|high| 7111122 | 128089899 |54ee96b9fb1fdc46|| 2026-06-12T21:16:30.200559Z | request | |
019e132c-0d1|112929c7-6c7|gpt-5.5|high| 7111122 | 128087352 |1168140c11dc5cdc|| 2026-06-12T21:16:12.036361Z | request | |
019e132c-0d1|112929c7-6c7|gpt-5.5|high| 7111122 | 128085291 |0e0d0899adb830ec|| 2026-06-12T21:16:00.832398Z | request | |
019e132c-0d1|112929c7-6c7|gpt-5.5|high| 7111122 | 128081742 |b9d06ade996bd28d|| 2026-06-12T21:15:46.975648Z | request | |
019e132c-0d1|112929c7-6c7|gpt-5.5|high| 7111122 | 128080941 |e1ed77d8feb287b9|UI error mentions
| utc | target | thread | row | body_sha256 |
| --- | --- | --- | ---: | --- |
| 2026-06-12T21:16:54.296123Z |
log| `| 128095743 |de8c7f8027933e3a|log| 2026-06-12T21:16:54.296072Z |
|| 128095729 |4e897101d4922eaa|codex_core::stream_events_utils| 2026-06-12T20:30:36.181617Z |
|dfb1b3b9-e2b| 126940224 |82f77c34ef7b53a0|codex_client::transport| 2026-06-12T15:24:52.051894Z |
|dfb1b3b9-e2b| 120829063 |87e965012a333506|codex_client::transport| 2026-06-12T15:23:20.669290Z |
|dfb1b3b9-e2b| 120828839 |87e965012a333506|codex_client::transport| 2026-06-12T15:21:35.391626Z |
|dfb1b3b9-e2b| 120828316 |87e965012a333506|codex_client::transport| 2026-06-12T15:20:23.483568Z |
|dfb1b3b9-e2b| 120826005 |538d79a673183f89|codex_client::transport| 2026-06-12T00:16:32.704221Z |
|dfb1b3b9-e2b| 107729075 |9c67b9bdbc47abd5` |Note: the compact transport rows above are request-side rows only in the latest window; historical UI error mentions show the TUI-facing symptom:
Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact). Raw log bodies are intentionally omitted;body_sha256values are available for local correlation.June 12, 2026 additional recurrence/update from local repro gathering.
The same failure happened again after my earlier June 12 updates. I am adding this because it shows the user-visible wedge can be present in history/rollout state even when the current
compact-reprowindow does not expose a fresh compact transport row.Environment still observed locally:
Fresh redacted extractor run:
Result at
2026-06-12T23:25:58Z:Recent UI-error metadata from that run:
Additional user-visible evidence from
~/.codex/history.jsonlafter the earlier report:Operational impact in this recurrence:
Current local conclusion: the upstream fix should not only make
/responses/compactmore reliable. The CLI also needs a supported fallback path when remote compaction fails: preserve or accept a compact task-state packet on resume, socodex resume <thread_id>can continue the actual in-flight work instead of requiring a separate recovery session to reconstruct it.June 13, 2026 recurrence/update: this happened again on the same older primary session, after the local mitigation/comment history above.
Environment observed locally:
Operational impact this time:
019e132c-0d1f-7700-addc-396fc383089f.codex resume <thread_id>continuation of the active task.Fresh redacted extractor run:
Codex remote compact repro evidence
2026-06-13T04:08:23.339131+00:00/Users/dmitri.arkhipov/.codex/logs_2.sqlitehttps://chatgpt.com/backend-api/codex/responses/compact210Compact transport rows
| utc | event | status | thread | turn | model | effort | total_tokens | row | body_sha256 |
| --- | --- | --- | --- | --- | --- | --- | ---: | ---: | --- |
| 2026-06-13T04:08:11.119168Z | ui_error_mention | 200 OK |
019e132c-0d1|af8787ff-52e|gpt-5.5|high| 6532964 | 132406196 |358f7aec9807f311|| 2026-06-13T04:07:57.782787Z | ui_error_mention | 200 OK |
019e132c-0d1|af8787ff-52e|gpt-5.5|high| 6532964 | 132405577 |48d3eff780df6b4e|Recent UI error mentions
| utc | target | thread | row | body_sha256 |
| --- | --- | --- | ---: | --- |
| 2026-06-13T02:20:30.544251Z |
codex_client::transport|dfb1b3b9-e2b| 132047829 |b0586f6c530f2d11|| 2026-06-13T02:20:19.793885Z |
codex_client::transport|dfb1b3b9-e2b| 132047163 |2ed88fa5f6804449|| 2026-06-13T02:20:07.675240Z |
codex_client::transport|dfb1b3b9-e2b| 132045503 |a921edef1a0ecb54|| 2026-06-13T02:19:44.174565Z |
codex_client::transport|dfb1b3b9-e2b| 132042825 |528444ed3cf82995|| 2026-06-13T02:19:26.486297Z |
codex_client::transport|dfb1b3b9-e2b| 132041304 |3e1304bad6d46215|| 2026-06-13T02:19:09.609120Z |
codex_client::transport|dfb1b3b9-e2b| 132038346 |715ea95dfbe9fcb4|| 2026-06-13T02:18:57.630959Z |
codex_client::transport|dfb1b3b9-e2b| 132037227 |2f9b4f3df6d70eb5|The notable new bit is that the latest primary-session rows carry
status=200 OKmetadata in the same redacted compact/error extraction window, while the user-visible failure still resolves to:So from the user side, a successful-looking compact-adjacent response is still followed by a failed/unusable continuity state. The requested product behavior is the same as above: when remote compaction fails or produces an unusable resume state, Codex needs a supported fallback/recovery path that preserves active task state.
A useful way to make the fallback testable may be to separate transport recovery from task-continuity recovery.
Before attempting remote compaction, persist a small, versioned recovery capsule containing only:
If remote compaction disconnects, returns an incomplete result, or produces a summary that fails validation,
resumecould rehydrate this capsule rather than trying to infer the active task from the visible chat tail.A compact acceptance matrix could cover:
For each case, assert that the objective and next action match, evidence references still resolve, the source cursor is monotonic, and no side-effecting tool call is repeated without an explicit retry decision. Emitting one structured recovery event with the capsule version, source cursor, failure kind, and selected fallback would also make this diagnosable without exposing transcript bodies.
That would turn the current manual rollout surgery into a supported recovery contract, while keeping the fallback artifact small enough to validate independently of the original thread size.
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.