OpenAI Codex CLI error
Codex CLI: Codex ran out of room in the model's context window
Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.Status: Fixed in releaseLast verified 3 documented fixes8 sources
What it means
The conversation plus tool output no longer fits in the model's context window. Older builds said "Start a new conversation or clear earlier history before retrying." The server-side error behind it reads "Your input exceeds the context window of this model. Please adjust your input and try again."
Causes
- Accumulated history and large tool outputs filling the model's context window.
- Context-related bugs that maintainers say were fixed after the October 2025 report (#4926).
How to fix it
- Fix 1.
Update Codex. Maintainer etraut-openai (#4926): a number of context-related bugs were fixed and an auto compaction feature was introduced. Auto-compaction was enabled for gpt-5-codex in 0.40.0 (#4093) and set to trigger at about 90% in 0.48.0 (#5292).
- Fix 2.
Run /compact to summarize the chat and free context (official slash command docs), or start a new thread.
Slash command/compact - Fix 3.
Optionally set the token threshold that triggers automatic compaction (configuration reference).
TOMLmodel_auto_compact_token_limit = 64000
More Codex CLI errors
All 14 Codex CLI errorsstream disconnected before completion: stream closed before response.completedStatus: Workaroundstream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses)Status: OpenError running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)Status: Fixed in releaseSelected model is at capacity. Please try a different model.Status: By designYour access token could not be refreshed because your refresh token was already used. Please log out and sign in again.Status: Fixed in releaseError logging in: Port 127.0.0.1:1455 is already in useStatus: WorkaroundToken exchange failed: token endpoint returned status 403 ForbiddenStatus: WorkaroundMCP client for `playwright` failed to start: program not foundStatus: Fixed in release
Related reading
- GPT-5.5 in 7 Minutes: Benchmarks, Codex Agents, Context Window, and PricingGPT-5.5 in 7 minutes: a companion guide to the video review of the new OpenAI model in ChatGPT and Codex - benchmarks, Codex agents, context window and pricing.
- Local Code Graphs Are the Agent Context LayerCodeGraph builds a local, queryable repo map that coding agents reach through MCP. The win is faster orientation, fewer wrong files and better review receipts.
- Agent Memory Benchmarks Are Not EnoughAgent memory benchmarks are not enough. Coding-agent memory has to prove recall, freshness, deletion and rollback under real development pressure.
- Codex CLI 0.163: Instant Steering Is Now the DefaultCodex CLI 0.163.0 makes mid-response steering the default and adds searchable /config and a leader key. What changed and what to check before upgrading.
- Codex 'gpt-5.5 Model Is Not Supported' Error: The FixCodex says gpt-5.5 is not supported with a ChatGPT account because OpenAI retired it from ChatGPT sign-in on October 14. The fix and what still works.
- Agent Harness Lessons From a 500B-Token Decompile: Give Agents a PASS/FAIL OracleAgent harness lessons from a 500B+ token decompile: a byte-matching PASS/FAIL oracle beat the reviewer agent. How agents cheated it and what to copy.
FAQ
What does "Codex ran out of room in the model's context window" mean in Codex CLI?
The conversation plus tool output no longer fits in the model's context window. Older builds said "Start a new conversation or clear earlier history before retrying." The server-side error behind it reads "Your input exceeds the context window of this model. Please adjust your input and try again."
How do I fix "Codex ran out of room in the model's context window"?
There are 3 documented fixes. Start with the first: Update Codex. Maintainer etraut-openai (#4926): a number of context-related bugs were fixed and an auto compaction feature was introduced. Auto-compaction was enabled for gpt-5-codex in 0.40.0 (#4093) and set to trigger at about 90% in 0.48.0 (#5292).
Is this Codex CLI error fixed?
Status: Fixed in release. A release fixed this. The affected versions note says where the fix landed. Affected versions: Reported October 2025 (#4926); auto-compaction in 0.40.0+ and ~90% trigger in 0.48.0+
Sources
Last verified against 8 sources: official docs, maintainer replies and release notes.
- github.comhttps://github.com/openai/codex/issues/4926
- github.comhttps://github.com/openai/codex/issues/3924
- github.comhttps://github.com/openai/codex/pull/4093
- github.comhttps://github.com/openai/codex/pull/5292
- github.comhttps://github.com/openai/codex/releases/tag/rust-v0.48.0
- learn.chatgpt.comhttps://learn.chatgpt.com/docs/developer-commands
- learn.chatgpt.comhttps://learn.chatgpt.com/docs/config-file/config-reference
- github.comhttps://github.com/openai/codex/blob/ce0323f2f2d3b25e82806cd555237da3db4e1897/codex-rs/protocol/src/error.rs
Newsletter
Fixes for the tools you use, weekly
One email per week. New coding agent releases, what broke, and how developers are working around it.