On this page
When Claude Code reports Prompt is too long, the official error reference defines the condition this way: "The conversation plus attached files exceeds the model's context window." That is a context-window problem, not a plan quota running out, and not a 529 Overloaded outage. The same runtime error is documented for the CLI, the Desktop app, and cloud sessions, which share this error reference.
The steps below follow Anthropic's official Claude Code documentation. We haven't run Claude Code on our own machines, and we haven't reproduced this error. Figures such as 94k, 200k, 967K, 32MB, or about 1,000 tokens appear only as they do in the official docs, not as measurements from this site.
What the message looks like
The baseline wording is Prompt is too long. In an interactive session the same condition is usually shown as:
Context limit reached · /compact or /clear to continueIf DISABLE_COMPACT is set, that line names only /clear. Longer forms still start with Prompt is too long ·. In -p output and in the transcript, the text stays Prompt is too long. When auto-compact has been turned off in user settings, the interactive line also says so:
Context limit reached · /compact or /clear to continue · auto-compact is off · /config to turn it onThe Auto-compact toggle in /config writes autoCompactEnabled to user settings. Official docs say this hint appears only when a /config change would take effect: not when DISABLE_AUTO_COMPACT or DISABLE_COMPACT turned auto-compact off, and not when a higher-precedence scope such as project or managed settings set autoCompactEnabled to false. Before v2.1.235, the line carried no auto-compact hint.
Amazon Bedrock reports the same condition as Input is too long for requested model., and Claude Code handles it the same way. Before v2.1.217, that phrasing was not recognized, so auto-compact never triggered on it and /compact failed with the same error. A Claude apps gateway may report capability_rejected: prompt_too_long when a cloud upstream rejects the request in the provider's own error shape; Claude Code treats that token the same as Prompt is too long. Before v2.1.228, the token was not recognized, so auto-compact did not trigger on it.
When automatic compaction already ran on the turn and failed on an underlying error, such as an unavailable model or an authentication failure, the message is Prompt is too long · automatic compaction failed: <the underlying error>. Official guidance is to resolve the named error first; /compact fails on the same error until that is done. Before v2.1.229, a failed automatic compaction surfaced the bare Prompt is too long, without the cause.
Official first steps: /compact or /clear
The official "What to do" list starts with /compact, which summarizes earlier turns and frees space, or /clear, which starts a new conversation. /clear empties the conversation context; project memory remains. The commands page lists /reset and /new as aliases of /clear. /compact continues the same conversation; /clear starts over. /compact [instructions] can take optional focus instructions. /clear [name] can label the previous conversation for later use in /resume.
If /compact answers Not enough messages to compact., the conversation is a single exchange with nothing earlier to summarize, so the space is taken by that one prompt and by what Claude Code sends with every request. Official next steps are to run /clear and resend with less pasted text or smaller attachments, or to reduce tool definitions and memory files as described below.
If the error appears right after Claude was stopped while compacting, official docs say the conversation is unchanged and still large enough to need compacting. The recovery is to run /compact and send the message again, and to update to v2.1.304 or later; before that version, stopping at that moment could end the turn with this error. On v2.1.305, with many MCP tools and a direct connection to the Anthropic API, this error can hide an unrelated 400 or 422; official docs recommend updating to v2.1.306 or later so the original error is visible.
How /context shows what filled the window
/context shows a colored-grid breakdown of window usage, with suggestions for context-heavy tools, memory bloat, and capacity warnings. The debug-configuration page groups that breakdown by system prompt, system tools, MCP tools, custom subagents (with the source each loaded from), memory files, skills, and conversation messages. In fullscreen mode the per-item breakdown collapses; /context all expands it. Subdirectory CLAUDE.md files load on demand rather than at session start, so they do not appear in the session-start breakdown.
When the conversation has already grown past the model's context window, /context puts a warning at the top of its output. The 200k and 94k figures in the following line are from an official documentation example, not a reading from this site or from any particular machine:
Context exceeds the 200k-token limit by 94k tokens — run /compact or /clear to continue.After a Context exceeds warning, official docs say a next message can be sent while auto-compact is on, which is the default. If that still fails and becomes Prompt is too long, the Prompt is too long entry applies. While auto-compact is off, the recovery is to run the /compact command named in the warning, or /clear to start over. Until one of those runs, messages fail with Context limit reached, or with Prompt is too long in -p output. When the limit exceeded is a compaction window, such as the 200K boundary on 1M-context models, the warning is worded differently, because a compaction window can sit below the model's context window and requests past it can still succeed. This is also an official documentation example:
Context is 94k tokens past the 200k-token compaction window — run /compact to reduce usage.Both forms name /clear instead of /compact when DISABLE_COMPACT is set. Before v2.1.216, /context showed usage above 100% with no warning line explaining the meaning or the recovery.
Unused MCP servers and large CLAUDE.md files
The official list includes /mcp disable <name> to turn off unused MCP servers and remove their tool definitions from context. /mcp can also disable a named server, or all servers, without opening the interactive list. A first-time MCP setup belongs in How to Set Up MCP Servers in Claude Code (November 2026), not in the steps for this error.
Large CLAUDE.md files should be trimmed, or moved into path-scoped rules that load only when relevant. The memory page says to target under 200 lines per file: longer files consume more context and may reduce adherence. A file over 4 MiB is skipped entirely. Imports with @path help with organization but do not reduce context cost, because imported files load together with the CLAUDE.md that imports them. A warning appears at startup and in /status when a single file is over the recommended length, and also when several files that are each within that length add up past a combined limit at session start. On-demand subdirectory CLAUDE.md files and rules files also have a character cap that depends on the session window: 40,000 characters for a 200K window; for a 1M window, 200,000 characters on Claude Opus 4.6 and Claude Sonnet 4.6, and 150,000 characters on later models. Only the start of a file over that cap is sent. Before v2.1.309, that limit was not applied to files that load on demand.
Auto-compact is on by default
autoCompactEnabled appears in /config as Auto-compact and defaults to true. Set to false, Claude Code does not compact automatically; manual /compact remains available, and idle compaction turns off as well. DISABLE_AUTO_COMPACT=1 turns off automatic compaction and idle compaction, leaves manual /compact available, and overrides autoCompactEnabled. Official settings text says that whichever of the two turns auto-compact off, the other cannot turn it back on. DISABLE_COMPACT=1 disables all compaction, including automatic compaction and manual /compact; interactive hints then name /clear rather than /compact.
Auto-compact is on by default and, according to the official docs, normally prevents this error. If it was turned off in /config or with DISABLE_AUTO_COMPACT, the documented recovery is to turn it back on. If it stays off, /compact has to be run manually before the window fills. The commands page also lists /autocompact [auto|<tokens>], which sets the auto-compact window, for example 500k, or auto to return to the window tuned for the model. With no argument, a dialog shows the current window. The command requires Claude Code v2.1.221 or later. The context-window page also lists earlier options before an automatic pass: a focused /compact, /rewind to summarize only part of the conversation, /autocompact 500k and similar values to compact earlier, /clear when switching to unrelated work, and handing large file reads to a subagent.
When automatic compaction runs on this error, it normally summarizes the oldest exchanges and keeps the newest. As a last resort, if no whole exchange can be summarized, the newest prompt is kept word for word and everything before it is summarized; if in that case the conversation does not end with that prompt, the whole conversation is summarized instead. Claude Code skips this recovery when the content that would be carried forward holds no model reply and less than about 1,000 tokens of the person's own text, such as a short retry sent after an oversized paste. In that situation the official next step is /clear. Before v2.1.269, compaction failed whenever it could not summarize a whole exchange, so a session in that state hit this error again on every turn.
When a single exchange cannot be compacted
A single-exchange conversation has no earlier turns to summarize. When automatic compaction would have run on one, Claude Code skips the attempt and explains what fills the request. When the API does not report token counts, the official message is:
Prompt is too long · this conversation is a single exchange and cannot be compacted — the request size comes mostly from system prompt, tool definitions, or attachments.When the API reports token counts and the conversation's own content is most of the request, the official message is (placeholders left as in the docs, not filled with invented numbers):
Prompt is too long · the request is ~<request tokens> tokens (limit <limit>) and this conversation's own content is most of it. A single-exchange conversation cannot be compacted; start with less content (smaller files or pasted text).When most of the request is outside the conversation, the official message is:
Prompt is too long · the request is ~<request tokens> tokens (limit <limit>) but this conversation is only ~<conversation tokens> tokens — the rest is system prompt, tool definitions, and attachment content. A single-exchange conversation cannot be compacted; reduce attached files/tools or start with less context.Official recovery is to reduce pasted text, attachments, tools, or memory files, then /clear and resend. Before v2.1.162, Claude Code still attempted the compaction and surfaced the bare Prompt is too long when it failed.
Default auto-compact thresholds and unrecognized model IDs
If an auto-compact window has not been set separately, Claude Code generally compacts when the conversation reaches the model's context limit, with these official exceptions: cloud sessions compact as the conversation approaches the model's limit; Sonnet 4.6 and Opus 4.6 without extended context compact at the 200K boundary; when CLAUDE_CODE_DISABLE_1M_CONTEXT=1 is set, models with a native 1M window, such as Sonnet 5 and the Fable models, also compact at the 200K boundary; models running with a native 1M window compact before the window fills, at about 967K tokens by default (the official list includes the Fable models, Sonnet 5 and later, Haiku 5.5, and Opus 4.7 and later); and sessions on a model ID Claude Code does not recognize compact at the context window it assumes for that ID.
If this error appears near 200K tokens on a model that actually accepts a larger window, one official cause is that Claude Code does not recognize the model ID and therefore treats it as a 200K window. To keep working past that point, the docs say to give Claude Code the model's real context window, as described in the model-configuration section "Correct the window for a gateway or custom model ID." A startup warning may look like the official example Model "my-gateway-opus" isn't recognized · context assumed to be 200k tokens; "my-gateway-opus" in that example is a documentation placeholder, not the name of a shipping product.
Ways to declare a real window include CLAUDE_CODE_MAX_CONTEXT_TOKENS (in tokens), a modelOverrides or modelPicker mapping for a known model, or a [1m] suffix on an ID that should use a 1M window. Official docs are explicit that this variable does not apply to every ID on its own; which IDs it affects is spelled out on the same model-configuration page, and setting the variable is not a guarantee that it will take effect. Once Claude Code recognizes the ID or uses the window that was given, the startup warning no longer appears. If a custom ANTHROPIC_BASE_URL is in use and the error starts with Prompt is too long · automatic compaction failed, the official suggestion is to set the model's context window or update to v2.1.299 or later. Before v2.1.299, Claude Code ended the turn with that message near the assumed 200K window instead of sending the request.
When a larger window is needed rather than a shorter conversation, official docs say Fable models, Sonnet 5 and later, Haiku 5.5, Opus 4.6 and later, and Sonnet 4.6 support a 1 million token context window. How the [1m] variant is selected, and how plan access works, is documented in the Extended context section of the official model-configuration page. Plan details are also covered separately in Claude Pricing (November 2026) and are not restated here.
What remains after compaction
The official "What survives compaction" table on the context-window page describes the following: the system prompt and output style still apply; project-root CLAUDE.md and unscoped rules are re-injected from disk; auto memory is re-injected from disk; skill descriptions are rebuilt from current skills and re-injected (this requires Claude Code v2.1.304 or later); if the session started with a Git status snapshot, a fresh one is read from the repository; a plan written in plan mode is re-injected from disk; rules with paths: frontmatter and nested CLAUDE.md files in subdirectories reload on demand; files Claude read or edited are re-read, up to five, most recently modified first, and a file over 5,000 tokens comes back as a path reference without its content, shown as Referenced file instead of Read; invoked skill bodies are re-injected, capped at 5,000 tokens per skill and 25,000 tokens total, with the oldest dropped first; background commands and background subagents keep running, and Claude Code reminds the model which ones are still running; context that hooks added earlier is summarized with the rest of the conversation; and SessionStart hooks that match the compact source are run, with their output added to the compacted context.
Path-scoped rules and nested CLAUDE.md files are loaded into message history when a matching file is read, written, or edited, so compaction summarizes them away with everything else. An instruction that existed only in the conversation, lives in a nested CLAUDE.md that has not reloaded yet, or is a path-scoped rule that has not matched a file since compaction, can look as if it disappeared. Official guidance is to add conversation-only instructions to CLAUDE.md, or, for a rule that must persist, to drop the paths: frontmatter or move it to the project-root CLAUDE.md.
How this differs from usage limits, 529, Request too large, and a thrashing compact loop
Plan quota exhaustion uses a different set of sentences on the error reference, such as You've hit your session limit, You've hit your weekly limit, or the Opus and Sonnet limit variants. Those messages are about account or plan allowances, not the model's context window. That topic is covered in Anthropic Still Describes Claude Code Limits in Multiples, So Here's What Each Plan Gets.
529 Overloaded is a server-side capacity error, not a full context window. That tutorial is Claude Code Says "529 Overloaded"? Here's What Anthropic's Docs Say and What to Try.
Request too large (max 32MB) is also a different error. Official docs define it as the raw request body exceeding the API's 32MB limit before tokenization, usually because of large pasted content, tool results, or attachments, and state that this limit is separate from the context window. If the message says compacting cannot make it fit, official recovery is to press Esc twice to step back past the turn that added the large content, or to run /clear. Otherwise /compact is available; the docs say it drops accumulated images and attachments. Large files should be referenced by path so they can be read in chunks, rather than pasted in full. 32MB is not another name for Prompt is too long.
Autocompact is thrashing: the context refilled to the limit... is yet another message, from the troubleshooting page rather than the Prompt is too long entry. There, automatic compaction already succeeded, but a file or tool output refilled the window several times in a row, and Claude Code stops retrying to avoid a loop. Official recovery steps on that page include reading an oversized file in smaller chunks, a focused /compact, moving large-file work to a subagent, or /clear if the earlier conversation is no longer needed. That condition is related, but it is not the definition of Prompt is too long.
What a GitHub issue reports — and what it does not
GitHub issue #103279 in the anthropics/claude-code repository, titled [BUG] Auto-compact stops triggering on 1M-context sessions, which then fail with "Prompt is too long" (VS Code extension 2.1.301), was still open. It has one comment. Labels include bug, platform:windows, area:core, and platform:vscode. The author is not an official Anthropic account (author_association is NONE).
The author described Claude Code VS Code extension 2.1.301 on Windows 11, model claude-opus-5-5 with a 1M context window, on a Max subscription, with autoCompactEnabled: true and no compaction-related environment variables set. According to that report, two long sessions on 18 October 2026 (the issue was filed at 04:27 Asia/Shanghai on 19 October 2026, which is 2026-10-18T20:27:08Z) did not auto-compact, later failed with a synthetic Prompt is too long message (isApiErrorMessage: true, error: invalid_request), and then failed the same way on every later turn until /clear. The author, reading a personal transcript, placed an auto-compact threshold around 967,000 to 971,000 tokens. That is the same order of magnitude as the official default of about 967K tokens for native 1M-window models, but 967K is cited here only from the official documentation. The successive counts in the issue are that user's reported session data, not an official threshold. The author's own workaround was to run /clear by hand at about 900,000 tokens. That is a user workaround, not official guidance.
A comment dated 23:02 Asia/Shanghai on 28 October 2026 (2026-10-28T15:02:47Z), from a Linux CLI 2.1.310 session, also with author_association: NONE, described a long-running subagent at about 940k tokens. The next message, about 2 KB, returned Prompt is too long at once. After the single word continue, a compact_boundary and a summary appeared, and the session continued at about 207k tokens. That is likewise a user report, not an official procedure, and not a basis for guessing a root cause. Issue #103279 remains open and had no official comment. Official docs describe expected behavior and recovery steps; they do not, by themselves, confirm this report as a product defect, or say that it has been fixed or left unfixed.
These notes follow the official error reference and the related commands, context-window, settings, environment-variable, model-configuration, memory, troubleshooting, and cloud-session pages. The docs.anthropic.com errors URL redirects to the same code.claude.com error reference; it is not a second, different document set.
