Claude Code’s Prompt is too long error means the input being sent exceeds the context limit. The current interactive interface may instead show Context limit reached. First distinguish a long history that can be compacted from an initial input that is already too large. The following shows example error messages; the numbers are illustrative.

Prompt is too long

# Example API error message:
prompt is too long: 233153 tokens > 200000 maximum

Input includes more than the text you just typed: conversation history, files read, tool results, and instructions can all contribute. In 233153 tokens > 200000 maximum, the input has 233,153 tokens against an allowance of 200,000. The context window itself covers both input and the output generated for this response; this error means the input alone already 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, but does not guarantee that every overflow will be prevented. Based on the official Claude Code error documentation and API specifications checked on September 21, 2026, this article explains causes, recovery steps, and the conditions for 200K and 1M. Direct API use is covered separately.

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. But a huge paste, disabled automatic compaction, or an authentication error during compaction can still stop it. Rereading the same huge file immediately after summarizing can fill the window again. Do not diagnose the cause solely from whether automatic compaction is enabled. Read the complete error and check what was loaded immediately beforehand.

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

The claim that connecting MCP always loads every tool’s detailed definition at startup does not describe the current default. Definitions may load upfront when Tool Search is disabled, preloading is configured, or the connection does not support it. Check your connection’s conditions in the official Tool Search configuration table. Looking at /context is more useful than estimating overhead from the number of servers alone.

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.” 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, but has availability conditions. 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, check the model’s capacity, the capacity Claude Code uses for your connection, the automatic-compaction threshold, and pricing conditions separately. Use /status to check the current model and account, and /model to see available choices.

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, 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.

For subscriptions, Opus 1M is included with Max, Team, and Enterprise, while Opus 1M on Pro and Sonnet 4.6 1M on subscriptions require usage credits. Sonnet 5 connected directly to the Anthropic API is handled differently: 1M is the default on all plans, 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, the official explanation is that there is not enough room for the generated summary. Empty the input box, press Esc twice, then choose a turn before the large input from the list to rewind the conversation. Pressing twice does not automatically rewind several turns. If you choose an action that also rewinds code, check its scope. Retry compaction afterward; if that still does not free enough space, use /clear and restart with smaller input. See the official keyboard controls for the conditions.

If automatic compaction failed is followed by authentication failure or an unavailable model, fix that cause before trying to free the window. Not enough messages to compact. means there is too little earlier conversation to summarize: reduce attachments or pasted content rather than repeating compaction. 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. For API use, inspect 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, confirm that a small request receives 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. Check the error text or the API’s stop_reason, rather than deciding solely because a response appears cut off.

SymptomMeaningMain response
Prompt is too long / 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, check 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.

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: normally leave automatic compaction enabled. If you recall disabling it, check /config and the applied settings. 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 that the window Claude Code assumes matches the connection’s actual capacity. Increasing a number in configuration does not enlarge the model’s real window. Review the official custom-model settings with your administrator.

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.

MCP’s detailed definitions load on demand by default. Inspect the current contents with /context instead of judging overhead by server count alone. For 1M, check model, connection, and plan conditions; keep capacity, pricing, and automatic-compaction thresholds separate. For direct API use, inspect 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. Possible causes include huge input, no earlier conversation to summarize, compaction failure, or the window filling again immediately after summarizing. Do not reduce the diagnosis to two possibilities: read the full error and check recent reads. If a cause such as authentication failure is reported, resolve it first.

Q. /compact also fails with “Conversation too long.”
A. The official explanation is that there is not enough room for the summary. Empty the input box, press Esc twice, choose an earlier turn from the list to rewind the conversation, then retry. If that does not free enough space, record what matters and start with smaller input after /clear. Check the scope before choosing an action that rewinds code.

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, use /context. This differs from cumulative consumption or plan allowances in /usage. Some MCP definitions load on demand, so do not judge overhead solely by connection count. For the API, estimate the request with the target model’s token-counting API.