Claude Code’s Prompt is too long error means the input being sent exceeds the context window. In the interactive interface, the basic form is a single line starting with Context limit reached, while the longer forms that name a cause keep the Prompt is too long · wording. The second half of the string varies with the situation, and that is where it tells you what to do next. Compare the string on your screen with the list below.

# Interactive interface (usual)
Context limit reached · /compact or /clear to continue

# Interactive interface (auto-compact turned off)
Context limit reached · /compact or /clear to continue · auto-compact is off · /config to turn it on

# Interactive interface (compaction disabled entirely with DISABLE_COMPACT)
Context limit reached · /clear to continue

# -p output and the transcript
Prompt is too long

# Automatic compaction failed with another error
Prompt is too long · automatic compaction failed: <the underlying error>

# A single-exchange conversation with no history to summarize
Prompt is too long · this conversation is a single exchange and cannot be compacted — …
Prompt is too long · the request is ~<N> tokens (limit <limit>) … A single-exchange conversation cannot be compacted; …

# Through Amazon Bedrock
Input is too long for requested model.

# /compact itself fails (Section 4)
Error during compaction: Conversation too long. Press esc twice to go up a few messages and try again.

# API response body (numbers are an example)
prompt is too long: 209117 tokens > 200000 maximum

How to recover now →

Input includes more than the text you just typed: conversation history, files read, tool results, and instructions can all contribute. In the API body, 209117 tokens > 200000 maximum means the input of 209,117 tokens exceeds the 200,000-token limit. The context window itself covers both input and the output generated for this response; this error means the input alone exceeds the limit. Recovery differs from a usage limit reached by exhausting your plan’s allowance for a period.

Use /compact for a long history, reduce the input if the first message is too large, and resolve any reported cause of compaction failure first. Those are the basic recovery paths. Automatic compaction is enabled by default and normally prevents this error; when the error appears anyway, these three cases are where the paths divide. Based on the official Claude Code error documentation and API specifications as of September 21, 2026, this article explains causes, recovery steps, and the conditions for 200K and 1M. Direct API use is covered separately.

Claude Code

The same “too long” error can require different reductions

During a long conversation

Summarize earlier history. If the window fills again immediately after compaction, split up the large reads.

Initial input already too large

There is no earlier conversation to summarize. Start with smaller pastes, attachments, instructions, and tool overhead.

Compaction itself fails

First resolve the accompanying cause, such as authentication failure or an unavailable model. Repeating compaction alone will not fix it.

Use /context for the window breakdown and /usage for consumption over a period or plan allowances. Both involve tokens, but measure different things.

1. What this error means

The context window is the limit on how much information a model can reference and generate in one response. It is measured in tokens, not characters, and includes input as well as this response’s output and thinking tokens. Input read from the API cache still occupies the window. Caching changes pricing or processing; it does not make that input take zero space. See Anthropic’s context-window specification.

Within that limit, Prompt is too long occurs when the input being sent already fails to fit the window by itself. Even a short question can belong to a large request if earlier history or files accompany it. That is why shortening only the latest question may not help. For the basics, see What is a context window?

As the limit approaches, Claude Code clears older tool output and summarizes the conversation if needed. What still stops it is a huge paste, disabled automatic compaction, or a failure of compaction itself. Rereading the same huge file immediately after summarizing can also fill the window again. The second half of the string at the top tells you which case you are in. automatic compaction failed: is followed by the cause of the compaction failure, single exchange means there is no history to summarize, and auto-compact is off means automatic compaction is turned off.

2. What fills the context window?

The following breakdown follows the explanation of how Claude Code works. A saved conversation log is not identical to what is currently sent to the model. Removing older tool results or summarizing changes the contents of the active window.

ComponentWhat enters the windowWhat to review
Conversation historyExchanges sent in the current request. Compaction replaces some parts with a summary/compact for the same task; /clear for an unrelated next task
Files and tool resultsFile content read, search results, command output, and similar materialNarrow searches, read only relevant lines, or delegate detailed research to a subagent
MCPTool names and server instructions. By default, Tool Search loads detailed definitions when neededCheck actual overhead with /context and disable unused servers through /mcp
CLAUDE.md and memoryApplicable instructions and memory that has been loaded. Not every automatic-memory file is always presentKeep standing rules short and separate explanations needed only for specific tasks
SkillsNormally, descriptions at startup and bodies when used. Settings can defer descriptions tooReview unnecessary automatic-invocation candidates and overly long skill bodies
System instructionsOperating instructions supplied by Claude Code or the connection environmentStart with instructions, attachments, and tools that you control

By default, Tool Search loads MCP tool definitions only when they are needed. At session start, only tool names and server instructions go in, so adding servers has little effect on the window. Definitions load upfront when you set ENABLE_TOOL_SEARCH=false, specify alwaysLoad for a server, or set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS, among other cases. When you route through a gateway with ANTHROPIC_BASE_URL, Tool Search is on by default from v2.1.304 onward (see the official Tool Search configuration table for the full list). Check the actual overhead with /context, not by server count.

