Claude Code "Prompt Is Too Long": Fix It with /compact, /context and Less Context

What Prompt is too long means, whether to wait, and what to check first.

Language: English · 日本語版

Fix a setting, login or environment Official documentation checked on

Wait or fix?

Fix it in the session; waiting will not help. The conversation plus attached files exceeds the model's context window, so the same request fails again until less is sent. The usual fix takes seconds: /compact summarizes earlier turns, and /clear starts fresh. If the error comes back right after a clear, the space is taken by what Claude Code sends with every request, such as tool definitions, memory files and attachments, and that is what to trim.

Messages you may see

  • Prompt is too long
  • Context limit reached · /compact or /clear to continue
  • Prompt is too long · automatic compaction failed: <the underlying error>
  • Input is too long for requested model.

The exact wording changes a little between Claude Code versions and providers.

What the message means

Auto-compact is on by default and normally prevents this error by summarizing your oldest exchanges and keeping the newest. In an interactive session the error appears as "Context limit reached · /compact or /clear to continue", and the line also tells you when auto-compact is off. Amazon Bedrock reports the same condition as "Input is too long for requested model." When automatic compaction ran and failed on another error, such as an unavailable model or an authentication failure, the message names that error after a separator, and /compact keeps failing until you resolve it. A conversation with a single exchange has nothing earlier to summarize, so Claude Code explains what fills the request instead.

Common causes

  • A long conversation with large file reads or pasted logs.
  • Tool definitions from MCP servers you are not using.
  • Large CLAUDE.md memory files that load on every request.
  • Auto-compact turned off in /config or with DISABLE_AUTO_COMPACT.
  • A custom model ID through a gateway, where Claude Code assumed a context window that differs from the real one.

Check in this order

  1. Run /compact. If it answers "Not enough messages to compact.", run /clear and resend with less pasted text or smaller attachments.
  2. If the message says automatic compaction failed, fix the error it names first, then run /compact again.
  3. Run /context to see what is using the window: system prompt, tools, memory files and messages.
  4. Disable MCP servers you are not using with /mcp disable <name>, and trim large CLAUDE.md files or move instructions into path-scoped rules that load only when relevant.
  5. If you turned auto-compact off, turn it back on in /config. If you keep it off, run /compact yourself before the window fills.
  6. If Claude Code warned that it does not recognize your model ID, give it the model's real context window as the model configuration page describes.

We took the fixes from the official pages below and put them in order, with the quickest and most likely ones first.

How it differs from similar errors

  • "Request too large (max 32MB)" is about the size of the raw request body, mostly attachments. That limit is separate from the context window.
  • "Response exceeded the output token maximum" is about the length of Claude's reply, not your input.
  • "You've hit your session limit" is about your plan's allowance, not the size of one conversation.

Related errors

Official sources

Unofficial page. Not affiliated with, endorsed by, or sponsored by Anthropic, PBC. Claude and Claude Code are trademarks of Anthropic, PBC. Messages and fixes change with updates, so read the official pages as well.

Back to the error list (10 errors)