Codex ran out of room in the context window: what to do
When Codex runs out of context, type /compact to swap the earlier turns for a
summary, or start a new chat with /new and paste a short note about the task.
/status shows how much room the current chat has left, so you can compact before it
fills.
The message people see
Codex's documentation does not print this error. In the openai/codex issue tracker on GitHub, users quote it like this (issue #28920, about the Codex app on Windows, June 2026):
Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.
Other open reports in the same tracker describe the app showing
Automatically compacting context with the window at 100% and the task stopping anyway
(issue #29319), and one large tool result pushing a request past the window before automatic
compaction ran (issue #32888). These are bug reports from users, not documented behavior, but they explain why the message
can appear with compaction on.
See how full the chat is
Type /status. Codex's developer commands page, read on October 17, 2026, says it
shows the active model, the approval policy, writable roots and current token usage, and that it
is the place to confirm remaining context capacity. In the Codex IDE extension,
/status shows the chat ID, context usage and rate limits.
To keep the number in view, type /statusline and add context stats to the
footer. Codex saves that choice in config.toml, so it is there in every chat after.
Free room with /compact
Type /compact and confirm when Codex offers to summarize the chat so far. It
replaces the earlier turns with a concise summary and you carry on in the same chat. A summary is
shorter than what it replaces, so an exact error string, a file path or the reason you rejected an
approach can come out vaguer than it went in. If one of those matters for the next step, say it
again right after compacting.
/recap sounds similar but only writes a summary for you to read. It frees
nothing.
Tune automatic compaction
Codex compacts by itself when a chat crosses a token threshold. Codex's configuration reference
lists these keys for ~/.codex/config.toml:
model_auto_compact_token_limit: the token count that triggers automatic compaction. Left unset, Codex uses the model's default.model_auto_compact_token_limit_scope:total, the default, counts the whole active context.body_after_prefixcounts only what has grown after the part carried over from the last compaction.model_context_window: how many tokens of context the active model has.compact_prompt: your own wording for the prompt that writes the summary.
The reference gives no recommended values, and this page will not guess any. If the error started after you set one of these, take the line out and retry with the defaults before you change anything else.
Start a new chat without losing the task
When compaction fails or the summary has lost the thread, start a new chat:
/newstarts a fresh chat in the same session./cleardoes the same and also clears what is on screen./forkcopies the current chat into a new one with a fresh ID and leaves the original alone. A fork starts as a copy of the full chat, so it frees no room.
The new chat starts empty but not blind. The files Codex changed are in the folder, committed or
not, and it can read them. What it loses is the task: what you asked for, what is finished, and
what you already ruled out. Before you leave the full chat, wait for the turn to end and type
/export session.md, which saves the whole conversation as Markdown. Then open the new
chat with a note like this, filled in with your own task:
Task: (what you asked for, in one line)
Done: (what is finished; the diff has the details)
Not done: (what is left)
Ruled out: (what you tried that failed, and why)
Next step: (the one thing to do first)
The last chat ran out of context. Do not redo finished work.
Ask Codex to repeat the next step back before it edits anything. Rules you retype in every
chat belong in AGENTS.md, which /init scaffolds, so they survive the
next full window.
Which of these is your situation
- The chat is long but still working. Check
/status, then/compactat a natural stopping point. - You saw the out-of-room message once. Run
/compactyourself and retry. The reporter in issue #28920 says that is what let the chat continue. - Compaction itself fails, or the message comes back every turn. Export, write
the note, and start over with
/new. - You changed the compaction settings. Remove them and retry with the defaults.
Or carry the task to Claude Code or Cursor
A full window is a natural point to switch agents. The note above works the same in Claude Code or Cursor opened on the same project folder: they read the files Codex changed, and the note tells them the rest. Read what Codex changed before you hand it on. The order to read it in is in how to review what Codex changed.
BuildGist can carry the task instead of the note. When you start a new chat in Claude Code or Cursor in the same project, a BuildGist card offers Codex's task. Choose Continue and the chat starts with that context, or Start fresh to skip it. Claude Code takes the context on a new session. In Cursor it is best effort, so if the task does not show, paste the note. Moving a task among all three agents is in how to keep context across Claude Code, Cursor and Codex.
Sources
- Codex developer commands, checked October 17, 2026.
- Codex configuration reference, checked October 17, 2026.
- User reports in openai/codex: #28920, #29319 and #32888, open on October 17, 2026.
What you need
- A Mac with Apple silicon and macOS 12 or later.
- Claude Code, Cursor or Codex.
- A Git project. No commit, push, remote or GitHub repository is needed.
- A GitHub account, to sign in. BuildGist does not access your GitHub repositories.
Codex needs you to approve BuildGist once, in Codex. BuildGist shows the steps. Setup is in Getting started.
To explain a run, your computer sends BuildGist what that run needs, and BuildGist passes it to Anthropic. BuildGist does not keep this material. It does not send your whole repository, files the run did not change, or files named like secrets, such as .env files and keys. It keeps the explanation and short cited excerpts of changed code, at most 12 lines each. Secret masking is best-effort. Privacy has the full list.
Every account gets 7 days of BuildGist Pro free, with no card. The 7 days start at your first explanation or Continue handoff. Nobody is charged when the trial ends. After that, BuildGist Pro is $12 per month, plus any applicable tax shown at checkout. See pricing.
Apple silicon, macOS 12 or later. United States, 18 or older.
Related
- What did Claude Code change?
- Switch from Claude Code to Codex
- Understand code an agent wrote
- Hand off Claude Code to Cursor
- Review what Codex changed
- You’ve hit your session limit in Claude Code
- You’ve hit your usage limit in Codex
- Keep context across agents
- Review AI code before merging
- BuildGist or the git diff
- Claude Code session history
- Undo Claude Code changes
- BuildGist vs CLAUDE.md, AGENTS.md and HANDOFF.md
- Keep context from Claude Code to Cursor
- Resume an agent session in another tool
- BuildGist vs Conductor
- Undo Codex changes
Questions: kayvanandre@gmail.com.