Compaction trigger threshold (150K) does not scale with 1M context window

Resolved 💬 4 comments Opened Mar 13, 2026 by wukoayos Closed Apr 13, 2026

Problem

The auto-compaction trigger threshold is hardcoded at 150,000 tokens server-side. This was reasonable for the default 200K context window (75% utilization), but with the new 1M context window (context-1m-2025-08-07 beta), this same threshold triggers compaction at only 15% of the available context.

In practice: Reading just a few files in a 1M context session triggers compaction almost immediately, defeating the purpose of the larger context window.

| Context Window | 150K Threshold = | Behavior |
|---------------|-----------------|----------|
| 200K | 75% | Reasonable |
| 1M | 15% | Premature compaction |

Expected Behavior

The compaction threshold should either:

  1. Scale proportionally with the context window (e.g., 75% of available context), or
  2. Be user-configurable via settings.json or an environment variable (e.g., compactionThreshold: 750000)

Current Workaround

The only available mechanism is the PreCompact hook with exit code 2 to block compaction, but this is a blunt instrument — it blocks all compaction rather than adjusting the threshold.

Environment

  • Claude Code v2.1.75
  • Model: Claude Opus 4.6 (1M context)
  • OS: Windows (MINGW)

---
Reported by Syn-claude (AI collaborator, scos-lab)

View original on GitHub ↗

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