Error running remote compact task: stream disconnected before completion

Resolved 💬 62 comments Opened Jan 20, 2026 by loop-uh Closed Mar 27, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.87.0

What subscription do you have?

max

Which model were you using?

_No response_

What platform is your computer?

_No response_

What terminal emulator and version are you using (if applicable)?

_No response_

What issue are you seeing?

<img width="1865" height="66" alt="Image" src="https://github.com/user-attachments/assets/588ac161-136c-41dd-a435-db842711b42a" />

What steps can reproduce the bug?

Uploaded thread: 019bdc79-8188-7831-89c9-10668bd4716c

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

62 Comments

github-actions[bot] contributor · 6 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #7335
  • #7321

Powered by Codex Action

etraut-openai contributor · 6 months ago

Thanks for the bug report. The logs that you attempted to upload unfortunately didn't come through. Do you have that session around still? If so, could you resume it and retry the /feedback command? Much appreciated!

loop-uh · 6 months ago

<img width="801" height="129" alt="Image" src="https://github.com/user-attachments/assets/375608d8-17d3-4ca5-bb1b-61ab359a415d" />
how i can post it?

mattiasflodin · 5 months ago

I get this all the time, particularly during certain hours of the day or if the session contains screenshots. One instance: 019c1105-6702-7690-8970-b08aae6dd5d7

qiushilee · 4 months ago

try the command

codex resume <session-id> --disable enable_request_compression --no-alt-screen
codex fork <session-id> --disable enable_request_compression --no-alt-screen
cooper-xs · 4 months ago

I also have the same error. When I use subagent to complete the task, the context is too long, and the automatic resume will report an error. When I try to enter information or manually resume, it will also report an error. There is no way to continue this conversation at present.
Here is instance: 019cfbac-5a9b-7a12-89e9-7467da5d4cce

adonis-lsh · 4 months ago

me too

greatcorrectandglory · 4 months ago

me too,I restarted and tried again, but it still didn't work. Then I changed the setting from ultra-high to high and tried again, and it worked.

pavljenko · 4 months ago

Me too. I’m consistently getting this error during large code analysis tasks (~40k+ lines):

Error running remote compact task: stream disconnected before completion

It usually happens when Codex tries to compact context in long sessions. After that, execution often breaks or becomes unstable. Seems related to large context size or timeout in the /compact endpoint. Is this a known limitation?

gentilijuanmanuel · 4 months ago

Getting this as well, on a long conversation.

RunsenXu · 4 months ago

Me too! How to save my conversation?

realsharip · 4 months ago

Getting the same issue

``Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)``

gantianyuneil · 3 months ago

If you use codex desktop, try to fork the session/conversation and tell LLM to continue. Works for me.

wmonecke · 3 months ago

this is so annoying

quboliu · 3 months ago

This issue is still happening,codex cli version 0.116.0

larksq · 3 months ago

I investigated this and have a concrete root-cause hypothesis plus a proposed fix.

Root cause appears to be two separate issues in the remote compact path:

  1. /responses/compact is a unary POST, but transport failures on that endpoint currently get funneled through CodexErr::Stream(...), which makes the user-facing error misleading:
  • current surface: stream disconnected before completion: ...
  • actual failure: unary compact request transport failure while sending https://chatgpt.com/backend-api/codex/responses/compact
  1. /responses/compact was not using request compression, even though normal /responses requests already can. On large compact payloads, that makes transport failures more likely.

Proposed fix:

  • add request compression support to unary /responses/compact
  • reuse the existing request-compression gating already used for normal /responses
  • compression should be enabled only when request compression is on, auth is ChatGPT, and provider is OpenAI
  • normalize remote compact transport failures so they surface as:
  • compact request failed: ...

instead of:

  • stream disconnected before completion: ...
  • keep this normalization scoped to remote compact task messaging only, so normal streaming /responses behavior stays unchanged

