GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@rekram1-node rekram1-node commented Oct 23, 2026 •
edited by opencode-agent Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions
@rekram1-node
fix(core): ignore a compaction buffer that leaves the model no room
f73f173
opencode-agent[bot]
opencode-agent Bot reviewed Oct 23, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

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

Before

After

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/session/compaction.ts
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

@opencode-agent opencode-agent Bot Oct 23, 2026

Copy link
Copy Markdown
Contributor

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.

All reactions
@rekram1-node
rekram1-node merged commit 33726e8 into dev Oct 23, 2026
15 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node
rekram1-node deleted the ignore-invalid-buffer branch October 23, 2026 03:02
@thtesche thtesche mentioned this pull request Oct 24, 2026
compaction: buffer of 180,904 reduces 200k window ceiling to just 15k tokens #58774
Closed
@reynold-hu reynold-hu mentioned this pull request Oct 26, 2026
fix(core): bound auto-compaction when the buffer exceeds the window #56786
Closed
3 of 6 tasks
@opencodejr opencodejr Bot mentioned this pull request Oct 28, 2026
compaction.buffer: flat token count can't serve mixed model windows (no percentage or per-model form) #59994
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

A large compaction.buffer leaves small models no room before compaction V2: compaction fires on first request / loops when compaction.buffer >= model context limit

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@rekram1-node
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.