Home / Blog / Pricing

Pricing

Claude Code "Prompt Is Too Long": Why It Happens and How to Fix It

Claude Code says 'Prompt is too long' or /compact fails with 'Conversation too long'? What fills the context window and the commands that clear it fast.

8 min read

Error meanings and fixes checked Oct 30, 2026 in Claude Code’s error reference and troubleshooting guide. User-reported error strings are quoted from Claude Code GitHub issues #18199, #21853 and #23047 (verified Oct 29, 2026). Every source is listed at the bottom. No affiliate links on this page (how we work).

The exact errors: Prompt is too long and Conversation too long

Claude Code has a few ways of telling you the same thing. You’ll see one of these:

Prompt is too long
Context limit reached · /compact or /clear to continue
Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again.

The first two are the documented forms. Claude Code’s error reference says Prompt is too long is the API error, and that “in an interactive session, Claude Code shows this error as” the Context limit reached line (verified Oct 30, 2026). The third one, where /compact itself gives up, comes from user reports in GitHub issues #18199 and #21853 (verified Oct 29, 2026). It isn’t listed in the current error reference.

The short answer (as of Oct 30, 2026): your conversation, plus everything Claude Code sends along with it, no longer fits in the model’s context window. Anthropic’s wording is “The conversation plus attached files exceeds the model’s context window.” This is a size problem, not a billing problem. You haven’t run out of usage, and upgrading your plan won’t make a full window empty.

The fix is almost always one of /compact, /context, /mcp disable or /clear. Here’s the order.

What actually fills the context window

People blame the chat history, and sometimes that’s right. But the request Claude Code sends each turn carries more than your messages. Anthropic’s /context command breaks it into four parts (error reference, verified Oct 30, 2026):

  • System prompt: Claude Code’s own instructions.
  • Tools: the definitions of every tool it can call, including every tool from every MCP server you’ve connected.
  • Memory files: your CLAUDE.md files, loaded every turn.
  • Messages: the conversation itself, including file contents Claude read and command output it saw.

That’s why you can hit the error in a brand-new session. Anthropic documents a specific message for it: Prompt is too long · this conversation is a single exchange and cannot be compacted — the request size comes mostly from system prompt, tool definitions, or attachments. One giant paste, a pile of MCP servers and a novel-length CLAUDE.md will do it before you’ve said hello.

The fix, in order

Here’s the documented sequence, cheapest first (error reference, verified Oct 30, 2026):

  1. /compact. It summarizes earlier turns to free space. Auto-compaction, when it runs, “normally summarizes your oldest exchanges and keeps the newest”. The troubleshooting guide also lets you steer it, with an example like /compact keep only the plan and the diff. Think of it as middle-out compression from Silicon Valley, except it actually ships.
  2. /context. Run it to see “a breakdown of what is consuming the window: system prompt, tools, memory files, and messages.” If it opens with something like Context exceeds the 200k-token limit by 94k tokens — run /compact or /clear to continue., you know exactly how far over you are. That example is from Anthropic’s docs; your numbers will differ.
  3. Disable MCP servers you aren’t using. /mcp disable <name> removes their tool definitions from context. If /context shows tools eating a big slice, this is your fix. It’s the Chuck McGill move from Better Call Saul, unplugging everything in the house, except here it actually helps.
  4. Trim CLAUDE.md. Anthropic suggests trimming large memory files “or move instructions into path-scoped rules that load only when relevant.” Your 4,000-line style guide doesn’t need to ride along when you’re fixing a typo.
  5. /clear. This starts fresh. It’s the right call when the old conversation has done its job, or when /compact can’t help. Then resend with less pasted text or smaller attachments.

Also check that auto-compact is on. Anthropic says it “is on by default and normally prevents this error.” If you turned it off, newer versions tell you: Context limit reached · /compact or /clear to continue · auto-compact is off · /config to turn it on (v2.1.235 and later). Flip it back in /config, or run /compact yourself before the window fills.

When /compact fails

This is the scenario that sends people to Google, so here’s what the official docs cover and what they don’t.

  • Not enough messages to compact. Anthropic explains this means “the conversation is a single exchange with nothing earlier to summarize”. Run /clear and resend with less, or cut tools and memory files using steps 3 and 4.
  • Prompt is too long · automatic compaction failed: <the underlying error>: auto-compaction tripped over something else, such as an unavailable model or an auth failure. Anthropic says to “Resolve the named error first; /compact fails on the same error until you do.”
  • You hit Esc while it was compacting. Your conversation is unchanged and still too big. Run /compact again, and update to v2.1.304 or later so stopping mid-compaction stops causing this.
  • Conversation too long. Press esc twice to go up a few messages and try again. This is the user-reported wording from #18199 and #21853. The message tells you its own fix: press Esc twice to step back a few messages, then try again from there. If that doesn’t work, update Claude Code (the current docs describe newer compaction fallbacks), then /clear.
  • Compaction works, then the window refills instantly. The troubleshooting guide calls this Autocompact is thrashing: the context refilled to the limit..., usually a big file or tool output refilling the window several times in a row. Its documented fixes: read big files in chunks instead of all at once, use /compact keep only the plan and the diff, hand the heavy reading to a subagent (it runs in a separate context window), or /clear.

