Skip to content

Feature: Configurable compaction threshold and model (global + per-model) #11930

Closed as not planned

Description

@tobiastornros

Add configurable compaction settings at both global and per-model levels:

  • Threshold: Trigger compaction at a percentage of context usage (not just at 100%)
  • Model: Use a different (cheaper/faster) model for compaction

Motivation

  1. Different models degrade at different context levels - Claude Opus quality drops around 50-60% context, while other models may handle more. Users should be able to tune this per-model.

  2. Compaction can use cheaper models - The compaction summary doesn't need the most expensive model. Users (especially Copilot users) want to use a cheaper model for compaction to save quota/costs.

Proposed Solution

Global config

{
  "compaction": {
    "auto": true,
    "prune": true,
    "threshold": 80,
    "model": "anthropic/claude-haiku-3-5-20241022"
  }
}

Per-model config

{
  "provider": {
    "anthropic": {
      "models": {
        "claude-opus-4-20250514": {
          "compaction_threshold": 50,
          "compaction_model": "zhipu/glm-4-plus"
        }
      }
    }
  }
}

Priority hierarchy

  1. Per-model compaction_threshold / compaction_model (highest)
  2. Global compaction.threshold / compaction.model
  3. Default: 100% threshold, same model as session

Related Issues

Activity

  1. github-actions commented on Feb 3, 2026

    @github-actions
    Contributor

    This issue consolidates several related feature requests about compaction configuration. The issues listed are highly relevant and should be reviewed:

    This current issue (#11930) appears to be a comprehensive feature proposal that builds upon and consolidates these requests. It may be worth reviewing whether to close the older issues as duplicates of this one once it's implemented, or keeping them open for discussion if they represent specific use cases.

  2. added a commit that references this issue on Feb 3, 2026
    5b87f2c
  3. absurdly-nerdly commented on Feb 25, 2026

    @absurdly-nerdly

    Yes please, this really is needed, and per-model/per-agent config is a must!

  4. Fridayxiao commented on Mar 4, 2026

    @Fridayxiao

    Damn right

  5. Mte90 commented on Mar 4, 2026

    @Mte90

    yeah same issue, I want to be able to set the model for compaction.
    maybe also an early alert when probably it will do the compaction can be handy as there is the issue that now often forgets everything.

  6. nyl199310 commented on Mar 6, 2026

    @nyl199310

    One specific part I want to make sure is covered here is prune, not just full summary compaction.

    Right now SessionCompaction.prune() uses fixed thresholds:

    • PRUNE_PROTECT = 40_000
    • PRUNE_MINIMUM = 20_000

    and it runs after each assistant turn. That means old tool outputs can start getting replaced with [Old tool result content cleared] very early, even on long-context models.

    On 1M-context models this feels especially aggressive, because full compaction is model-aware but prune is not. So even when the session is nowhere near overflow, older tool outputs may already be gone.

    So from my side, the ideal solution here would also include one of:

    • scaling prune thresholds from model.limit.context
    • exposing prune knobs such as prune_protect / prune_minimum
    • otherwise making prune less aggressive automatically on very large-context models

    I opened #16285 for this originally, but I'm consolidating the request here since it seems to overlap with this broader compaction-config issue.

  7. drewbitt commented on Mar 30, 2026

    @drewbitt

    You can already globally set a specific model for compaction.

    #6976 (comment)

    The per mode specific compaction percentage feature is much needed though. GLM 5.1 can't get past 60% without generating gibberish.

  8. assigned and unassigned on Apr 26, 2026
  9. github-actions commented on Jun 26, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions