Skip to main content

auto_compact_threshold

Function auto_compact_threshold 

Source
pub fn auto_compact_threshold(token_budget: usize) -> usize
Expand description

Compute the auto-compression trigger threshold for a given context window. Returns the token total above which needs_compression fires.

Buffer scales with window size:

  • ≤ 100K (proxy-bound): 5K buffer → 65K window → 60K trigger.
  • 100K (vendor large): 13K buffer → 200K window → 187K trigger.

  • Either branch caps at ctx_window / 4 so degenerate small windows (8K Ollama) still land on a meaningful 6K threshold rather than underflowing to 0.