Two version notes from the error reference. If you see the error near 200K tokens on a model that accepts more, Claude Code may not recognize your model ID, since it assumes a 200K window for unknown IDs; the docs show how to set the real window. And v2.1.305 can hide an unrelated 400 or 422 API error behind this one when you have many MCP tools, so update to v2.1.306 or later to see the real error.

Want to keep the conversation but restart the terminal? Anthropic’s troubleshooting guide says restarting doesn’t lose your conversation: claude --resume in the same directory picks it back up. That keeps your context, so it won’t fix a full window by itself.

Will a bigger plan fix it?

Mostly no, and this is the part I wish Anthropic’s upsell emails said out loud. Context window and usage limits are different things.

  • Usage limits are how much you can use Claude per five-hour session and per week. Pro, Max and Team change those. That’s covered in Claude Code usage limits and, for the big plans, Claude Max vs Ultra.
  • Context window is how much fits in a single request. Anthropic’s pricing grid lists context as “Up to 1M varies by model” on both Pro and Team (verified Oct 29, 2026), so it’s tied to the model more than the plan. Anthropic’s help pages don’t all quote the same number, which is why I’m not printing a per-plan figure here.

The one place money touches context: the error reference documents API Error: Usage credits required for 1M context, which it calls “an entitlement check, not a quota exhaustion”. Some setups need usage credits turned on to use the 1M window. If that’s your message, it’s a billing switch, not a full context.

The cost angle: a bloated context makes every request more expensive in tokens, cache or no cache. If you’re on the API, Claude prompt caching pricing explains what repeated context costs, and Claude Code pricing covers the plans. Keeping context lean saves usage on every plan.

Different error? If it says 529 or Overloaded, that’s server capacity, not size. See Claude Code 529 overloaded. If you’re shopping for a second tool anyway, AI coding tools compared has dated prices.

Here’s what I’d do

Run /context first, before anything else. It turns a vague error into a pie chart of blame. If messages are the problem, /compact (with an instruction about what to keep). If tools are the problem, /mcp disable the servers you forgot you installed. If CLAUDE.md is the problem, cut it. And if the session has wandered through three features and a refactor, /clear and start clean. Sometimes a cut to black, Sopranos-style, is the right ending.

Getting “Invalid API key · Please run /login” instead? This Claude Code login fix covers stray keys and wrong logins.

Seeing a connection error instead? The Claude Code ECONNRESET fix covers Unable to connect to API.

Edits failing with a different message? Claude Code “File has been unexpectedly modified” explains the read-before-write check and its fixes.

A 400 with a different message? Claude Code API Error 400 breaks down the variants.

FAQ

Why does Claude Code say prompt is too long? The conversation plus attached files, tool definitions and memory files has grown past the model’s context window, so the request no longer fits.

How do I fix prompt is too long in Claude Code? Run /compact to summarize earlier turns, check /context to see what is filling the window, disable unused MCP servers with /mcp disable, trim CLAUDE.md, or /clear to start fresh.

What does Conversation too long. Press esc twice to go up a few messages and try again. mean? Compaction itself failed because the conversation was too big to summarize; press Esc twice to step back a few messages, retry, update Claude Code, or /clear.

Does /compact lose my work? Your files are untouched; /compact summarizes older conversation turns and keeps the newest, so fine detail from early in the chat can be condensed.

Will upgrading to Claude Max fix prompt is too long? No, plans change usage limits, while the context window depends on the model; clear or compact the context instead.

Why do I get Prompt is too long in a brand-new session? The system prompt, MCP tool definitions, CLAUDE.md and any pasted files can fill the window alone; disable unused MCP servers and trim memory files.

Sources

  1. Claude Code error reference (Prompt is too long, Context limit reached, compaction-failed and single-exchange forms, Not enough messages to compact, /context, /mcp disable, CLAUDE.md, auto-compact, 200K assumption, version notes, 1M usage credits): https://code.claude.com/docs/en/errors (verified 2026-10-30)
  2. Claude Code troubleshooting (Autocompact is thrashing, /compact with instructions, subagents, claude —resume): https://code.claude.com/docs/en/troubleshooting (verified 2026-10-30)
  3. Claude Code GitHub issue #18199 (Conversation too long. Press esc twice, user report): https://github.com/anthropics/claude-code/issues/18199 (verified 2026-10-29)
  4. Claude Code GitHub issue #21853 (Conversation too long regression, user report): https://github.com/anthropics/claude-code/issues/21853 (verified 2026-10-29)
  5. Claude Code GitHub issue #23047 (Context limit reached · /compact or /clear to continue, user report): https://github.com/anthropics/claude-code/issues/23047 (verified 2026-10-29)
  6. Claude pricing (context window “Up to 1M varies by model”): https://claude.com/pricing (verified 2026-10-29)

Related reading