Codex CLI runs out of context instead of compacting/resuming long thread with many tool calls
Open 💬 0 comments Opened Apr 27, 2026 by ledmaster
What version of Codex CLI is running?
codex-cli 0.125.0
What subscription do you have?
Pro
Which model were you using?
gpt-5.5 xhigh
What platform is your computer?
Darwin 24.6.0 x86_64 i386
What terminal emulator and version are you using (if applicable)?
Ghostty 1.3.1
What issue are you seeing?
During a long Codex CLI session, Codex hit the context-window limit and showed this message:
Codex ran out of room in the model's context window. Start a new thread or clear earlier
history before retrying.
The session was not able to continue normally from the existing thread. I had to start/use a new compacted context instead of the CLI automatically compacting the conversation or giving a working continuation path.
Uploaded thread:
019dd000-1909-7592-9fa5-c26c1f006225
What steps can reproduce the bug?
- Start a Codex CLI session using
codex-cli 0.125.0. - Ask Codex to do a research-heavy task that requires current web/GitHub investigation.
- In my thread, the task was researching Xiaomi S20+ vacuum map backup/recovery. The turn included:
- 30 built-in web tool actions: 8 searches, 20 page opens, and 2 find-in-page operations.
- 58 shell tool interactions: 53
exec_commandcalls and 5write_stdincalls. - All 53
exec_commandcalls werecurl-backed shell commands, covering GitHub raw files, GitHub API endpoints, Xiaomi MIOT spec endpoints, and related project documentation.
- Several tool outputs were large. The largest recorded tool output was:
curl -sL
'https://raw.githubusercontent.com/Tasshack/dreame-vacuum/master/custom_components/dreame_vacuum/dreame/resources.py'
Original token count: 815104
Output bytes in transcript: 40167
- Before the error, the session token logs showed cumulative token usage growing well beyond the model context window. The final token-count event immediately before the failure was:
total_tokens: 258400
model_context_window: 258400
- Codex then failed before producing the final answer with:
Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.
Uploaded thread: 019dd000-1909-7592-9fa5-c26c1f006225
What is the expected behavior?
Codex CLI should compact the conversation automatically instead of requiring the user to start a new thread or manually clear earlier history.
Additional information
_No response_