Skip to content

Compaction: support percentage-based trigger relative to context window #5848

@tara-marchand

Description

@tara-marchand

Summary

Allow auto-compaction to trigger at a percentage of the model's context window, instead of only an absolute compaction.reserveTokens value.

Problem

Auto-compaction fires when contextTokens > contextWindow - reserveTokens. Because reserveTokens is an absolute token count, the effective trigger point shifts whenever the active model's context window changes.

Example: to compact at ~25% usage I set reserveTokens: 150000 for a 200k-window model (trigger at 50k). Switching to a 1M-window model with the same setting moves the trigger to ~85% (1,000,000 - 150,000 = 850,000). I have to recompute and edit settings every time I change models or window size.

This also makes shared/team settings fragile, since the right value depends on each user's current model.

Proposal

Add a percentage-based threshold option, evaluated against the live context window:

"compaction": {
  "enabled": true,
  "triggerPercent": 25,        // compact when usage reaches 25% of contextWindow
  "keepRecentTokens": 20000
}

Suggested semantics:

  • triggerPercent (0-100): compact when contextTokens >= contextWindow * triggerPercent / 100.
  • Keep reserveTokens working as today for backward compatibility.
  • If both are set, document precedence (e.g. triggerPercent wins, or use whichever triggers first).
  • keepRecentTokens could optionally gain a percentage variant too (keepRecentPercent).

Benefit

One setting that stays correct across models and context-window sizes (including 1M-context models), with no manual recomputation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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