claude/for
Search
Subscribe
Claude Code

“Context limit reached” in Claude Code: causes and the fix

Claude Code's on-screen form of “Prompt is too long”: the next request won't fit the context window. Run /context, then /compact or /clear.

"Context limit reached · /compact or /clear to continue" is how an interactive Claude Code session shows the error "Prompt is too long": the next request would not fit in the model's context window, or in the window Claude Code believes it has. It comes from your session or your setup, not from an Anthropic outage. Run /context to see what fills the window, then /compact to summarize or /clear to start fresh.

claude-for is an independent guide, not affiliated with Anthropic. Everything below was checked on December 5, 2026 against Anthropic's error reference, the Claude Code CHANGELOG and public GitHub reports.

TL;DR. Run /context. If the window really is full, run /compact. If that fails or finds nothing to compact, rewind past the oversized message or run /clear. If the line ends with "auto-compact is off", switch it back on in /config.

The exact wording and its variants

Anthropic's error reference files the line under "Prompt is too long" and documents three forms:

  • "Context limit reached · /compact or /clear to continue" is the standard one.
  • "Context limit reached · /compact or /clear to continue · auto-compact is off · /config to turn it on" appears when you turned auto-compact off in your user settings. The CHANGELOG added that hint in version 2.1.235, released August 18, 2026.
  • "Context limit reached · /clear to continue" appears when the DISABLE_COMPACT environment variable is set.

Some reports end with a model hint instead, such as · /model opus[1m] in #18152 or · /model sonnet[1m] in #69179. Anthropic doesn't document that form.

The line only exists in an interactive session: in -p output and in the transcript, the same error stays "Prompt is too long", per the docs. The string "Context limit reached" is present in Claude Code 2.1.337, checked December 5, 2026, and in every installed version back to 2.1.328.

Messages it gets confused with

  • "Context low (0% remaining) · Run /compact to compact & continue" is the warning before the wall, quoted in #90113.
  • "Autocompact is thrashing" means the context refilled right after three compactions in a row (CHANGELOG, 2.1.89).
  • "Request too large (max 32MB)" is a size limit in bytes, usually images and attachments, separate from the context window.
  • In the claude.ai apps, the cousins are "Your message will exceed the length limit for this chat" (our guide) and "Compacting our conversation so we can keep chatting" (our guide). Neither shows in the terminal.

What fills the context window

Anthropic's context window page lists what loads before you type a word: the system prompt, CLAUDE.md, auto memory, MCP tool names and server instructions, and skill descriptions. After that, every file read, command output, hook output, image and reply adds to the pile.

The wall also arrives before 100%. Since version 2.1.7, Claude Code computes its limit on the "effective context window (which reserves space for max output tokens)", per the CHANGELOG, so room for Claude's answer is held back.

Why it shows up with no apparent cause

We counted 311 GitHub issues in anthropics/claude-code that mention "Context limit reached" (search of December 5, 2026). 78 carry it in the title and 21 are still open. They run from March 2025 to November 2026 and peaked at 79 in February 2026. The newest, #112184 (November 25, version 2.1.325), is titled "shown with no apparent cause". The same patterns keep coming back:

  • The newest turn is the heavy one. Two images in #112184, a Stop hook printing linter output in #24458, a dozen subagents returning at once in a comment on #23993. A commenter on #112184 suggests that compaction summarizes older turns and cannot shrink the newest. That is a user's inference, not Anthropic's.
  • The real limit is lower than the displayed one. In #34158, a forgotten CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000 in ~/.bashrc stopped a 1M session at 197K tokens. Anthropic's docs don't list that variable. On Amazon Bedrock, a Claude Code maintainer suspected the endpoint itself was rejecting a fresh request (#81636).
  • Counting bugs, since fixed. Version 2.1.7 shipped on January 13, 2026, and #18152 and #18159 arrived the next day. Version 2.1.14 fixed the regression that blocked users "at ~65% context usage instead of the intended ~98%". Later fixes covered skills with model: frontmatter (2.1.76), stopping a turn mid-compaction (2.1.304), an unrelated API error shown as too long with many MCP tools (2.1.306) and a false error after a reply hit the output limit (2.1.334).
  • Auto-compact is off somewhere you forgot. The docs say the "auto-compact is off" hint only shows when /config could change it. DISABLE_AUTO_COMPACT, or autoCompactEnabled: false in project or managed settings, turns it off without the hint.

