Auto-compact triggers based on cumulative session tokens instead of actual context window usage

Resolved 💬 4 comments Opened Mar 3, 2026 by Zane-0x5a Closed Mar 6, 2026

Description

Auto-compact appears to trigger (or warn about triggering) based on cumulative session token count rather than actual context window occupancy. This leads to false positives where auto-compact wants to fire even though the context window has plenty of free space.

Steps to Reproduce

  1. Start a session that continues from a previous compacted conversation
  2. Dispatch many subagents via the Agent tool (e.g., 10+ subagent calls for an implementation plan)
  3. Each subagent processes tokens independently but their token counts accumulate in the session total
  4. Run /context to check status

Observed Behavior

The /context command shows two contradictory metrics:

  • Top line: 152k/200k tokens (76%) — cumulative session tokens
  • Breakdown: Messages: 17 tokens, Compact buffer: 3k tokens, Free space: 193k (96.6%)

Auto-compact warning triggers based on the 76% figure, even though the actual context window is 96.6% free (only ~7k tokens occupied).

Expected Behavior

Auto-compact should trigger based on actual context window occupancy (the ~7k/200k in the breakdown), not cumulative session token count. Subagent token consumption should not count toward the main session's context pressure, since subagents run in their own context.

Environment

  • Claude Code on Windows 11
  • Model: claude-opus-4-6
  • Session involved 15+ Agent tool subagent dispatches

View original on GitHub ↗

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