Repository navigation
fix(core): give compaction summaries the same output limit as normal turns - #57564
Conversation
There was a problem hiding this comment.
With the PR, summaries get the model's own output limit (up to 256k), still fitted to the room left in the window. I checked this with a temporary runner scenario: a 1M-context model with a 128k output limit, compacting at about 860k tokens, asked for a 32k summary on the base and a 128k summary with the PR. Windows of 200k and below keep the same limits, as described. The core session, compaction and model-request tests pass, and so does typecheck in packages/core.
Public API: unchanged. SessionModelRequest.outputLimit lost its kind parameter, but it's only used inside packages/core.
One concern, not blocking (inline): on large windows the summary now has very little margin for the token estimate running low.
Problem
Compaction summaries were capped at 32k output tokens, and thinking counts against that cap. On reasoning models at high effort the summary can spend the whole 32k thinking and fail with "Compaction summary reached the output token limit", even when the window has plenty of room left.
Example from #56766: Claude Haiku 5.5 at max effort, 1M window, 305k in, 32.0k out, failed. About 700k of the window was still free. Only the cap stopped it.
Change
Summaries now get the model's output limit (up to 256k), like a normal turn, sized to the room the request leaves in the window. Since the summary request is usually most of the window, it also keeps the same 15% margin for a low token estimate that normal turns use, and never gets less than before.
max_tokensis still always sent, so providers that need it explicitly (#42448) are unaffected, and the OpenAI plugin still strips it foropenai.Tradeoff
When the catalog lists a bigger window than the provider actually accepts, a summary with lots of apparent room can ask for more output than shrinking the input can make room for. Normal turns already behave this way. The fix for that is correcting those catalog limits.
Out of scope
length. Separate PR.Added by the opencode bot (AI-generated).
Fixes #56766
Related: #54797, #44609