wrong display result of context window after adjusting gpt5.4 to 1M context window size

Resolved 💬 3 comments Opened Mar 5, 2026 by winoros Closed Mar 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?

v0.111.0

What subscription do you have?

Pro

Which model were you using?

gpt-5.4

What platform is your computer?

Linux 6.17.0-14-generic x86_64 x86_64

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

ssh

What issue are you seeing?

I viewed the release article https://openai.com/index/introducing-gpt-5-4/.
So I changed the context window by editing the config.toml:

model_context_window = 1000000
model_auto_compact_token_limit = 900000

I tested some sessions already. None of them estimated the correct context window.
Some of them showed like this after a medium run:
<img width="906" height="51" alt="Image" src="https://github.com/user-attachments/assets/dd4491f7-427e-49a7-9366-5b227fa62fa6" />
It output the used token upon exit. But I think the result is wrong.
Token usage: total=12,840 input=11,897 (+ 3,456 cached) output=943 (reasoning 516)

Some of them showed like this after a short run

<img width="807" height="38" alt="Image" src="https://github.com/user-attachments/assets/5a1db73d-c91b-4065-b988-192d5673a733" />
And no used token info after exiting the cli.

What steps can reproduce the bug?

Change the config.toml, then start a session and run any command.

What is the expected behavior?

I'm setting the correct window size for gpt5.4. I think all things should work as usual.

Additional information

_No response_

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 5 months ago

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

  • #11845
  • #11805

Powered by Codex Action

winoros · 5 months ago

I used it to apply a small fix.
Seems that fixing the window size before the first TokenCount works as expected.
This is its summary:

  Summary:
  When model_context_window is manually set to 1_000_000 (for example with GPT-5.4), Codex core correctly treats the usable
  context window as 950_000 because it applies the model’s effective_context_window_percent (95%). However, the TUI initially
  displayed 1M in a new session and before the first TokenCount event arrived. The display was falling back to the raw config
  value (config.model_context_window) instead of the runtime effective window, which made the context window UI and /status
  output inconsistent at startup. After the first TokenCount, the UI corrected itself to 950K. The fix is to cache and use the
  effective context window from runtime events (such as TurnStarted) for pre-token-count displays.

It seems worked, though I don't think the summary is correct.

etraut-openai contributor · 5 months ago

Thanks for the bug report. This will be fixed in the next release.