anomalyco / anomalyco/opencode
[FEATURE]: per-model compaction threshold (reserved/buffer)
@rekram1-node is already working on this.
Since Aug 20, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 384
Description
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
limitalready works.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.