BuildGist

Codex ran out of room in the context window: what to do

Kayvan Zahiri ·

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:

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:

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

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

What you need

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.

Try BuildGist

Apple silicon, macOS 12 or later. United States, 18 or older.

Related

Questions: kayvanandre@gmail.com.