Context compaction fails with 'Conversation too long' when context limit is reached

Resolved 💬 4 comments Opened Feb 17, 2026 by yanmwisa Closed Mar 20, 2026

Bug Description

When the context window reaches its limit, Claude Code prompts the user to run /compact or /clear to continue. However, running /compact at this point fails with:

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

This creates a deadlock situation:

  • The conversation is too long to continue working
  • The conversation is also too long to compact
  • The only option left is /clear, which loses all conversation context

Steps to Reproduce

  1. Work on a complex, long-running task in Claude Code (e.g., multi-file debugging with agents)
  2. Continue until the context limit is reached and the message appears: Context limit reached · /compact or /clear to continue
  3. Run /compact
  4. Observe the error: Error during compaction: Error: Conversation too long

Expected Behavior

/compact should always be able to compress the conversation, especially when the context limit is reached. This is the exact scenario where compaction is most needed. The compaction mechanism should handle conversations of any length — possibly by:

  • Compacting in chunks/stages rather than trying to process the entire conversation at once
  • Using a progressive summarization strategy (summarize older segments first, then merge)
  • Having a fallback compaction mode that is more aggressive when the standard approach fails

Actual Behavior

/compact fails when the conversation is too long, which is precisely when the user needs it the most. The user is forced to use /clear and lose all context, or press Esc and manually go back several messages.

Screenshot

The screenshot below shows:

  1. Context limit reached on an agent task
  2. 4+ minutes spent "crunching" before failing
  3. /compact command explicitly failing with the error

Environment

  • Claude Code CLI
  • macOS (Darwin 25.2.0)
  • February 2026

Impact

This is a significant UX issue for long working sessions. Users working on complex tasks (multi-file refactoring, debugging with agents, etc.) regularly hit context limits. Being unable to compact forces a full context reset (/clear), losing all accumulated understanding of the task, which can mean hours of re-explanation and re-investigation.

Suggested Priority

High — this undermines one of the core features that makes long Claude Code sessions viable.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