Feature request: percentage-based autoCompactWindow for cross-model behavior

Resolved 💬 4 comments Opened Apr 29, 2026 by bradygrapentine Closed May 3, 2026

Problem

autoCompactWindow is an absolute integer (100k–1M tokens), so a single global value can't express a consistent compaction policy across models with different context sizes:

  • autoCompactWindow: 550000 → fires at 55% on 1M-context Opus, but never fires on 200k-context models (above their entire window, falls back to harness ~95% default).
  • autoCompactWindow: 110000 → fires at 55% on 200k models, but at ~11% on 1M (way too aggressive).

Users who switch between 1M Opus and 200k Sonnet/Haiku in the same workflow have no way to set a single "compact at X% full" policy.

Proposed

Add a fractional alternative:

{
  "autoCompactWindowFraction": 0.55
}

When set, the harness computes the threshold as fraction * activeModelContextWindow at session start (or per-turn). When both autoCompactWindow and autoCompactWindowFraction are set, the absolute value wins for back-compat.

Why hooks can't solve this

  • No hook output field mutates settings.
  • SessionStart fires after settings are loaded.
  • Stop hooks can't invoke /compact.

So this needs to live in the harness, not user-land.

Use case

Long agent-team sessions on smaller-context models currently rot before reaching the harness's ~95% default; users want to compact earlier (50–70%) regardless of which model is active.

View original on GitHub ↗

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