The Claude moves worth stealing, by email

Workflows tested on real jobs, sent only when they are worth it. Free.

How to fix it, fastest first

now

Run /context

It breaks usage down into system prompt, tools, memory files and messages. Note the biggest row.

next

Run /compact

Add a focus if you like, such as /compact keep the auth bug fix. If it answers Not enough messages to compact., one prompt is too big on its own: go to the next step.

next

Rewind past the oversized message

Press Esc twice or run /rewind, pick the message before the images or the big paste, choose Restore conversation, then resend it smaller.

next

Turn auto-compact back on

Toggle Auto-compact in /config, and look for DISABLE_AUTO_COMPACT in your shell profile or in the env block of your settings.

next

Shrink what loads on every turn

Disable idle MCP servers with /mcp disable and the server name. Trim CLAUDE.md, or move workflow instructions into skills that load on demand.

next

Run /clear

Your files stay as they are. Run /rename first, so /resume can find the old conversation later.

next

Update, then restart

Run claude update. If the line comes back right after /clear with little in use, quit and start a new process.

The /compact, /mcp and CLAUDE.md steps come from the error reference, the rename-then-clear tip from Anthropic's costs page, and the rewind route from the checkpointing docs plus a reply on #112184. For the habits that keep sessions lean, see our context engineering guide.

If you need a bigger window

Fable models, Sonnet 5 and later, Haiku 5.5, and Opus 4.7 and later run with a 1M-token window by default, per Anthropic's model configuration page. Opus 4.6 and Sonnet 4.6 reach 1M only through their [1m] variant. Opus 4.6 at 1M is included on Max, Ultra, Team and Enterprise, but Pro needs usage credits. Sonnet 4.6 at 1M needs usage credits on every subscription plan.

A bigger window doesn't mean later compaction. From version 2.1.334, rolling out, most current 1M models compact near 400K tokens by default. Run /autocompact to see your window, or /autocompact 1M for the full one. Behind a gateway that stops at 200K, set CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000 so Claude Code compacts before the gateway refuses.

When to stop and wait

This line describes your session, so status.claude.com will rarely explain it. Check the status page only if a brand-new session fails on its first short message while /context shows little in use. On Bedrock, Vertex or a company gateway, ask whoever runs the endpoint what input limit it enforces.

The honest limits

Anthropic documents the message, its variants and the main fixes. It doesn't document CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE, the model-hint form, or why /context and the block disagree in so many reports. Most of those issues closed as stale or as duplicates with no Anthropic reply, and #112184 is still open, labeled needs-repro.

The 311 figure counts issues that mention the phrase, not distinct bugs. We have not triggered the message ourselves: the version check is a text search of the installed program, not a test.

Questions people ask

Why does Claude Code say context limit reached when /context shows free space?

/context shows Claude Code's own count. The block means the request didn't fit, by the API's measure or Claude Code's pre-send check, and the two can disagree. Reports blame the newest turn (images, hook output, subagent results), a leftover override, a provider's lower limit, or counting bugs since fixed.

Is "Context limit reached" the same as "Prompt is too long"?

Yes. Anthropic's error reference says an interactive session shows "Prompt is too long" as "Context limit reached · /compact or /clear to continue". Scripts run with -p keep the original wording, and so do longer forms such as "Prompt is too long · automatic compaction failed".

Will /clear delete my work?

No. /clear empties the conversation Claude sees, not your project. Edits already made stay on disk. Run /rename before clearing so you can reopen the old conversation with /resume, as Anthropic's costs page suggests.

Can I make Claude Code compact instead of stopping?

Yes. Auto-compact is on by default: switch it back on in /config and remove DISABLE_AUTO_COMPACT if you set it. To compact earlier than the default, run /autocompact with a size such as 300k.

If Anthropic changes how Claude Code handles a full context window, the newsletter will say so in one line.

The Claude moves worth stealing, by email

Workflows tested on real jobs, sent only when they are worth it. Free.