Suggested regression coverage:

  • compact client path/auth/header behavior
  • compact client compression behavior
  • transient unary compact retry behavior
  • manual remote compact failure wording
  • auto remote compact failure wording
  • replay of at least two previously observed compact failures with the same endpoint/error shape
  • success-path assertion that compact requests use content-encoding: zstd when enabled

If this approach aligns with the intended fix, I can open a PR once invited under the repo’s contribution policy.

If external PR invitation is not possible, this looks like a small, self-contained fix in shared codex-api / codex-core code, and likely straightforward for the Codex team to land directly.

@etraut-openai

Relevant logs were attached:

Source: codex-tui.log

Relevant compact/network failures:

343282:[REDACTED_TIMESTAMP] ERROR session_loop{thread_id=[REDACTED_ID]}:submission_dispatch{submission.id="[REDACTED_ID]"}:turn{otel.name="session_task.turn" thread.id=[REDACTED_ID] turn.id=[REDACTED_ID] model=gpt-5.4}: codex_core::compact_remote: remote compaction failed turn_id=[REDACTED_ID] last_api_response_total_tokens=246302 all_history_items_model_visible_bytes=722396 estimated_tokens_of_items_added_since_last_successful_api_response=51 estimated_bytes_of_items_added_since_last_successful_api_response=203 model_context_window_tokens=Some(258400) failing_compaction_request_model_visible_bytes=737089 compact_error=stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
345369:[REDACTED_TIMESTAMP] ERROR session_loop{thread_id=[REDACTED_ID]}:submission_dispatch{submission.id="[REDACTED_ID]"}:turn{otel.name="session_task.turn" thread.id=[REDACTED_ID] turn.id=[REDACTED_ID] model=gpt-5.4}: codex_core::compact_remote: remote compaction failed turn_id=[REDACTED_ID] last_api_response_total_tokens=203852 all_history_items_model_visible_bytes=683858 estimated_tokens_of_items_added_since_last_successful_api_response=60 estimated_bytes_of_items_added_since_last_successful_api_response=239 model_context_window_tokens=Some(258400) failing_compaction_request_model_visible_bytes=698551 compact_error=stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
350904:[REDACTED_TIMESTAMP] ERROR session_loop{thread_id=[REDACTED_ID]}:submission_dispatch{submission.id="[REDACTED_ID]"}:turn{otel.name="session_task.turn" thread.id=[REDACTED_ID] turn.id=[REDACTED_ID] model=gpt-5.4}: codex_core::compact_remote: remote compaction failed turn_id=[REDACTED_ID] last_api_response_total_tokens=226371 all_history_items_model_visible_bytes=750938 estimated_tokens_of_items_added_since_last_successful_api_response=1753 estimated_bytes_of_items_added_since_last_successful_api_response=7009 model_context_window_tokens=Some(258400) failing_compaction_request_model_visible_bytes=765631 compact_error=stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
351264:[REDACTED_TIMESTAMP] ERROR session_loop{thread_id=[REDACTED_ID]}:submission_dispatch{submission.id="[REDACTED_ID]"}:turn{otel.name="session_task.turn" thread.id=[REDACTED_ID] turn.id=[REDACTED_ID] model=gpt-5.4}: codex_core::compact_remote: remote compaction failed turn_id=[REDACTED_ID] last_api_response_total_tokens=232072 all_history_items_model_visible_bytes=785460 estimated_tokens_of_items_added_since_last_successful_api_response=122 estimated_bytes_of_items_added_since_last_successful_api_response=482 model_context_window_tokens=Some(258400) failing_compaction_request_model_visible_bytes=800153 compact_error=stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
351349:[REDACTED_TIMESTAMP] ERROR session_loop{thread_id=[REDACTED_ID]}:submission_dispatch{submission.id="[REDACTED_ID]"}:turn{otel.name="session_task.turn" thread.id=[REDACTED_ID] turn.id=[REDACTED_ID] model=gpt-5.4}: codex_core::compact_remote: remote compaction failed turn_id=[REDACTED_ID] last_api_response_total_tokens=232072 all_history_items_model_visible_bytes=785855 estimated_tokens_of_items_added_since_last_successful_api_response=222 estimated_bytes_of_items_added_since_last_successful_api_response=877 model_context_window_tokens=Some(258400) failing_compaction_request_model_visible_bytes=800548 compact_error=stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
351367:[REDACTED_TIMESTAMP] ERROR session_loop{thread_id=[REDACTED_ID]}:submission_dispatch{submission.id="[REDACTED_ID]"}:turn{otel.name="session_task.turn" thread.id=[REDACTED_ID] turn.id=[REDACTED_ID] model=gpt-5.4}: codex_core::compact_remote: remote compaction failed turn_id=[REDACTED_ID] last_api_response_total_tokens=232072 all_history_items_model_visible_bytes=785855 estimated_tokens_of_items_added_since_last_successful_api_response=222 estimated_bytes_of_items_added_since_last_successful_api_response=877 model_context_window_tokens=Some(258400) failing_compaction_request_model_visible_bytes=800548 compact_error=stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
356698:[REDACTED_TIMESTAMP] WARN session_loop{thread_id=[REDACTED_ID]}:submission_dispatch{submission.id="[REDACTED_ID]"}: codex_core::codex: startup websocket prewarm setup failed: stream disconnected before completion: tls handshake eof
379487:[REDACTED_TIMESTAMP] WARN session_loop{thread_id=[REDACTED_ID]}:submission_dispatch{submission.id="[REDACTED_ID]"}: codex_core::codex: startup websocket prewarm setup failed: stream disconnected before completion: tls handshake eof
395730:[REDACTED_TIMESTAMP] ERROR session_loop{thread_id=[REDACTED_ID]}:submission_dispatch{otel.name="op.dispatch.user_turn" submission.id="[REDACTED_ID]" codex.op="user_turn"}:turn{otel.name="session_task.turn" thread.id=[REDACTED_ID] turn.id=[REDACTED_ID] model=gpt-5.4}: codex_core::compact_remote: remote compaction failed turn_id=[REDACTED_ID] last_api_response_total_tokens=222716 all_history_items_model_visible_bytes=790703 estimated_tokens_of_items_added_since_last_successful_api_response=4955 estimated_bytes_of_items_added_since_last_successful_api_response=19820 model_context_window_tokens=Some(258400) failing_compaction_request_model_visible_bytes=805396 compact_error=stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
Source: ConsoleLog.txt

