GeezerVison is showing github.com — fix(core): ignore a compaction buffer that leaves the model no room by rekram1-node · Pull Request #58313 · anomalyco/opencode
Conversation
rekram1-node
commented
Oct 23, 2026
•
edited by opencode-agent
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
A compaction.buffer set for a large model can be bigger than a smaller model's whole window. The ceiling is window - buffer, so it goes to zero or below and automatic compaction is due on every step.
- if (buffer !== undefined) return window - buffer
+ if (buffer !== undefined && buffer < window) return window - buffer
A buffer that leaves no room is now ignored, and the default reserve (15% of the window, at least 16k) applies. The docs note it next to buffer.
Fixes #56783
Fixes #58146
Added by the opencode bot (AI-generated).
Related: #43703
Public API: a compaction.buffer at or above the model's window is now ignored in favour of the default reserve (backwards compatible)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix works. With the #56783 reproduction (128k simulated model, compaction.buffer: 600000), the base runs a failed automatic compaction after every message and gives no replies. With this PR both messages get normal replies and no compaction runs. session-compaction.test.ts and tsc for packages/core pass.
Public API: no keys are added or removed. compaction.buffer now has a different meaning in one case: a value at or above the model's window is ignored and the default reserve applies. This is backwards compatible; before, such values made compaction run on every turn.
One non-blocking point, inline: a buffer just under the window still leaves almost no room.
For comparison, #56786 takes the same approach and #58147 caps the buffer at a quarter of the window instead.
Related: #43703


Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
if (window <= 0) return Number.POSITIVE_INFINITY
|
|
|
if (buffer !== undefined) return window - buffer
|
|
|
// A buffer that leaves no room, such as one set for a larger model, is ignored.
|
|
|
if (buffer !== undefined && buffer < window) return window - buffer
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only helps once the buffer reaches the window, so a buffer just under it still leaves no usable room. For example, buffer: 127_999 on a 128k model gives a ceiling of 1, so compaction is due every turn, and selectModel sizes the summary request to that same ceiling. 128_000 falls back to the default. A buffer sized for a 1M model will often sit just under a smaller window rather than above it. Could the fallback also apply when window - buffer would drop below some minimum, such as RESERVE_MIN or the default ceiling?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|