Subagents investigate in a separate window and can return results without bringing all intermediate tool output into the parent conversation. However, the summary or conclusions they return still use the parent’s window. Asking them to reproduce the entire investigation reduces the benefit. Specify the output you need, such as “Return only relevant files and lines, conclusions, and unresolved questions.” Subagents also inherit every MCP tool definition from the parent, so the official error documentation recommends disabling MCP servers you are not using before spawning subagents. The design principles are covered in context engineering.

Use /context for occupancy of the current window and /usage for token consumption and plan usage. The latter’s cost display is an estimate, not a finalized bill. In supported environments, /skill-doctor can also inspect skill overhead. If you cannot find it, start with /context. See What is using your context? for measurement steps and the official command list for availability conditions.

3. Context window sizes: 200K and 1M

200K means 200,000 tokens; 1M means one million. However, the model’s capacity, the capacity Claude Code uses for your connection, the automatic-compaction threshold, and pricing conditions are separate numbers. See the current model and account with /status, and the available choices with /model.

Separate capacity from conditions of use

Examples using 200K

Models such as Sonnet 4.5. Claude Code may also treat a 1M-capable model as 200K because of its connection or a setting that disables 1M.

Examples using 1M

Examples on the Anthropic API include the Fable family, Sonnet 5 or later, and Opus 4.7 or later. Some use 1M by default; adding [1m] is not always required.

Source: Anthropic’s model configuration and extended context. The point at which automatic compaction starts varies by settings and model.

On subscriptions, usage credits come into play only for Opus 4.6 and Sonnet 4.6, which reach 1M through their [1m] variant. Opus 4.6 with 1M is included with Max, Team, and Enterprise but requires usage credits on Pro; Sonnet 4.6 with 1M requires usage credits on every subscription. The Fable family, Sonnet 5 or later (including the current Sonnet 5.5), and Opus 4.7 or later connected directly to the Anthropic API are handled differently: 1M is the default on all plans, including Pro, without additional usage credits or selecting [1m]. Gateways and settings that disable 1M introduce exceptions, so do not decide from the model name alone.

“Standard pricing” for 1M means there is no additional long-context per-token premium for exceeding 200K. It does not mean unlimited extra input for the same total price. Processing more tokens increases usage. Whether 1M is included in your plan or billed through credits is another separate question.

The ratio between characters and tokens also varies by model and content. Rather than assuming every newer model adds a fixed percentage, use token counting for the target model when working with the API. Some tasks need a larger window, but removing irrelevant logs and duplicate instructions first makes it easier to judge the capacity actually needed.

4. How to recover now

Choose a recovery step according to what happened: a growing history or a large file added to the input. The following options are ordered by priority.

FIXES

Steps to free space in the window

1. /compact (when there is history)
Summarize conversation history to free space. You can specify a focus, such as /compact Focus on the authentication bug. This reduces the load while preserving context.
2. /clear (when moving to another task)
Give the conversation a fresh start. Record necessary decisions first. This does not delete the project’s files.
3. Move large reads out of the main conversation
Read huge files by line range, or ask a subagent to investigate in its own window and return only conclusions.
4. Reduce content loaded repeatedly
Check the breakdown with /context, then disable unnecessary MCP servers and shorten CLAUDE.md. Separate detailed procedures so they are read only when needed.
5. Use a 1M model if the task genuinely needs it
For tasks that truly need a large window, such as working across a huge codebase, use /model to select a model with 1M context. First do the cleanup in steps 1–4. Do not disable automatic compaction; leave its default enabled.

Use 1 for a long history and 2 for an unrelated next task. For oversized initial input, use 3 and 4. If a root cause of compaction failure is reported, fix that first.

If /compact fails with Error during compaction: Conversation too long, there is not enough room for the generated summary. Press Esc twice with the input box empty (or run /rewind) to open the rewind menu, then choose a message before the large input to rewind the conversation. To rewind only the conversation and keep the current code, choose Restore conversation. Then retry compaction; if that still does not free enough space, use /clear and restart with smaller input. The earlier conversation is saved, and you can reopen it with /resume. The menu options are described in the official rewind documentation.

If automatic compaction failed: is followed by authentication failure or an unavailable model, fix that cause before trying to free the window. Until you do, /compact fails with the same error. When /compact answers Not enough messages to compact., the conversation is a single exchange with nothing earlier to summarize. Run /clear, then resend with less pasted text or smaller attachments. If the window fills immediately after compaction, narrow the recent large logs or files to the parts you need.

If you call the API directly

