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): keep room for the summary's reply when the compaction buffer is small by 2SinceJuly · Pull Request #59226 · anomalyco/opencode

Conversation

@2SinceJuly

@2SinceJuly 2SinceJuly commented Oct 26, 2026 •
edited by opencode-agent Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #59110

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

compaction.buffer was doing two jobs: reserving headroom before compaction and capping the summary's completion tokens. With a small buffer (2048 in the report) and a reasoning model, the model spends the whole budget thinking, so compaction fails with finish_reason: length and "Compaction summary reached the output token limit" even though the conversation fits the window.

The summary request now also keeps the default reserve free (15% of the window, or 16k) and aims the transcript at the rest, so the reply has room to reason before it writes the summary. buffer keeps its documented job of deciding when compaction triggers. Native compaction is untouched, and a buffer at or above the default reserve behaves exactly as before.

How did you verify your code works?

  • Added a regression test in packages/core/test/session-compaction.test.ts: with buffer: 2000 on a 200k window the summary request now asks for 30k output tokens instead of 2k. It fails on dev and passes with the change.
  • The four compaction suites in packages/core pass: 38 tests.
  • The same four suites pass in a Linux container (oven/bun:1.4.4, arm64): 38 tests.
  • bun typecheck in packages/core reports no type errors.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #56862, #58463

Sorry, something went wrong.

Uh oh!

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

All reactions
opencode-agent[bot]
opencode-agent Bot reviewed Oct 26, 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.

Looks good. I reproduced #59110 with the issue's opencode-drive script (128k/16k simulated model, compaction.buffer: 2048). On the base, the summary request goes out with max_tokens=2048 and fails with "Compaction summary reached the output token limit". With this change, it goes out with max_tokens=16000 and the summary is saved. The compaction test suites in packages/core pass, the new test fails on the base as expected, and tsc -b is clean.

The change only affects summary requests. When to compact and native compaction still use the buffer alone, and a buffer at or above the default reserve behaves as before. With a small buffer, the summary transcript now aims at about 85% of the window instead of the window minus the buffer, so more of the oldest history is shortened. That is the trade-off you'd expect for giving the reply room, and it matches the default.

Heads-up: #58492 also changes calculateCeiling. The two should combine cleanly, since summaryCeiling would then also reserve the model's output, but expect a textual conflict.

Public API: unchanged.

Related: #56862, #58463

Before

After

Sorry, something went wrong.

Uh oh!

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

All reactions
@2SinceJuly
fix(core): keep room for the summary's reply when the buffer is small
5a8fd8b
`compaction.buffer` was used both as headroom before compacting and as the
summary's output limit, so a small buffer left a reasoning model no tokens to
write the summary and `/compact` failed with a misleading output-limit error.

The summary request now also keeps the default reserve (15% of the window, or
16k) free and aims the transcript at the rest. Native compaction and buffers
at or above the default reserve are unchanged.
@2SinceJuly
2SinceJuly force-pushed the fix/compaction-summary-budget branch from ef69e2c to 50bf3f1 Compare October 27, 2026 07:21
opencode-agent[bot]
opencode-agent Bot reviewed Oct 27, 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.

Still looks good after the rebase. The fix is unchanged. Updating the two tests from #59441 that pinned the summary's maxTokens to the buffer is the right call, and the change fits #59441's new sizing: a larger output limit lowers the size up to which the conversation is sent unchanged. I re-ran the #59110 reproduction on the new base and on this head: the summary request goes from max_tokens=2048 with "Compaction summary reached the output token limit" to max_tokens=16000 with the summary saved. The compaction suites in packages/core pass (44 tests) and tsc -b is clean.

Public API: unchanged.

Before

After

Sorry, something went wrong.

Uh oh!

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

All reactions
@2SinceJuly
2SinceJuly force-pushed the fix/compaction-summary-budget branch from 50bf3f1 to 5a8fd8b Compare October 30, 2026 04:40
This was referenced Oct 30, 2026
core: context-only limit leaves compaction using conflicting window sizes #60648
Closed
fix(core): bound compaction summaries by the context window #60658
Closed
@2SinceJuly

2SinceJuly commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Parking this temporarily to free one of the repo's 3 open-PR slots: #59528 fixes a user-reported broken auth logout and is waiting on maintainers. Nothing is wrong with this change — I'll reopen it as soon as a slot frees.

All reactions

Sorry, something went wrong.

Uh oh!

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

@2SinceJuly 2SinceJuly closed this Nov 2, 2026
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.

compaction: reasoning tokens consume the summary budget, so compaction fails with "reached the output token limit"

Uh oh!

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

1 participant

@2SinceJuly
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.