Context limit reached breaks /compact — conversation becomes unrecoverable

Resolved 💬 2 comments Opened Mar 3, 2026 by tobiashill666 Closed Mar 31, 2026

Bug

When a session hits the context limit, /compact also fails with:

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

This leaves the user stuck — can't continue, can't compact, forced to /clear and lose all session context.

Steps to reproduce

  1. Work on a multi-task session with many file reads/edits (7+ tasks involving code exploration, editing, and testing)
  2. Eventually the context fills up and tool calls start showing "Context limit reached"
  3. Run /compact
  4. /compact itself fails because the conversation is too long for the compaction prompt

Expected behavior

/compact should always work, even when at the context limit. It should be able to summarize and truncate the conversation regardless of current length — this is precisely when it's needed most.

Actual behavior

/compact fails with the same context limit error, creating an unrecoverable state where the only option is /clear which loses all working context.

Environment

  • Claude Code CLI
  • Observed across multiple sessions with extended multi-task workflows

Suggestion

Reserve headroom for the compaction prompt so it can always execute, or implement a fallback compaction strategy (e.g., aggressive truncation) when the standard compaction can't fit.

View original on GitHub ↗

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