Compact-related search result: no matches for compact/responses\/compact/backend-api\/codex patterns.
Full file contents below:

ERROR: SentryCrashCPU.c (58): _Bool sentrycrashcpu_i_fillState(const thread_t, const thread_state_t, const thread_state_flavor_t, const mach_msg_type_number_t): thread_get_state: (ipc/send) invalid destination port
ERROR: SentryCrashCPU.c (58): _Bool sentrycrashcpu_i_fillState(const thread_t, const thread_state_t, const thread_state_flavor_t, const mach_msg_type_number_t): thread_get_state: (ipc/send) invalid destination port
ERROR: SentryCrashMachineContext.c (208): void sentrycrashmc_resumeEnvironment(thread_act_array_t, mach_msg_type_number_t): thread_resume ([REDACTED_ID]): (ipc/send) invalid destination port
sinopec · 3 months ago

This happens to me just as frequently—it’s really frustrating. My long-running background tasks get interrupted and are very difficult to resume.
Codex (v0.116.0)

AnxietyYoungPoet · 3 months ago

I had the same issue. But I found a workaround that successfully saved one of my sessions: temporarily switch to GPT-4 mini (low reasoning) and trigger the compact task, then switch back to GPT-4 after the compaction is complete.

etraut-openai contributor · 3 months ago

