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

Resolved 💬 2 comments Opened May 8, 2026 by mityayak Closed May 8, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

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

  1. Start Codex:
  2. Confirm /status shows a 1.05M context window.
  3. Use the session until it reaches auto-compaction.
  4. Resume or continue the compacted session.
  5. 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.

View original on GitHub ↗

2 Comments

github-actions[bot] contributor · 3 months ago

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

  • #21770
  • #21569
  • #20132

Powered by Codex Action

etraut-openai contributor · 3 months ago

It looks like you're attempting to set an invalid (unsupported) model window size. It's getting set back to a valid (supported) value. A 1M context window is not currently supported in Codex for GPT-5.5. See #19464.