Submit a toolSubmit

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.

The problem: 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.

How do I fix the named cause or shrink a single exchange when Claude Code compaction fails?

  1. 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

  2. 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.

  3. 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.

  4. 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

  5. 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.

All tools for “Fix Claude Code automatic compaction failed / single-exchange too long” →

Related fixes

See also AI tools launched today on the daily board.