published fresh until

Claude Code: 'Error during compaction: Conversation too long'?

Summary If Claude Code hits the context limit while /compact is running, the issue was closed by a bot as not planned with no Anthropic reply. Reported workarounds are /compact after pressing Esc twice, /clear, or compacting earlier; the suggested timing numbers are one commenter's estimate.

Not for forgotten details after compaction, see claude-code-compact-lost-details-compact-instructions-and-summarize-from-here

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Anthropic lists specific compaction repairs in 2.1.304 (errors after stopping a turn during compaction of a conversation the API rejected as too long), 2.1.310 (compaction after a Prompt is too long error retaining excessive dense text, such as base64 or SVG), 2.1.307 (some Autocompact is thrashing errors after many PDF pages, images or other large tool results), and 2.1.317 (Prompt is too long after automatic compaction when a very large CLAUDE.md changed since its last send); these release claims do not establish that every February #26317 case is resolved (checked 2026-11-05). I did not test current versions.

The problem

In a long Claude Code session the screen shows "Context limit reached · /compact or /clear to continue", and running /compact then fails with "Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again."

What the source says

The Claude Code issue 26317, opened 17 February 2026 by @yanmwisa on the CLI on macOS, describes exactly this after a long multi-file debugging run with agents; the reporter also saw about four minutes of waiting before the failure and asked for compaction in chunks. A bot flagged possible duplicates (issues 26267, 26220 and 25620), marked the issue stale on 6 March, closed it as not planned on 20 March and locked it on 29 March. I saw no reply from Anthropic staff.

Workarounds named there: /clear (loses all context); pressing Esc twice to go back a few messages, as the error suggests; and a commenter's advice to run /compact proactively at roughly 70 to 80 percent of the context window (their estimate: about 150k tokens on Sonnet, 160k on Opus; anecdotal, not official). That commenter also promoted a session-snapshot tool they develop; I did not look at it.

Order to try

Do first: Press Esc twice and step back a few messages, then try /compact again.

1. Press Esc twice and step back a few messages, then try /compact again. 2. If it still fails, save what you need (open decisions, file list) to a notes file by hand, then /clear. 3. Next time, compact earlier, before the limit message appears.

Mistakes to check

  • Retrying /compact repeatedly at the limit; the issue shows it failing the same way.
  • Assuming a newer version fixes every case: the February issue has no official resolution; the later releases above identify narrower repairs.

Limits

One closed, locked issue from February 2026; I did not reproduce it. Those third-party fix claims remain unconfirmed; the tagged release repairs above were read, without runtime trials.

Sources

Read: the GitHub issue above. Search snippets only: third-party guides on the same message.

Started from a post by @yanmwisa, packaged by the editor. Original post

Subjects

More in context management

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code: 'Error during compaction: Conversation too long'?
Summary: If Claude Code hits the context limit while `/compact` is running, the issue was closed by a bot as not planned with no Anthropic reply. Reported workarounds are `/compact` after pressing Esc twice, `/clear`, or compacting earlier; the suggested timing numbers are one commenter's estimate.
Copy for agent
get the whatworks thread claude-code-error-during-compaction-conversation-too-long-context-limit-reached and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-error-during-compaction-conversation-too-long-context-limit-reached
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks