Fix Claude Code "Prompt is too long" (Context limit reached)
Claude Code Prompt is too long or Context limit reached means the context window is full. Run /compact, or /clear and resend less for a single exchange.
Context limit reached · /compact or /clear to continueThe conversation plus attached files exceeds the model's context window. An interactive session shows the line above; claude -p output and the transcript show Prompt is too long. Run /compact to summarize earlier turns and keep going, or /clear to start fresh when there is nothing earlier to summarize.
[1] Read what follows the message to tell the cases apart. The same error carries different tails, and each needs a different fix.
| What you see | Meaning and fix |
|---|---|
Context limit reached · /compact or /clear to continue | Basic form. Run /compact |
… · auto-compact is off · /config to turn it on | Auto-compact was turned off in user settings. Turn it back on in /config |
Prompt is too long · automatic compaction failed: <error> | Auto-compact failed on another error, such as an unavailable model or an auth failure. Fix that error first |
Prompt is too long · this conversation is a single exchange and cannot be compacted … | Only one exchange, so nothing to summarize. /clear and resend with less |
Input is too long for requested model. | The same condition on Amazon Bedrock. Same fixes |
/compact answering Not enough messages to compact. is the same single-exchange signal.
[2] In a multi-turn conversation, run /compact. It summarizes the oldest exchanges and keeps the newest. What survives compaction is covered in /compact vs /clear for long sessions. If you don't need the earlier context, /clear is quicker.
[3] In a single-exchange conversation, read the numbers in the message. When the API reports token counts, you get one of two forms.
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.The first means the pasted text or files are too big: /clear and send them in pieces. The second means the conversation is small but the system prompt, tool definitions and memory files sent with every request take the room; go to step 4.
[4] Run /context to see what fills the window, then cut the large items. It breaks usage down into system prompt, tools, memory files and messages.
- Disable MCP servers you don't use with
/mcp disable <name>. Their tool definitions leave the context. - Trim a large
CLAUDE.md, or move instructions into path-scoped rules that load only where they apply.
If /context starts with a line like Context exceeds the 200k-token limit by 94k tokens — run /compact or /clear to continue., the window is already exceeded and every request fails with this error until you free space.
[5] If you turned auto-compact off, turn it back on. It is on by default and normally prevents this error. Enable Auto-compact in /config, or remove the DISABLE_AUTO_COMPACT environment variable. If you keep it off, run /compact yourself before the window fills.
[6] If the error hits near 200K tokens on a model with a larger window, one possible cause is a model ID that Claude Code does not recognize. Check the model ID you actually use, and whether a warning such as Model "<model>" isn't recognized · context assumed to be 200k tokens appeared. In that case Claude Code assumes a 200K window for the unknown ID, so set the model's real context window. With a gateway in ANTHROPIC_BASE_URL and a message starting with Prompt is too long · automatic compaction failed, set the window or update to v2.1.299 or later.
[7] Some cases are version bugs. The official docs list two.
| Symptom | Fix |
|---|---|
| The error right after you stopped Claude while it was compacting | The conversation is unchanged; run /compact and resend. Update to v2.1.304 or later to prevent it |
| v2.1.305, many MCP tools, direct Anthropic API connection | This error can hide an unrelated 400 or 422. Update to v2.1.306 or later to see the original error |
If compaction works but the context refills at once and you get Autocompact is thrashing, see that error's post. Request too large above 32MB is a byte limit, not a token limit; see 413 request_too_large.