Skip to content

Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again

This is Claude Code telling you that /compact — the command the tool just told you to run — could not run. Nothing is wrong with your API key, your plan, or your network: the summarization request Claude Code makes on your behalf did not fit in the window, and it never left your machine in a usable form. The error is arithmetic, not connectivity, which is why waiting and trying again changes nothing.

Data as of 2026-09. Vendor limits and defaults change; check the official docs for current values before acting on any number below.

The command that rescues a full window needs the window not to be full

Compaction is not a delete operation. It is a model call: Claude Code sends the conversation you want summarized and asks for a summary back, and both the conversation and the summary have to fit inside the same context window. When the conversation alone has already reached the ceiling, there is no room left for the summary to be written into.

That is the whole deadlock, and it is worth stating plainly because the two halves of it appear in different places. The full-context banner reads Context limit reached · /compact or /clear to continue. You run /compact, and /compact answers that the conversation is too long. Each message is correct and together they form a loop.

The way out is not a better /compact invocation — it is making the conversation shorter first, by removing turns, and only then compacting. Compaction is a summarizer, and a summarizer needs somewhere to put the summary.

Is retrying useful?

No. The same conversation is the same length, and it will fail identically.

There is a second reason worth knowing. Claude Code retries transient failures up to 10 times with exponential backoff before it shows you any error at all — that is the CLAUDE_CODE_MAX_RETRIES default. By the time this line is on your screen, the possibility that it was a blip has already been tested ten times. Pressing up-arrow and Enter is attempt eleven against a condition that did not move between attempts.

The only retry that accomplishes anything is the one you run after the conversation is shorter. Do that, and /compact completes on the first try.

The double-Esc that appears to do nothing

The error tells you to press Esc twice. People press Esc twice, see nothing happen, and conclude the instruction is wrong. It isn’t — it is conditional.

Double-Esc opens the rewind menu only when the prompt input is empty. If there is any text in the input box, the first double-Esc clears that text instead; the cleared text goes into input history, so Up brings it back. Since you almost certainly have a half-typed prompt sitting there when this error arrives, the sequence that actually works is: press Esc twice to clear the box, then press Esc twice again to open the menu. /rewind opens the same menu with no keyboard trick involved.

A checkpoint exists for every prompt you sent that started a turn, so the list you get is a list of your own messages. Step back several of them — not one — and run /compact again.

Pick the option that rolls back the conversation, not your files

The rewind menu offers Restore code and conversation, Restore conversation, Restore code, Summarize from here, Summarize up to here, and Never mind. The two code-restore entries only appear when the selected checkpoint has tracked file changes.

For this error you want the conversation-only option. Restoring code as well will revert the work you were doing, and it will revert it partially: /rewind does not restore files modified by Bash commands, does not restore subagent edits (except a foreground forked skill), and skips symlinked or hard-linked paths, leaving their current contents in place. In a session where a build script or a git command touched the tree, a code restore produces a mixed state that is harder to reason about than either end of it. Use git for code; use rewind for the conversation.

Which exit fits your situation

  • You need the history and the window is at the ceiling — Esc twice with an empty input, step back several turns, then /compact. The removed turns are gone from the live conversation; the summary covers what remains.
  • /compact answers Not enough messages to compact. instead — a different failure with the opposite cause. The conversation has too few turns to summarize, which happens when one enormous paste or tool output filled the window by itself. There is nothing for compaction to condense; stepping back past that single message is the only fix.
  • You do not need the history — /clear. This is less destructive than it feels: the previous conversation is preserved and reopenable with /resume. Transcripts are local JSONL files under ~/.claude/projects/, swept by cleanupPeriodDays, which defaults to 30 days.
  • It keeps happening every session — compaction is starting too late. The auto-compact window controls how full the context gets before compaction runs, and it is settable with /autocompact <value> (which writes the autoCompactWindow user setting), the --autocompact launch flag, or the CLAUDE_CODE_AUTO_COMPACT_WINDOW environment variable, in increasing order of precedence. The accepted range is 100K to 1M tokens. Defaults differ by model: models running with a native 1M window compact before the window fills, at about 967K tokens, while models running with a 200K window compact at the 200K boundary.
  • Compaction succeeds and the window immediately refills — you will see Autocompact is thrashing: the context refilled to the limit.... Something is re-reading a large file or replaying a large tool output right after each compaction, and Claude Code has stopped retrying.

That last case has a mechanical explanation worth internalizing: the window does not come back empty after compaction. The system prompt, CLAUDE.md, memory, and MCP tool definitions are re-injected, the body of each skill you invoked comes back capped at 5,000 tokens per skill, and Claude Code re-reads up to five of the files touched in the session — with any file over 5,000 tokens returning as a path reference rather than its contents. A session whose re-injected baseline is already large has very little room to work with even immediately after a successful compaction.

How to know you are actually out of it

Two observations, in order. First, /compact completes without an error and /context no longer shows a warning line about exceeding the limit or sitting past the compaction window. Second, send a real prompt — a normal one, not a one-word test — and it completes. One successful /compact with no follow-up turn proves only that the summarizer fit, not that your next request will.

If /context still shows the non-conversation categories — system prompt, tool definitions, attachments — occupying most of the window after a successful compaction, you are not looking at a conversation-length problem at all, and more compaction will not help.