Claude Code "Prompt is too long": causes and fixes

Claude Code says "Prompt is too long" when the request (system prompt, CLAUDE.md, tool definitions, the conversation and whatever you just pasted or attached) no longer fits the model's context window. The exact wording of the message points to the cause, and the cause decides the fix.

Contents

Claude Code says "Prompt is too long" when the request it is about to send no longer fits the model's context window. That request carries more than your conversation: the system prompt, CLAUDE.md, MCP tool definitions, every earlier turn and the file or paste you just added. The wording of the message points to the part that is too big, or to a second error behind it, and that decides the fix.

What "Prompt is too long" means in Claude Code#

Anthropic's error reference gives the cause in one line: "The conversation plus attached files exceeds the model's context window." In an interactive session you usually see Context limit reached · /compact or /clear to continue. With auto-compact turned off in /config, the line ends auto-compact is off · /config to turn it on. With DISABLE_COMPACT set, it offers only /clear. Amazon Bedrock words the error Input is too long for requested model., and Claude Code has treated that the same way since v2.1.217.

What you see What it tells you Start with
Context limit reached · /compact or /clear to continue The conversation filled the window /compact with a focus
…this conversation's own content is most of it. A single-exchange conversation cannot be compacted One prompt, paste or file is too big Rewind and send less
…the rest is system prompt, tool definitions, and attachment content What loads at startup leaves no room /context, then trim
Prompt is too long · automatic compaction failed: <the underlying error> Compaction itself hit another error Fix the named error
Autocompact is thrashing: the context refilled to the limit... A file or tool output refills the window after each compact Read it in parts

Fix "Context limit reached" in a long conversation#

A long session with many file reads, where auto-compact didn't get there first, is the usual case.

  1. Run /compact with a focus, for example /compact keep the plan and the failing test. The focus decides what the summary keeps. Without one, it keeps what the model guesses matters.
  2. To keep your recent turns word for word, open /rewind, pick an earlier prompt and choose Summarize up to here. Only the part before that prompt becomes a summary.
  3. If you've moved on to other work, run /clear. The old conversation isn't deleted: /resume brings it back.

/compact vs /clear in Claude Code lists what a summary keeps and loses, and when to clear instead. If the answers were already slipping before the error, the same full window is behind it (why Claude Code gets worse in long sessions).

Fix it when one paste or file is too big#

A single-exchange conversation cannot be compacted means there is nothing earlier to summarise, and /compact answers Not enough messages to compact. for the same reason. We ran into this ourselves: a pasted log of several MB went into a Claude Code chat inline, and compacting failed the same way the message had.

  1. Press Esc twice on an empty prompt, or run /rewind. Pick the prompt that carried the paste and choose Restore conversation. The conversation goes back to before it, and the prompt returns to the input field for you to cut down. How to undo Claude Code changes covers the other restore options.
  2. Save the log or dump to a file and ask Claude to read only what matters: a line range, one function, the lines around an error.
  3. Hand big reads to a subagent. A subagent works in its own context window, and only its result comes back into yours.
  4. If that message was the whole session, run /clear and send a smaller version.

Fix it when the startup load is the problem#

Two forms of the message put the blame elsewhere: the rest is system prompt, tool definitions, and attachment content, and the request size comes mostly from system prompt, tool definitions, or attachments. Your own text isn't the issue. Run /context and compare the Messages row with the rows above it. If those rows add up to more, trim what loads before you type:

  1. /mcp disable <name> turns off a server you aren't using and takes its tool definitions out of context. With tool search, many servers already cost little; too many MCP servers shows when they still fill the window.
  2. Shorten a long CLAUDE.md, or move instructions into path-scoped rules, which load only when Claude works on matching files.
  3. Check that auto-compact is on in /config and that DISABLE_AUTO_COMPACT isn't set.

When compaction fails or thrashes#

After automatic compaction failed: comes a second error, such as an unavailable model or a failed sign-in. The error reference sets the order: "Resolve the named error first; /compact fails on the same error until you do."

An error near 200K tokens on a model that accepts more can mean Claude Code doesn't recognise your model ID and assumes a 200K window. The fix is to give it the real window. With a custom ANTHROPIC_BASE_URL and the compaction-failed form, v2.1.299 or later also fixes it. Claude Code's 1M context window lists which models have 1M and what a turn that size costs.

Autocompact is thrashing means compaction worked, but a file or tool output filled the window again straight after, several times in a row, and Claude Code stopped trying. Anthropic's troubleshooting page gives four ways out:

  1. Read the file in smaller chunks.
  2. Compact with a focus that drops the output: /compact keep only the plan and the diff.
  3. Move the large-file work to a subagent.
  4. Run /clear.

If it comes back after /clear, run /context and read the startup rows as above.

How Shuriken handles it#

A Claude Code chat in Shuriken is Claude Code itself, so it hits the same limit for the same reasons. Click the context meter in the composer for a map of that chat's window, in the rows /context uses (Messages, MCP tools, Memory files, Skills). The map carries hints such as turning one MCP server off for this chat only, and its Compact button takes an optional "Keep…" focus.

You can also fork a chat from any of the agent's replies: pick the reply just before the oversized message. The fork opens as a new chat with the conversation up to there attached as "Chat history". Your messages and the replies come in full, and each file read or command as a one-line summary. The big file reads and tool output stay behind, and the original chat is left as it was. To try it on your own projects, download Shuriken.

Sources

  1. Error reference: Prompt is too long (Claude Code docs) (accessed 24 October 2026)
  2. Troubleshooting: auto-compaction stops with a thrashing error (Claude Code docs) (accessed 24 October 2026)
  3. Checkpointing: rewind and summarize (Claude Code docs) (accessed 24 October 2026)
  4. Explore the context window (Claude Code docs) (accessed 24 October 2026)
  5. Subagents: each runs in its own context window (Claude Code docs) (accessed 24 October 2026)
  6. Model configuration: correct the window for a gateway or custom model ID (Claude Code docs) (accessed 24 October 2026)

Frequently asked questions

Why does /compact say Not enough messages to compact?

Because the conversation is a single exchange, and there is nothing earlier to summarise. That one prompt and what Claude Code sends with every request take the space, so run /clear and send it again with less pasted text or smaller attachments.

What does Input is too long for requested model mean in Claude Code?

It is how Amazon Bedrock words the same error. From v2.1.217 Claude Code treats it like Prompt is too long, so auto-compact runs on it; on older versions /compact failed with the same message.

Can auto-compact being off cause Prompt is too long?

Yes. Auto-compact is on by default and normally keeps this error away; with it off in /config, the error line ends auto-compact is off · /config to turn it on. Turn it back on there, or unset DISABLE_AUTO_COMPACT if that turned it off, and if you keep it off, run /compact yourself before the window fills.

Will a 1M context window stop the error?

It raises the limit, but a big enough paste, file or tool output can still go past it. Compaction works the same way at the larger limit, and so do the fixes on this page.

Free tools