Claude Code · Requests and models
Prompt is too long / Context limit reached
Fix “Prompt is too long” and “Context limit reached” in Claude Code: compact, clear or trim what fills the context window, with exact steps.
Message
The exact error
Context limit reached · /compact or /clear to continueAlso appears as:
- In -p output and transcripts
- Prompt is too long
- When automatic compaction failed
- Prompt is too long · automatic compaction failed: <the underlying error>
- Amazon Bedrock
- Input is too long for requested model.
- A single exchange that can’t be compacted
- 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.
- With auto-compact turned off
- Context limit reached · /compact or /clear to continue · auto-compact is off · /config to turn it on
- Claude apps gateway
- capability_rejected: prompt_too_long
Meaning
What does “Prompt is too long” mean in Claude Code?
“Prompt is too long” means the conversation plus everything Claude Code sends with it (system prompt, tool and MCP definitions, CLAUDE.md and attachments) no longer fits the model’s context window. Every request carries all of that, so when the total passes the window, the API refuses it. Auto-compact normally summarises older turns before this happens; seeing the error means it was turned off, it failed on another error, or a single huge message filled the window by itself.
Causes
Why does it happen when auto-compact is on?
- One message too big on its own: a huge paste, a large file read or a big tool result
- Compaction itself failed on another error (the message then ends
automatic compaction failed: <the underlying error>) - Auto-compact turned off in
/configor withDISABLE_AUTO_COMPACT - Many MCP servers whose tool definitions are sent with every request, or a very large CLAUDE.md
Fix
How do I fix “Context limit reached · /compact or /clear to continue”?
Step back past the oversized turn
If the error appeared right after you pasted a big file or Claude read a large output, press Esc twice to rewind past that turn, then continue with a smaller excerpt. This keeps the rest of the conversation.
Compact or start fresh
Run
/compactto summarise earlier turns, or/clearto start a new conversation. If/compactsaysNot enough messages to compact., the one message is too big: run/clearand resend with less pasted text. If the message names a failed compaction, fix that underlying error first, since/compactfails on it too.See what’s using the space
Run
/contextfor a breakdown of system prompt, tools, memory files and messages.Cut what’s sent every time
Disable unused MCP servers with
/mcp disable <name>, and trim large CLAUDE.md files or move parts into path-scoped rules that load only when Claude works on matching files (the CLAUDE.md generator helps keep it short). Hand noisy work such as test runs to a subagent, which returns only a summary. The context window checker shows how much a document takes before you paste it.Turn auto-compact back on
If you switched it off in
/configor withDISABLE_AUTO_COMPACT, turn it on again, or run/compactyourself before the window fills.
Explained
Does it happen on Bedrock, gateways or custom models?
Yes, with different wording. Amazon Bedrock reports the same condition as Input is too long for requested model., and a Claude apps gateway as capability_rejected: prompt_too_long; Claude Code handles both the same way. If the error appears near 200K tokens on a model that accepts more, Claude Code may not recognise the model ID and is assuming a 200K window: Anthropic’s model configuration docs explain how to give it the real window.
FAQ
Questions people ask
Why do I get “Prompt is too long” on every message after it appears once?
The oversized content is still in the conversation, so every new request re-sends it and fails the same way. Press Esc twice to step back past the turn that added the large content, run /compact, or run /clear to start a new conversation. Current versions recover better on their own; older ones could stay stuck until you cleared the session.
What does “this conversation is a single exchange and cannot be compacted” mean?
There are no earlier turns to summarise, so the space is taken by your one prompt plus what Claude Code sends with every request: the system prompt, tool definitions and attachments. Run /clear and resend with less pasted text or smaller files, disable MCP servers you don’t need, or trim large CLAUDE.md files.
How do I keep my work when I hit the context limit?
Run /compact, which keeps a summary of earlier turns, or ask Claude for a short summary of decisions and next steps before you clear. Your previous conversation stays on disk and you can return to it later with /resume. Lasting instructions belong in CLAUDE.md, which is loaded again after a /clear.
Is “Prompt is too long” the same as “Request too large”?
No. “Prompt is too long” is about tokens: the request exceeds the model’s context window. “Request too large” is a separate 32MB limit on the raw request body, usually hit by accumulated images, attachments or very large tool results, and it applies before tokens are counted. /compact drops accumulated images and attachments.
Related
Related errors
- Claude Code: You've hit your session limit (usage limit reached)Server and limits
- There's an issue with the selected modelRequests and models
- API Error: 400 due to tool use concurrency issuesRequests and models
- API Error: 500 Internal server errorServer and limits
- API Error: Claude’s response exceeded the 32000 output token maximumRequests and models
- API Error: Usage credits required for 1M contextServer and limits
Keep exploring