/compact and /clear are Claude Code operations, not control commands sent to the Messages API. When the input alone exceeds the window, the API returns a 400 invalid_request_error ("prompt is too long"). Review the messages, system, tools, and attachments you send, and estimate input with the target model’s token-counting API. Reduce the request itself: summarize older history, narrow documents to relevant sections, or remove unnecessary definitions. Avoid cutting the request in a way that breaks the pairing between tool calls and results. API-side compaction is also available for long conversations, but its supported models and settings are separate from Claude Code commands.

After recovery, make sure a small request gets a response, then add necessary information back gradually. Resending the same huge input and waiting will not increase capacity. For routine cleanup, see saving tokens in Claude Code.

5. Distinguishing similar errors

Oversized input, a configured output limit, a window limit reached during generation, and usage over a period are different issues. Tell them apart by the error text or the API’s stop_reason, not by a response that merely looks cut off.

SymptomMeaningMain response
Prompt is too long / Context limit reached / N tokens > M maximumThis article’s subject: input exceeds the context window/compact, /clear, delegate large reads to a subagent, or use a 1M model
Response stops early (stop_reason: max_tokens)Output reached the request’s max_tokens settingFor the API, review the output setting and model limit; or ask for a continuation
stop_reason: model_context_window_exceededInput plus output reached the window limit during generationReduce input to leave room for output
usage limit reachedThe plan’s usage allowance is exhausted, unrelated to the token windowWait for reset; see handling usage limits
Usage credits required for 1M contextAn access issue: the selected 1M context is not included in your plan, not input overflow or an exhausted allowanceEnable credits and restart, or use /model to return to the standard window

According to Anthropic’s API specification, Claude 4.5 and later accept a request when input itself fits, even if input plus the requested max_tokens exceeds the window. Reaching the window limit during generation produces model_context_window_exceeded, so a short response alone does not prove it stopped because of max_tokens. For other problems, see common Claude Code errors.

Related: when the Codex app still shows the history but only sending fails, that is a conversation-state problem, not an input-size one, and is covered in Codex “thread not found”: troubleshooting and a recovery case.

6. Prevention checklist

Before working: inspect what is loaded with /context. Narrow large documents through search or line ranges instead of pasting them in full. When splitting research, specify the scope of conclusions the subagent should return too.

While working: leave automatic compaction on, as it is by default. If the error line says auto-compact is off, turn it back on in /config. If you turned it off with the DISABLE_AUTO_COMPACT environment variable, that hint does not appear, so remove that setting. Also check whether each compaction is followed by rereading the same material. More frequent manual compaction is not automatically better: when to run /compact and specifying which decisions to retain both matter.

Between tasks: before an unrelated task, save necessary information to files and use /clear for a new conversation. The earlier conversation is saved, but resuming the same huge history to recover may bring back the cause. Keep only rules needed every time in CLAUDE.md’s standing instructions.

Custom connections: if you use a gateway or custom model ID, check whether the window Claude Code assumes differs from the connection’s actual capacity. Increasing a number in configuration does not enlarge the model’s real window. How to align them is covered in the official custom-model settings.

Summary

Prompt is too long means the complete input, including history and attachments, does not fit—not just the sentence you typed last. Choose by situation: /compact for a long history, reduce oversized initial input, or resolve the root cause of a compaction error.

The second half of the error string (automatic compaction failed:, single exchange, or auto-compact is off) tells you which case you are in. MCP’s detailed definitions load on demand by default, so judge overhead with /context, not by server count. For 1M, capacity, pricing, and the automatic-compaction threshold are each determined by model, connection, and plan. For direct API use, review the request and stop reason rather than relying on Claude Code commands.

FAQ

Q. Are “Prompt is too long” and “usage limit reached” the same?
A. No. The former means input exceeds one request’s context limit; the latter concerns the plan’s usage allowance. For oversized input, reduce what you send. /clear does not restore your plan allowance.

Q. Why does this happen with automatic compaction enabled?
A. The causes are huge input, no earlier conversation to summarize, compaction failure, or the window filling again immediately after summarizing. The second half of the error string tells them apart. If automatic compaction failed: is followed by a cause such as authentication failure, resolve that first. If it says single exchange, run /clear and start with smaller input.

Q. /compact also fails with “Conversation too long.”
A. There is not enough room for the summary. With the input box empty, press Esc twice to open the rewind menu, rewind the conversation to a message before the large input, then retry. To keep your code, choose Restore conversation. If that does not free enough space, record what matters and start with smaller input after /clear.

Q. Will switching to a 1M model solve it?
A. It can help if the required input fits the new window, but availability conditions vary by model, connection, and plan. Standard per-token pricing for 1M does not mean the same total cost for more processing. Reducing unnecessary history and huge outputs first makes it easier to judge the required capacity.

Q. How can I see what is using the window?
A. In Claude Code, see the breakdown with /context. This differs from cumulative consumption or plan allowances in /usage. MCP definitions load on demand by default, so the number of connections alone does not tell you the overhead. For the API, estimate the request with the target model’s token-counting API.