GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FEATURE]: per-model compaction threshold (reserved/buffer) · Issue #43703 · anomalyco/opencode

[FEATURE]: per-model compaction threshold (reserved/buffer) #43703

New issue
Copy link
New issue
Copy link
Open
Open
[FEATURE]: per-model compaction threshold (reserved/buffer)#43703
Copy link
Assignees
rekram1-node

Description

@joserdf
joserdf
opened on Aug 20, 2026
Issue body actions

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

Allow configuring compaction thresholds per model instead of a single global value.

Currently the top-level compaction block (auto, prune, tail_turns, preserve_recent_tokens, reserved) is global — one value applied to every model/agent. There is no per-model or per-agent compaction field in the schema.

Use case

Users switch between models with very different context windows (e.g. a 32k local model and a 128k+ frontier model). A single reserved token buffer means the effective trigger point scales linearly with the model's context limit, which is not what we want: we want to compact a small model earlier (relative to its window) and a large model later, or vice-versa — independent reserved/buffer per model.

Current workaround (and its limitation)

The effective trigger is approximately model.limit.context − reserved. By setting a per-model limit.context in provider.<name>.models.<id>, the trigger point can be shifted per model. However, reserved (the headroom) stays a single global value, so you cannot set an independent buffer per model.

Proposed API

Something like a per-model override, e.g.:

{
  "provider": {
    "my-provider": {
      "models": {
        "small-model": {
          "limit": { "context": 32000, "output": 4096 },
          "compaction": { "auto": true, "reserved": 4000 }
        },
        "big-model": {
          "limit": { "context": 128000, "output": 8192 },
          "compaction": { "auto": true, "reserved": 24000 }
        }
      }
    }
  }
}

or a hook that receives the model and returns the compaction settings, so plugins can compute a threshold at runtime.

Benefits

  • Predictable, model-aware compaction behavior for multi-model setups.
  • No wasted context on large models or over-aggressive compaction on small models.
  • Enables provider-level defaults with per-model overrides, consistent with how limit already works.
Reacted by Nils DEYBACH

Activity

  1. github-actions
    assigned
    rekram1-node
    on Aug 20, 2026
  2. github-actions commented on Aug 20, 2026

    @github-actions
    github-actionsBot
    on Aug 20, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of or closely related to existing issues. Please check:

    • [FEATURE]: Feature Request / Bug: Per-agent compaction control breaks local model workflows #34510: Per-agent compaction control — requests per-agent compaction enable/disable; overlaps in motivation (models with different context sizes behaving differently under a single global config)
    • compaction.reserved silently ignored for models without limit.input (e.g. GLM-5.2) — revival of #13980 #38835: compaction.reserved silently ignored for models without limit.input — directly related to reserved not working as expected per-model
    • [FEATURE] Add auto-compact threshold for long sessions #40113: Add auto-compact threshold for long sessions — requests a configurable compaction trigger threshold (global, not per-model, but similar space)

    If those don't cover your use case, this issue is distinct enough to stand on its own — the specific ask for per-model compaction overrides inside provider.<name>.models.<id> doesn't appear to have an exact match.

  3. zce commented on Aug 30, 2026

    @zce
    zce
    on Aug 30, 2026
    More actions

    Related context from #44094: if per-model compaction thresholds become a thing, the compaction model's own context window needs to participate in the preflight ceiling too — otherwise a smaller-window compaction model overflows exactly when compaction is needed most (see my comment on #44094 and #46164).

    Reacted by PMalfG
  4. PzaThief commented on Oct 17, 2026

    @PzaThief
    PzaThief
    on Oct 17, 2026
    More actions

    Opened #56443 with a V2 implementation.

    It adds an optional buffer to the existing provider/model settings.compaction policy. The effective value is model setting, then provider setting, then the top-level compaction.buffer. buffer stays an absolute token count.

    Feedback on the config shape is welcome.

  5. opencodejr commented on Oct 28, 2026

    @opencodejr
    opencodejrBot
    on Oct 28, 2026
    Contributor
    More actions

    Thanks for the clear write-up and the example config!

    You're asking for the compaction buffer (reserved in older configs, compaction.buffer in v2) to be set per model or provider, so a small local model and a large frontier model can each have their own headroom instead of sharing one global value. Right now v2 has a single top-level compaction.buffer for every model. The per-model settings.compaction doesn't have a buffer field yet. This can't be done with a plugin today either, because the plugin compaction settings are global and plugins aren't told which model is active.

    The maintainers will consider this. Related items:

    • feat(core): allow per-model compaction buffer #56443: open PR that adds a per-model/provider settings.compaction.buffer, falling back to the global compaction.buffer, and links to this issue
    • compaction.buffer: flat token count can't serve mixed model windows (no percentage or per-model form) #59994: the same request (per-model or percentage-based buffer), already pointed here as a duplicate
    • feat(opencode): support per-model compaction config #43713: an earlier PR for this issue, closed without being merged
    • compaction: buffer of 180,904 reduces 200k window ceiling to just 15k tokens #58774, [Bug] Auto-compaction fires at ~447k on a 1M-context model after model switch and fails with compaction.interrupted #57392: examples of how one global buffer behaves badly across very different context windows
  6. pma1999 commented on Nov 5, 2026

    @pma1999
    pma1999
    on Nov 5, 2026
    More actions

    Real-world case for this: one global buffer: "55%" keeps a 1M model at 450K but forces a 200K model to compact at 90K. Absolute per-model buffers would fix it cleanly: 200K -> 50K buffer (compact at 150K), 628K -> 345K (283K), 1M -> 550K (450K).

    Is the settings.compaction.buffer shape in #56443 (absolute tokens, model -> provider -> global fallback) the one you'd approve? If so, I can help test or refresh that branch.

  7. ksmeltzer commented on Nov 10, 2026

    @ksmeltzer
    ksmeltzer
    on Nov 10, 2026
    More actions

    We hit the same problem with 1M-context models where inflating buffer hurts smaller models, so I opened #61728 with a complementary approach: a configurable compaction.window (token ceiling for automatic compaction) rather than scaling buffer.

    It can be set globally (compaction.window), per provider/model/variant (settings.compaction.window), or per agent (agents.<id>.compaction.window), with precedence agent -> model/provider -> global (capped at the model's actual limit, while leaving the summary request's own budget at the model's real limit). That lets you set a global ceiling like "window": 180000 with a normal "buffer": 20000, or cap/opt-in specific models and agents directly.

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

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.