Claude Code "Prompt is too long" (and "Context limit reached"): which variant you have and how to fix it
Prompt is too long is Claude Code's error for a request that no longer fits the model's context window. Anthropic's error reference defines it as: "The conversation plus attached files exceeds the model's context window." In an interactive terminal session the same condition is displayed as a Context limit reached line; in -p (print) output and in the transcript the text stays Prompt is too long. This page lists every variant the official docs name today and the documented fix for each.
The 30-second answer
- Multi-turn session: run
/compactto summarize earlier turns, or/clearto start fresh. /compactrepliesNot enough messages to compact.: the conversation is a single exchange. Run/clearand resend with less pasted text or smaller attachments.- Find what is filling the window: run
/context. Then disable unused MCP servers with/mcp disable <name>and trim largeCLAUDE.mdfiles. - Message ends in
automatic compaction failed: …: fix the error it names first./compactfails on the same error until you do. - Auto-compact is on by default and normally prevents this error. If you turned it off, turn it back on.
The exact error
The base form, and the form an interactive session shows for it:
Prompt is too long Context limit reached · /compact or /clear to continue
The documented variants:
Context limit reached · /clear to continue Context limit reached · /compact or /clear to continue · auto-compact is off · /config to turn it on Prompt is too long · automatic compaction failed: <the underlying error> 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. Prompt is too long · the request is ~<request tokens> tokens (limit <limit>) and this conversation's own content is most of it. A single-exchange conversation cannot be compacted; start with less content (smaller files or pasted text). Prompt is too long · the request is ~<request tokens> tokens (limit <limit>) but this conversation is only ~<conversation tokens> tokens — the rest is system prompt, tool definitions, and attachment content. A single-exchange conversation cannot be compacted; reduce attached files/tools or start with less context. Input is too long for requested model.
All of these strings are copied from the "Prompt is too long" section and the "Find your error" table of the official Claude Code error reference, fetched on 9 November 2026. The angle-bracket parts are the docs' own placeholders. The last line is the wording Amazon Bedrock uses for the same condition; the docs say Claude Code "handles [it] the same way". None of these strings was produced by a session run for this page.
Verified against the official docs — 9 November 2026
What was checked. The error reference at code.claude.com/docs/en/errors was fetched on 9 November 2026, along with the pages its "Prompt is too long" section links to: context window, model configuration, settings reference, environment variables, memory, commands and MCP. Every string, command and version number on this page comes from those pages as they read on that date.
Installed version. The only commands run locally were claude --version and claude --help, on macOS:
$ claude --version 2.1.321 (Claude Code)
The section names several older-version behaviours ("Before v2.1.162" through "v2.1.306 or later"). 2.1.321 is newer than all of them, so the version-specific fixes below matter only if your claude --version prints something older.
Not verified. The error was not triggered for this page. No session was started, no context window was filled, and /compact, /clear, /context and /mcp disable were not run. Everything below is what the official documentation says, not observed behaviour.
Step 1: Read which variant you got
| What the message says | What the docs say it means | First move |
|---|---|---|
Context limit reached · /compact or /clear to continue | The interactive display of Prompt is too long | /compact or /clear |
Context limit reached · /clear to continue | DISABLE_COMPACT is set, so only /clear is offered | /clear, or unset the variable |
… · auto-compact is off · /config to turn it on | You turned auto-compact off in your user settings | /config, turn on Auto-compact |
Prompt is too long · automatic compaction failed: … | Automatic compaction ran on this turn and failed on an underlying error, such as an unavailable model or an authentication failure | Resolve the named error |
… single exchange … / A single-exchange conversation cannot be compacted | There are no earlier turns to summarize, so Claude Code skips compaction and says what fills the request | /clear, resend smaller |
Input is too long for requested model. | Amazon Bedrock's wording for the same condition | Same steps as the base error |
Step 2: Free space with /compact or /clear
This is the first "What to do" item in the docs: "Run /compact to summarize earlier turns and free space, or /clear to start fresh." /compact accepts optional focus instructions; the context window page gives this example:
/compact focus on the auth bug fix
The docs describe one case where automatic recovery is skipped and you should go straight to /clear: when the content it would carry forward "holds no model reply and less than about 1,000 tokens of your own text, such as a short retry sent after an oversized paste."
Step 3: Single exchange — shrink what you send
If /compact answers Not enough messages to compact., or the error is one of the single-exchange forms, compaction cannot help. The docs explain that the space "is taken by that one prompt and what Claude Code sends with every request". The two token-count forms tell you which side is the problem:
- "this conversation's own content is most of it" — your paste or attached files are too big. Run
/clearand resend with less pasted text or smaller attachments. - "the rest is system prompt, tool definitions, and attachment content" — the overhead is too big. Go to Step 4.
Step 4: Cut the per-request overhead
Run /context first. The docs say it shows "a breakdown of what is consuming the window: system prompt, tools, memory files, and messages". Then:
- MCP servers. "Disable MCP servers you are not using with
/mcp disable <name>to remove their tool definitions from context." The MCP page adds that tool search is enabled by default and defers tool definitions until Claude needs them, so only tool names and server instructions load at session start. Where tool search is off (for exampleENABLE_TOOL_SEARCH=false), tools load upfront and cost more context. - Memory files. "Trim large
CLAUDE.mdmemory files, or move instructions into path-scoped rules that load only when relevant". The memory page's target is under 200 lines perCLAUDE.mdfile, and it notes that@pathimports do not reduce context cost.
Step 5: Check auto-compact is on
The docs state: "Auto-compact is on by default and normally prevents this error." Two things turn it off: the Auto-compact toggle in /config (the autoCompactEnabled setting, default true) and the DISABLE_AUTO_COMPACT environment variable. DISABLE_COMPACT goes further and disables the manual /compact command as well. If you keep auto-compact off on purpose, the docs' advice is to "run /compact yourself before the window fills."
Step 6: Gateways and custom model IDs (error near 200K tokens)
If the error appears near 200K tokens on a model that accepts more, the docs name one cause: "a model ID that Claude Code doesn't recognize. Claude Code assumes a 200K window for such an ID". The model configuration page lists the corrections: run claude update if the model is newer than your Claude Code version, map the ID with a modelOverrides entry, append [1m] for a model with a 1M window, or set the window directly, as in the docs' example:
CLAUDE_CODE_MAX_CONTEXT_TOKENS=400000
The docs note that this variable does not apply to every kind of model ID; check the "Which IDs CLAUDE_CODE_MAX_CONTEXT_TOKENS applies to" section of the model configuration page before relying on it. If your gateway itself rejects requests above 200K tokens, the same page says to set CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000 so sessions compact at that boundary.
Step 7: Rule out an old Claude Code version
Run claude --version. The error reference ties several forms of this error to behaviour that later releases changed:
- Before v2.1.217: Bedrock's
Input is too long for requested model.wording was not recognized, so auto-compact never triggered on it and/compactfailed with the same error. - Before v2.1.269: compaction failed whenever it could not summarize a whole exchange, so a session in that state hit the error on every turn.
- Before v2.1.299: with a custom
ANTHROPIC_BASE_URL, the turn ended withPrompt is too long · automatic compaction failednear the assumed 200K window. - Before v2.1.304: stopping Claude while it was compacting could end the turn with this error. The conversation is unchanged; run
/compactand send your message again. - On v2.1.305: with many MCP tools and a direct connection to the Anthropic API, this error can hide an unrelated 400 or 422 error. Update to v2.1.306 or later to see the original error.
FAQ
Why does /compact answer "Not enough messages to compact."? Per the error reference, the conversation is a single exchange with nothing earlier to summarize. The space is taken by that one prompt plus what Claude Code sends with every request. Run /clear and resend with less pasted text or smaller attachments, or reduce tool definitions and memory files.
Why do I see "Context limit reached" instead of "Prompt is too long"? They are the same condition. The docs say an interactive session shows the error as Context limit reached · /compact or /clear to continue, while -p output and the transcript keep Prompt is too long. Longer forms, such as the compaction-failed form, keep the Prompt is too long · wording.
Does a 1M context window stop this error? It raises the limit rather than removing it. The docs say compaction "works the same way at the larger limit". They also say Claude Code assumes a 200K window for a model ID it does not recognize, so a gateway alias can hit the error near 200K tokens until you give Claude Code the real window (Step 6).
Is "Prompt is too long" the same as "Request too large"? No. The error reference lists Request too large separately: the raw request body exceeded the API's 32MB limit before tokenization, and the docs state that limit "is separate from the context window".
Related
- Claude Code: API key not configured
- Claude Code: command not found
- OpenAI API context_length_exceeded (a different product's context-limit error)
Verified on 9 November 2026: error strings and fix steps checked against the official Claude Code error reference and the docs pages it links to, fetched that day; installed version 2.1.321 confirmed with claude --version. The error itself was not triggered.