Claude Code "Prompt is too long: N tokens > 200000 maximum"
Last checked
The error
Context limit reached · /compact or /clear to continue
Prompt is too long
Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 208310 tokens > 200000 maximum"}}Current interactive Claude Code shows the first line. Non-interactive (-p) output and the transcript show Prompt is too long. The raw API form with token counts is from issue #12186.
"Prompt is too long" means the request Claude Code sent (conversation, system prompt, tool definitions, CLAUDE.md files and attachments) no longer fits in the model's context window, for example 208310 tokens against a 200000 limit. Run /compact to summarize earlier turns, or /clear to start fresh. Then run /context to see what is filling the window and cut it down.
Why it happens
Every request carries the whole conversation plus everything Claude Code sends with it. When that total passes the model's context limit, the API rejects it with a 400 before Claude reads a word.
- A long session with auto-compact turned off. Auto-compact is on by default and normally prevents this error, but it can be disabled in /config (autoCompactEnabled) or with the DISABLE_AUTO_COMPACT environment variable.
- Huge tool output or pasted content. A large file read, a log dump or a big paste can fill most of the window in one turn.
- Fixed overhead from MCP tool definitions and memory files. Every connected MCP server adds its tool schemas to every request, and large CLAUDE.md files load on every turn.
- A single exchange that cannot be compacted. If the first prompt alone is too big, there is nothing earlier to summarize, and the message says the conversation is a single exchange and cannot be compacted.
- Auto-compaction itself failed. The message then reads Prompt is too long · automatic compaction failed: followed by the underlying error, such as an unavailable model or an auth failure.
The fix
- 1 Run /compact to summarize earlier turns and free space. If it answers Not enough messages to compact., use /clear instead.
- 2 Run /clear to start a fresh conversation when the current one is no longer worth keeping.
- 3 Run /context to see what is consuming the window: system prompt, tools, memory files and messages.
- 4 Disable MCP servers you are not using with /mcp disable <name> so their tool definitions leave the context.
- 5 Trim large CLAUDE.md files, or move instructions into path-scoped rules that only load when relevant.
- 6 Reference big files by path instead of pasting them, and turn auto-compact back on in /config if you disabled it.
/compactWhen compacting cannot help
If the message says automatic compaction failed, fix the named error first. /compact fails on the same error until you do.
If it says the conversation is a single exchange, the space is taken by that one prompt plus the system prompt, tools and attachments. Run /clear and resend with less pasted text or smaller attachments, or cut tools and memory files first.
To step back past the turn that added a huge paste, press Esc twice (or run /rewind) and pick an earlier point.
Still failing?
- Run /context again after /compact; if the system prompt, tools and memory files alone are close to the limit, compacting messages will not be enough.
- On Amazon Bedrock the same condition reads Input is too long for requested model., so update Claude Code if auto-compact never triggers on it.
- If you see Request too large (max 32MB) instead, that is the 32MB raw request size limit, usually from accumulated images, not the token limit.
Related errors
Hit a different error?
Paste any agent error and get the cause and fix in seconds.
Frequently asked questions
Why does this happen on a short prompt in a new session?
The window also holds the system prompt, MCP tool definitions, CLAUDE.md files and attachments. Run /context to see their size; disabling unused MCP servers usually frees the most.
Is /compact or /clear better?
/compact keeps a summary of the conversation so you can carry on. /clear drops everything and starts fresh. Use /clear when the session has drifted or the summary would be mostly noise.
Can I stop it happening again?
Keep auto-compact on, reference files by path rather than pasting them, and keep CLAUDE.md short. If you keep auto-compact off, run /compact yourself before the window fills.
Stop firefighting agent errors
Decoding errors one at a time is the manual version of what BetterClaw automates. Run your agents on a no-code AI agent platform with managed models, retries and config validation built in.
Free plan available · Pro $49/mo · BYOK · 7-day money-back guarantee
