[Feature Request] Configurable context usage warning threshold

Resolved 💬 2 comments Opened May 22, 2026 by johnnydevriese Closed Jun 22, 2026

Problem

With verbose models (Opus 4.7), setting a low autocompact threshold (e.g., 100k tokens) creates a compaction loop — the model burns tokens fast enough that autocompact fires every few turns, wasting tokens on the compaction itself rather than doing useful work. The session gets stuck in a cycle of generate → compact → generate → compact.

The only current alternative is disabling autocompact and manually running /context to eyeball usage, which is easy to forget.

Proposal

Add a context.warningThreshold setting (percentage or absolute token count) that displays a visible warning (status line indicator, notification, or inline message) when context usage crosses the configured threshold.

Example config:

{
  "context.warningThreshold": 0.75
}

This gives the user a chance to:

  • Manually /compact at a time that makes sense
  • Start a new conversation
  • Switch to a less verbose model for the remainder of the session

Why this is different from autocompact

This complements autocompact rather than replacing it. Users who prefer manual control could:

  1. Disable autocompact (or set it very high as a safety net)
  2. Set a warning threshold at a lower percentage
  3. Take action on their own terms when warned

This avoids the compaction loop problem while still keeping users informed about context pressure.

Bonus: expose token count to hooks

A related enhancement would be exposing the current token count / context percentage in hook payloads (e.g., PostToolUse). This would let users build custom alerting — Slack notifications, sound alerts, terminal bell, etc. — without requiring Claude Code to build every notification UX natively.

View original on GitHub ↗

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