codex - 💡(How to fix) Fix Codex CLI appears to lose the configured `model_context_window` after auto-compaction

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…
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.128.0

What subscription do you have?

"auth_mode": "apikey" - api key provided by my company

Which model were you using?

gpt-5.5 hight

What platform is your computer?

Darwin 25.4.0 arm64 arm

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

iTerm2

What issue are you seeing?

Codex CLI appears to lose the configured model_context_window after auto-compaction.

Fresh sessions honor my config and start with a 1.05M context window. However, after a long session hit auto-compaction, the resumed/current session shows an effective context window of ~258K.

What steps can reproduce the bug?

Reproduction

  1. Configure ~/.codex/config.toml with:

    model_context_window = 1050000 model_auto_compact_token_limit = 997500

  2. Start Codex:

  3. Confirm /status shows a 1.05M context window.

  4. Use the session until it reaches auto-compaction.

  5. Resume or continue the compacted session.

  6. Check /status or the rollout logs.

Observed Result

The compacted/resumed session uses ~258K context instead of the configured 1.05M.

What is the expected behavior?

Expected Behavior

After auto-compaction or resume, the session should continue honoring:

model_context_window = 1050000 model_auto_compact_token_limit = 997500

The effective context window should remain around 1.05M for the configured model/provider/profile.

Additional information

Why This Looks Like A Bug

A brand-new session started with the same profile and config correctly reports:

Context window: 100% left (0 used / 1.05M)

So the config is valid and is honored at fresh session start. The issue appears specific to session compaction, where Codex seems to fall back to the provider/model default context window instead of preserving the configured model_context_window.

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

codex - 💡(How to fix) Fix Codex CLI appears to lose the configured `model_context_window` after auto-compaction