Skip to content
Checked against codex-cli 0.146.0 · October 9, 2026

When Codex exceeds the context window while compacting

Recover when Codex says its context window was exceeded while compacting, understand what history was dropped, and continue with an explicit state handoff.

Short answer

“Context window exceeded while compacting” means Codex could not fit the material needed for compaction and removed an oldest history item before retrying. Stop adding broad context, record the current goal and verified state in a file, then continue narrowly. Start a new session if the result has lost an important constraint.

What the message means

Compaction is supposed to replace older turns with a smaller working summary. This warning appears when that compaction request is itself too large. Codex responds by removing old history and trying to proceed, which can preserve momentum but may discard a decision you still need.

Fix it in this order

1. Check whether the task is still oriented

Ask for the goal, constraints, files changed, failing check, and next action. Compare the answer with the repository and your task notes. Do not assume the newest summary retained every early instruction.

Summarize the current goal, hard constraints, verified changes, failing checks, and next action.

2. Move durable state into the repository

Write a concise progress file or update the task checklist with facts that survive conversation compaction. Keep secrets and uncommitted private data out of that note, and verify commands rather than copying speculative model output.

# Update the project's existing task or progress file

3. Fork or start clean when context is unreliable

Use codex fork to preserve the original and try a narrower direction, or begin a new Codex session from the progress note. A new session loses conversational memory but can re-read the current files and tests.

codex fork --last "Read the task note, inspect the diff, and continue from the next unchecked item."

Important distinctions

  • This is a context-management warning, not a plan quota or credit message.
  • Removing an oldest history item does not undo file changes already made in the working tree.
  • A longer handoff is not always safer; include verified state and next decisions, not the entire transcript.

Where Crowsnest fits

Crowsnest reads Codex history through the supported app-server and can search older local turns when compaction drops something from the active working context. It does not rewrite completed Codex history or change the model's context limit.

Source and version

The exact text and flags on this page were checked against the installed codex-cli 0.146.0 binary on October 9, 2026. Version-specific behavior can change, so compare your own --help output before scripting around it. Official status or documentation →

Reviewed from first-party CLI output and the released Crowsnest product source. No command on this page bypasses provider limits, billing, authentication, or native history rules.