shouldCompact function
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;
}