Summary
PREEMPTIVE_OVERFLOW_RATIO = 0.9 is hardcoded at selection-BeP8qtCb.js:4199 in 2026.5.7. The runtime triggers preemptive compaction at 90% of contextTokens. For agents on tighter token budgets, an earlier trigger (e.g. 0.7) would compact on smaller, cheaper payloads.
Why this is worth tuning
When contextTokens=200000, 90% fires at ~180K tokens — the per-call summarizer cost is high, AND the buffer between trigger and hard cap is small (so any tool result that arrives between trigger and compaction can immediately tip into hard overflow → 3 retries via MAX_OVERFLOW_COMPACTION_ATTEMPTS).
Setting this lower reduces per-compaction model cost, widens the buffer between preemptive and hard overflow, and reduces the probability of cascading retries.
Proposed fix
Expose as agents.defaults.compaction.preemptiveOverflowRatio (or similar). Float in (0, 1), default 0.9 to preserve current behavior.
Filed alongside companion issue on MAX_OVERFLOW_COMPACTION_ATTEMPTS.
(Re-filed from badlogic/pi#5 — filed in wrong repo originally.)
Summary
PREEMPTIVE_OVERFLOW_RATIO = 0.9is hardcoded atselection-BeP8qtCb.js:4199in 2026.5.7. The runtime triggers preemptive compaction at 90% ofcontextTokens. For agents on tighter token budgets, an earlier trigger (e.g. 0.7) would compact on smaller, cheaper payloads.Why this is worth tuning
When
contextTokens=200000, 90% fires at ~180K tokens — the per-call summarizer cost is high, AND the buffer between trigger and hard cap is small (so any tool result that arrives between trigger and compaction can immediately tip into hard overflow → 3 retries viaMAX_OVERFLOW_COMPACTION_ATTEMPTS).Setting this lower reduces per-compaction model cost, widens the buffer between preemptive and hard overflow, and reduces the probability of cascading retries.
Proposed fix
Expose as
agents.defaults.compaction.preemptiveOverflowRatio(or similar). Float in(0, 1), default0.9to preserve current behavior.Filed alongside companion issue on
MAX_OVERFLOW_COMPACTION_ATTEMPTS.(Re-filed from
badlogic/pi#5— filed in wrong repo originally.)