Auto-compact should trigger earlier / threshold should be configurable

Resolved 💬 8 comments Opened Feb 25, 2026 by royleon55 Closed Apr 15, 2026

Problem

When autoCompact is enabled, the auto-compact trigger threshold is too close to the hard context window limit. This creates a failure scenario where:

  1. Context grows rapidly (e.g., large file reads, verbose tool outputs) and overshoots past the auto-compact threshold straight to the hard limit
  2. Claude stops working and advises running /compact manually
  3. Manual /compact then fails with "conversation is too long" — because the conversation is so large that even the compaction request can't fit in the context window
  4. The only option left is /clear, which destroys all conversation context

This is a catch-22: auto-compact didn't trigger when it should have, and manual compact can't rescue the situation.

Proposed Solution

  • Make the auto-compact threshold configurable — allow users to set a percentage (e.g., trigger at 80% or 85% of the context limit instead of the current default)
  • Trigger auto-compact earlier by default — even a 5% earlier threshold would provide enough buffer to avoid the failure scenario described above
  • Ensure /compact always works — if the conversation is too long to compact normally, consider a more aggressive fallback (e.g., truncating older messages before compacting)

Example config:

{
  "autoCompact": true,
  "autoCompactThreshold": 0.85
}

Impact

This is a significant UX issue. Losing an entire long session's context because auto-compact failed silently and manual compact can't recover is extremely frustrating — especially during complex multi-file tasks where rebuilding context is costly.

Environment

  • Claude Code CLI
  • autoCompact: true in settings
  • Model: Claude Opus
  • Platform: macOS

View original on GitHub ↗

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