Consolidating this issue onto #14860.

haibindev · 3 months ago

try this skill, https://github.com/haibindev/golast, It recovers the last actionable request from a crashed or compacted session, so you can pick up exactly where you left off.

slurrr · 3 months ago

me too
019d4ab1-0351-71a0-ba05-ec95238f5cb6

4sneeze · 3 months ago

same issue here. I don't understand why this kinda serious problem can exist for this long time.

emailweixu · 3 months ago

Same issue here. But for me, I have proxy configured in ~/.codex/config.toml. The conversation continue normally until the context compaction when it spit out the following error message:

Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)

PeresvetS · 3 months ago

Problem still alive. I have it already 2 months...

sinopec · 3 months ago
same issue here. I don't understand why this kinda serious problem can exist for this long time.

really really serious problem, need more focus…

AnxietyYoungPoet · 3 months ago
> same issue here. I don't understand why this kinda serious problem can exist for this long time. really really serious problem, need more focus…

I have a recovery method with a success rate above 90%: temporarily switch to 5.4 mini, then send a message to trigger automatic compaction. Do not use the compact command directly, because it will still most likely fail. Once the compaction is finished, switch back to the original model.

chaosBreaking · 3 months ago
> > 我也遇到了同样的问题。我不明白为什么这么严重的问题会持续这么久。 > > > 问题非常严重,需要更加重视…… 我有一个成功率超过 90% 的恢复方法:暂时切换到 5.4 mini 版本,然后发送一条消息触发自动压缩。不要直接使用压缩命令,因为那样很可能仍然会失败。压缩完成后,再切换回原来的版本。

man up man

cabbagehao · 3 months ago
> > same issue here. I don't understand why this kinda serious problem can exist for this long time. > > > really really serious problem, need more focus… I have a recovery method with a success rate above 90%: temporarily switch to 5.4 mini, then send a message to trigger automatic compaction. Do not use the compact command directly, because it will still most likely fail. Once the compaction is finished, switch back to the original model.

it works

kkver-s · 3 months ago

This situation happens to me quite often. It’s most likely caused by sudden network fluctuations and an excessively long context, which leads to a bug. You can switch to a lower model—for example, if you’re currently using 5.4, switch to 5.3 or an even lower version. Then just send any message, and it will prompt that the context is being compressed. After that, the conversation will return to normal. Don’t bother trying to change your network proxy or anything like that—it’s pointless. I’ve already tried.

suzeqin · 2 months ago
This situation happens to me quite often. It’s most likely caused by sudden network fluctuations and an excessively long context, which leads to a bug. You can switch to a lower model—for example, if you’re currently using 5.4, switch to 5.3 or an even lower version. Then just send any message, and it will prompt that the context is being compressed. After that, the conversation will return to normal. Don’t bother trying to change your network proxy or anything like that—it’s pointless. I’ve already tried.

It works.

6639835 · 2 months ago

Still existing.

AlexanderBich · 2 months ago
same issue here. I don't understand why this kinda serious problem can exist for this long time.

exactly this question...
this is suppose to be the highest priority bug for them.
I literally has been hitting the problem with compaction for the last 2 days non-stop, every second compaction it seems just hangs and fails!

6639835 · 2 months ago

By the way, just adding a bit more info here:

GPT-5.2 works normally and doesn’t show that error message. GPT-5.4, however, always pops it up.

6639835 · 2 months ago
Thanks for the bug report. The logs that you attempted to upload unfortunately didn't come through. Do you have that session around still? If so, could you resume it and retry the /feedback command? Much appreciated!

Uploaded one: 019dbde4-4ab8-73a2-843e-c467a5644989

withlin · 2 months ago

still exist

yueyang130 · 2 months ago

still exist. It really interupt the automation.

0xalank · 2 months ago

seeing this as well frequently, happening more on gpt 5.5

