Skip to content

Expose PREEMPTIVE_OVERFLOW_RATIO as a config knob (currently hardcoded to 0.9) #80639

@Cedric20011203

Description

@Cedric20011203

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions