Use sliding compaction for tiny budgets
ober
878d60bd3f3058cff10a12cba8b02d813e6f8c68
--- a/src/jcode/core/compaction-strategy.ss +++ b/src/jcode/core/compaction-strategy.ss @@ -243,10 +243,15 @@ (def (configured-compaction-strategy-name) (compaction-block-ref "strategy" "tiered")) +(def (default-compaction-strategy-name budget) + (if (and budget (<= budget 1024)) "sliding" "tiered")) + (def (run-configured-compaction messages budget) - "Pick the strategy from jcode.json (compaction.strategy, default tiered), - run it against BUDGET tokens, log the phase reached, return the messages." - (let* ((name (compaction-block-ref "strategy" "tiered")) + "Pick the strategy from jcode.json (compaction.strategy). Tiny budgets + default to sliding; larger budgets default to tiered. Run it against + BUDGET tokens, log the phase reached, return the messages." + (let* ((name (compaction-block-ref "strategy" + (default-compaction-strategy-name budget))) (keep (compaction-block-ref "strategy_keep_recent" (if (and budget (<= budget 4096)) 1 2))) (thr (compaction-block-ref "strategy_threshold" 0.75)) --- a/test/run.ss +++ b/test/run.ss @@ -840,6 +840,8 @@ (check! "sliding fires phase 1" (cdr r) 1) (check! "sliding keeps sys+user+protected" (length (car r)) 3) (check! "sliding head is system" (message-role (car (car r))) "system")) +(let ([r (run-configured-compaction hist-tier 572)]) + (check! "configured small budget uses sliding" (length r) 3)) ;; Tiered phase transitions (keep=1, uniform 0.75 threshold). ;; budgets: 4000→t3000 (p0), 1200→t900 (p1), 800→t600 (p2), 600→t450 (p3)