Codex CLI appears to lose the configured `model_context_window` after auto-compaction
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
- Configure ~/.codex/config.toml with:
model_context_window = 1050000
model_auto_compact_token_limit = 997500
- Start Codex:
- Confirm /status shows a 1.05M context window.
- Use the session until it reaches auto-compaction.
- Resume or continue the compacted session.
- 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.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