Repository navigation
Description
Description
I use a context override to keep prompts below the higher per-token pricing for long-context OpenAI prompts. I am not trying to set a separate max-input target; the context cost boundary is what matters to me.
On OpenCode Desktop v2.2.3, the Azure GPT-6 Luna model metadata from models.dev in my setup is context=1,050,000 / input=922,000 / output=128,000. My override sets context=256,000 and output=128,000, leaving input unset. With compaction.auto=true and buffer=40,000, the context panel reached about 225,000/256,000; Automatic compaction did not run. Manual /compact then sent max_output_tokens=1,024 and stopped at that cap; depending on reasoning tokens, it left a partial summary or no summary. Removing the model limit override lets manual compaction complete. Normal replies were unaffected.
The v2.2.3 source appears to use limit.input || limit.context for the compaction ceiling, but limit.context for summary output room. With these values, that suggests an 882,000-token ceiling and negative output room against the 256,000 context, clamped to 1,024. See calculateCeiling and outputLimit.
Is this behavior intended? If a context-only override is not meant to bound compaction, please clarify whether both fields must be set. My reason for setting context is to avoid higher long-context prompt pricing; I do not need a separate input-limit policy. If this behaves as designed, the fix is to add the same limit for input as I set for context in my settings. Related: #52954 and #59110.
Plugins
None found in user config; project-level plugins not verified.
OpenCode version
OpenCode Desktop/shared service v2.2.3. CLI v2.2.1 is installed but was not used for this reproduction.
Steps to reproduce
- Use the
azure/gpt-6-lunamodel or any other model from models.dev with the catalog limits above. Override only limit.context to 256000 (and leave limit.input unset); set compaction.auto=true and compaction.buffer=40000, or leave it unset as the default 15% will be in place. - Grow a session to about 225k while the context panel shows 256k. After an interrupted run, send another message. Automatic compaction does not start.
- Run /compact with the context override still set. The summary request uses max_output_tokens=1024 and stops at the limit. Remove the model limit override and retry; manual compaction completes.
Screenshot
No screenshot attached; can provide one if needed.
Operating System
Windows 11 Pro
Terminal
/ Desktop
Activity
opencodejr commentedon Oct 30, 2026
Thanks for the detailed report. I can confirm the
/compactpart on v2.2.3, and it still happens on the latestdev(da87c475a).What I did, with a simulated model whose limits match your setup (context 256,000 from the override, input 922,000 from the catalog, output 128,000) and
compaction: { auto: true, buffer: 40000 }:max_completion_tokens: 128000./compact. The summary request, and its retry, went out withmax_completion_tokens: 1024.inputleft out of the limit (context-only 256k), the same summary requests got40000.The script below reproduces it and logs the output limit of each request.
From the code, the cause looks like this: the compaction threshold and the summary request size come from
limit.input(922k − 40k buffer = 882k), but the summary's output room is worked out againstlimit.context(256k). That gives negative room, which is clamped to the 1,024 minimum.On automatic compaction not starting: the code uses the input limit for that by design. The missing docs for this are tracked in #52954. The 1,024 cap on the summary, though, is a real bug.
Until it's fixed, setting
inputto the same value ascontextin your override should make compaction work again. Related: #52954 (which limit sets the threshold), #59110 (reasoning tokens using up the summary budget, which makes a 1,024 cap worse), and #58492 (open PR changing the threshold calculation).Reproduction script (drive.ts)
Run it with opencode-drive:
opencode-drive run ./drive.ts. It drivesopencodefrom yourPATH; setOC_DEVto the path of an OpenCode checkout to run that from source instead.wannesdecraene commentedon Oct 30, 2026
I'd like to work on the summary-budget bug: with context=256000 and inherited input=922000, manual compaction incorrectly requests only 1024 output tokens. I'll add a regression test and keep changes to automatic-compaction policy separate. Is this scope sensible given #58492 and #59226? Later I could add the missing docs as the autocompaction not starting is by design.