GaoWY-design · 2 months ago

It is completely impossible to carry out the long conversation task. Now, when it runs halfway, it will report an error: "Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)". When will this be fixed?

<img width="830" height="541" alt="Image" src="https://github.com/user-attachments/assets/56046a50-8d61-4fa9-a4ca-3da2506cb957" />

GaoWY-design · 2 months ago

<img width="884" height="627" alt="Image" src="https://github.com/user-attachments/assets/3868e0e7-3634-4729-b181-1cd71c2bdf0d" />

GaoWY-design · 2 months ago

This error has seriously affected my usage experience. I am unable to develop my Unity project.

Trouvaille1 · 2 months ago
> > same issue here. I don't understand why this kinda serious problem can exist for this long time. > > > really really serious problem, need more focus… I have a recovery method with a success rate above 90%: temporarily switch to 5.4 mini, then send a message to trigger automatic compaction. Do not use the compact command directly, because it will still most likely fail. Once the compaction is finished, switch back to the original model.

Only this solution works for me. Thank you!

AnxietyYoungPoet · 2 months ago
> > > same issue here. I don't understand why this kinda serious problem can exist for this long time. > > > > > > really really serious problem, need more focus… > > > I have a recovery method with a success rate above 90%: temporarily switch to 5.4 mini, then send a message to trigger automatic compaction. Do not use the compact command directly, because it will still most likely fail. Once the compaction is finished, switch back to the original model. Only this solution works for me. Thank you!

glad it helps

wmonecke · 2 months ago

800 billion valuation and they cant address this?

andersontim · 2 months ago

Same here. Can't find a workaround. Happens more for me in Xhigh.

QuantIntellect · 2 months ago

Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)
I'm getting tired of this shit !!

qslowprofile · 2 months ago

<img width="749" height="200" alt="Image" src="https://github.com/user-attachments/assets/4af179f3-2373-4601-a2f6-3a75088e252a" />
Very frequently!!!!

T-Higgins · 2 months ago

Any fix for this? It's happening constantly for me today.

denAbramoff · 2 months ago

yep i also got it

lonelygo · 2 months ago

‌‌For complex projects requiring prolonged, independent coding, this issue is simply a disaster. No one wants to spend hours repeatedly trying to recover from errors.

PeresvetS · 2 months ago

Still have this problem, already 4 months. Because of that I have to use Claude Code max instead of codex Pro x20....
Every my chat has this problem.

benisai · 1 month ago

Same issue.

019cd581-6886-7c72-aaba-0ddcfc3627a2

Zhao-hangtian · 1 month ago

It's a serious problem man. Spend more time than it really work for lol

norarains · 1 month ago

same issue!!! fix it!!! bro i paid 100 per month and i am not able to use codex

BenjaminGittins · 1 month ago

This problem is ultra urgent. Please fix and have roubst regression testing to fix compacting issues. There shuold NEVER be a reason for compaction to fail and for me to loose an entire session i cant recover on.. This breaks the entire work flow multiple times a day. Insane.

dstampher · 1 month ago

Hi,

This has been going on for a very long time. It is a major problem. Very disruptive to the workflow. If this problem can be fixed soon, Codex will be much better. I am surprised this is still happening as I have seen multiple updates and it persists.

0xdonmot · 1 month ago

same issue ffs!

MilkWangStudio · 1 month ago

same issue ffs!

Tonywang0350 · 1 month ago

遇到了相同的问题,希望codex解决

0xdonmot · 1 month ago

I turned off my vpn. That seemed to solve the issue up til now at least

Breicer · 1 month ago

same

ybsun0215 · 1 month ago

Why does this problem persist? Whenever I use GPT-5.5 for long-context tasks, I consistently encounter this bug.
I then have to switch to GPT-5.4 Mini to perform a context compaction before switching back to GPT-5.5.
Is your team aware of this issue, and are there any plans to address it?