You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
V2: compaction fires on the first request and repeats every turn when compaction.buffer >= model context limit #56813
With compaction.buffer set greater than or equal to the model's context limit, V2 starts automatic compaction on the very first request and re-triggers it on every turn or two. This emits meaningless structured summaries at session start and sometimes surfaces an internal Session.StepFailedError: Nothing to compact yet at server start.
Plugins
No response
OpenCode version
opencode v2.0.32 (Linux x64). The same config is also read by V1 1.19.0, but the looping behavior was observed on V2.
Steps to reproduce
Reproduced on opencode/mimo-v2.6-flash-free; the defect is model-agnostic (it depends only on the arithmetic below).
Start a V2 session (any directory, e.g. one with an AGENTS.md).
Send a single first message.
Watch the message stream: a compaction message is created immediately after the first user message (reason: "auto"), summarizing an empty history, and it repeats every 1-2 turns.
Startup log:
ERROR "Failed to drain Session" cause="Session.StepFailedError: Nothing to compact yet
at SessionRunner.runStep
at SessionRunner.drain
at ServerProcess.start"
Expected
An oversized buffer should be clamped to < context limit, or rejected with a clear warning at config-load time.
Compaction should not run when there is no older history to compact.
The internal StepFailedError should not surface as a user-facing failure at server start.
Actual
The trigger condition is estimated_tokens > context_limit - max(requested_output_tokens, buffer) (the docs describe buffer's default as 10% of the context limit). When buffer >= context_limit, the right-hand side is zero or negative, so the condition is always true and compaction fires on every step, including the first.
Because buffer is a single global value evaluated against each model's own limit, a value chosen for a large-context model (e.g. 400000 for a 1M-token model) breaks every smaller model in the same config.
Additional context / feature request
buffer and keep.tokens are configurable only in the top-level compaction block; per-model settings.compaction accepts only type: native|summary. That forces one compaction policy across models with very different context windows. Allowing a per-model (or per-provider) buffer, and/or an absolute "compact at N tokens" threshold, would let users choose safe compaction points for a 200k model and a 1M model without a single global value that is unsafe for one of them.
Thanks for the detailed report! I think this is a duplicate of #56783, which you opened earlier today with the same config, steps and Nothing to compact yet error. It has already been reproduced on v2.0.32 and on the latest dev.
Possible duplicates and closely related issues, ordered from most to least likely:
Closing this as a duplicate of #56783, which you opened earlier with the same config, steps and Nothing to compact yet error. There's been no reply here saying how this one is different. Please follow #56783 for updates. PR #56786 is open to fix it, and the per-model buffer request is tracked in #43703 and PR #56443. Until the fix lands, keeping compaction.buffer below the smallest context window among your models avoids the problem. If this turns out to be a different problem, reply here and we'll take another look.
Activity
opencode-agent commentedon Oct 18, 2026
Thanks for the detailed report! I think this is a duplicate of #56783, which you opened earlier today with the same config, steps and
Nothing to compact yeterror. It has already been reproduced on v2.0.32 and on the latestdev.Possible duplicates and closely related issues, ordered from most to least likely:
compaction.buffer>= context window makes automatic compaction run on the first request and on every turn). It has been reproduced.buffercan't trigger compaction on every turn. It also waits until there is older history before compacting automatically, and shows an automatic run with nothing to compact as skipped, not failed.buffer/threshold, which is the "Additional context" part of this issue. PR feat(core): allow per-model compaction buffer #56443 implements it.Until then, keeping
compaction.bufferbelow the smallest context window among the models you use avoids the problem.The bot will close this issue as a duplicate in 1 day unless you reply explaining how it differs from #56783.
opencode-agent commentedon Oct 19, 2026
Closing this as a duplicate of #56783, which you opened earlier with the same config, steps and
Nothing to compact yeterror. There's been no reply here saying how this one is different. Please follow #56783 for updates. PR #56786 is open to fix it, and the per-modelbufferrequest is tracked in #43703 and PR #56443. Until the fix lands, keepingcompaction.bufferbelow the smallest context window among your models avoids the problem. If this turns out to be a different problem, reply here and we'll take another look.