codex - 💡(How to fix) Fix Remote compaction intermittently fails with stream disconnected before completion [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#17392Fetched 2026-04-11 06:16:49
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
1
Author
Timeline (top)
labeled ×3commented ×1unlabeled ×1

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.

Error Message

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) 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=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)

Root Cause

This does not appear to be caused by local repo code, shell commands, or a project-specific setup issue.

RAW_BUFFERClick to expand / collapse

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:

  1. long-running threads
  2. large accumulated tool output and/or long conversation history
  3. 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

extent analysis

TL;DR

  • The issue can be mitigated by adjusting the model context window or implementing a retry mechanism for remote compaction requests.

Guidance

  • Investigate the correlation between the model context window tokens (model_context_window_tokens=258400) and the failure to compact, considering adjustments to this parameter.
  • Review the API request for https://chatgpt.com/backend-api/codex/responses/compact to ensure it is properly formatted and that the server is not disconnecting due to request size or timeout issues.
  • Consider implementing a retry mechanism with exponential backoff for the remote compaction request to handle intermittent failures.
  • Analyze the last_api_response_total_tokens and all_history_items_model_visible_bytes values in the log lines to understand their impact on the compaction process.

Example

  • No specific code snippet can be provided without more context on the Codex App's internal implementation, but a potential workaround could involve modifying the compaction request to handle larger payloads or to retry upon failure.

Notes

  • The issue seems specific to the remote compaction request path and is intermittent, suggesting a potential problem with the request handling or server-side processing.
  • The provided log lines indicate a possible correlation between the failure and the size of the data being compacted, but more investigation is needed to confirm this.

Recommendation

  • Apply workaround: Implementing a retry mechanism for the remote compaction requests could help mitigate the issue until a more permanent fix is available. This approach can help improve the reliability of the compaction process without requiring significant changes to the underlying system.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When a thread needs compaction, Codex should either:

  • complete compaction successfully, or
  • fail gracefully with a retry/recovery path that preserves usability

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING