shouldCompact function

bool shouldCompact(
  1. int contextTokens,
  2. int contextWindow,
  3. CompactionSettings settings
)

Whether context usage exceeds the compaction threshold.

Ported from pi's shouldCompact: compacts when contextTokens > contextWindow - reserveTokens.

Implementation

bool shouldCompact(
  int contextTokens,
  int contextWindow,
  CompactionSettings settings,
) {
  if (!settings.enabled) return false;
  return contextTokens > contextWindow - settings.reserveTokens;
}