codex - 💡(How to fix) Fix Add an option to disable remote compaction and use local fallback in the CLI

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…

Error Message

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

Fix Action

Fix / Workaround

I also tested a minimal local patch against current main that adds the env gate at the existing should_use_remote_compact_task(...) decision point and leaves the default behavior unchanged. The local patch was small: codex-rs/core/src/compact.rs plus focused unit coverage in codex-rs/core/src/compact_tests.rs.

Code Example

CODEX_DISABLE_REMOTE_COMPACT=1 codex

---

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

---

Error running remote compact task: context_length_exceeded
RAW_BUFFERClick to expand / collapse

What variant of Codex are you using?

CLI

What feature would you like to see?

Codex CLI currently decides to use remote compaction based on the model provider. For OpenAI/ChatGPT auth this can force /compact and auto-compaction through the remote /responses/compact endpoint.

I would like a supported runtime override that disables remote compaction and lets the CLI use the existing local compaction path/fallback instead. One narrow option would be an environment variable such as:

CODEX_DISABLE_REMOTE_COMPACT=1 codex

When the variable is set, the CLI should skip the remote compact task and return false from the same decision point that currently checks provider remote-compaction support. When it is not set, behavior should remain unchanged.

Why this would help:

  • Normal Codex requests can work while the remote compact endpoint fails independently.
  • In long-running CLI sessions, a failed remote compaction can make /compact or automatic compaction unusable.
  • Users in proxy/VPN/firewall-sensitive environments may need to route normal API traffic differently from the ChatGPT backend compact endpoint.
  • Some users prefer a deterministic local fallback over failing the active session when the remote compact task is unavailable.

Example errors seen in the CLI:

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

I tried setting compact_mode = "local" in ~/.codex/config.toml, but the current CLI still reported remote compact task, so this config key appears to be ignored by the current code path. A documented env/config override would make this behavior explicit.

Additional information

I searched existing issues before filing this. There are several related remote compaction failures, for example #17392, #13271, #14860, #19400, and the earlier local-fallback discussion in #10986. This request is intentionally narrower than changing the default: keep remote compaction enabled by default, but expose an explicit escape hatch for users whose sessions are blocked by the remote compact endpoint.

I also tested a minimal local patch against current main that adds the env gate at the existing should_use_remote_compact_task(...) decision point and leaves the default behavior unchanged. The local patch was small: codex-rs/core/src/compact.rs plus focused unit coverage in codex-rs/core/src/compact_tests.rs.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING