Claude Code: Prompt is too long · automatic compaction failed. Fix the cause or shrink a single exchange
Claude Code couldn’t compact a too-long prompt. Fix the named compaction error, or if it’s a single exchange, /clear and resend less—don’t retry the same paste. Short answer: 5 steps. 1) Read the full message before you /clear everything; 2) If compaction failed with a named cause, fix that first; 3) If it’s a single exchange, there is nothing earlier to summarize; 4) Trim what loads on every request; 5) Keep auto-compact on for the next long session.
Last updated: · This page is the decision checklist; the tools list for “Fix Claude Code automatic compaction failed / single-exchange too long” is a separate URL.
How do I fix the named cause or shrink a single exchange when Claude Code compaction fails?
Read the full message before you /clear everything
Match `Prompt is too long · automatic compaction failed:` (it names the underlying error), or `Prompt is too long · this conversation is a single exchange` / `A single-exchange conversation cannot be compacted`. Those mean compaction couldn’t free enough space—not a model outage. Error index: https://code.claude.com/docs/en/errors
If compaction failed with a named cause, fix that first
Resolve the error after the colon; `/compact` fails on the same cause until you do. Common recoveries: update Claude Code (v2.1.299+ for custom `ANTHROPIC_BASE_URL` window assumptions; v2.1.304+ if you stopped mid-compact; v2.1.306+ if many MCP tools hid a 400/422). Then run `/compact` and resend.
If it’s a single exchange, there is nothing earlier to summarize
When `/compact` returns `Not enough messages to compact.`, one prompt (plus system/tools/attachments) filled the window. Run `/clear`, then resend with less pasted text, smaller attachments, or chunked file reads—not the same giant paste.
Trim what loads on every request
Run `/context` to see system prompt, tools, memory, and messages. Disable unused MCP servers with `/mcp disable <name>`, trim large `CLAUDE.md` files, and prefer path-scoped rules that load only when relevant. Context guide: https://code.claude.com/docs/en/context-window
Keep auto-compact on for the next long session
Auto-compact is on by default and normally prevents this error. If you turned it off in `/config` or with `DISABLE_AUTO_COMPACT`, turn it back on—or run `/compact` yourself before the window fills. Troubleshooting: https://code.claude.com/docs/en/troubleshooting
Which tools are best to fix Claude Code automatic compaction failed / single-exchange too long?
Claude Code error reference
Defines automatic compaction failed and single-exchange cannot be compacted.
Troubleshooting
Compact, /clear, and context refill recovery steps.
Context window
What /context shows and what survives compaction.
Commands
/compact, /clear, /context, and /mcp disable usage.
Open: 1 spot per week
One labeled sponsor for this topic each week; this week's spot is open. See open weeks →
All tools for “Fix Claude Code automatic compaction failed / single-exchange too long” →
Related fixes
- Stop a Cursor agent loopHow to fix a Cursor agent loop (same edit, or work after Stop)Fix →
- Claude Code vs Codex vs Cursor ~$20 plansClaude Code vs Codex vs Cursor $20 plan limits: how to pick without burning the weekFix →
- Scan a vibe-coded app for leaked API keysCheck a vibe-coded app for leaked API keys before you share itFix →
- Add an MCP server to Claude Code, Cursor, or CodexHow to add an MCP server to Claude Code, Cursor, or CodexFix →
See also AI tools launched today on the daily board.
NewAIToolsToday Daily
Top 3 AI launches, one model or news item that matters, and one simple fix. A 5-minute read, every weekday.