Codex context_window_exceeded or compaction failed: how to continue
Save progress, try compaction, then continue in the same project with a short handoff.
Start here
Enter /compact in the CLI chat box. If it still fails, start a new chat in the original project and provide a short handoff.
On this page
1. Save work and identify the error
- Save edited files and note the goal, completed work and next step. Keep the old chat.
- Use this guide for context_window_exceeded or context_length_exceeded. For usage limit, see the allowance guide.
2. Try compaction
- Enter the command below in CLI chat and confirm when prompted. In other clients, use compact only if the menu offers it.
- Afterward, ask for the goal and next step. If the same error persists, start a new chat.
/compact3. Start a chat in the same project
- Keep the existing files and send the completed handoff below.
- If the old chat cannot summarize, use its last messages and actual files. Include only the essentials.
Continue this project:
Goal:
Requirements to keep:
Completed work and files:
Verified results:
Next step:
Check the actual files and existing results before continuing.4. Continue in smaller steps
- Have the new chat complete one small task before proceeding.
- Provide files and nearby error logs as needed, and save a brief progress note after each stage.
5. Contact support
- Send the client version, model, error screenshot and results from compaction and the new chat.
- Keep the project files so support can help investigate.