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): bound compaction summaries by the context window by wannesdecraene · Pull Request #60658 · anomalyco/opencode

Conversation

@wannesdecraene

@wannesdecraene wannesdecraene commented Oct 30, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

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

Copy link
Copy Markdown

Issue for this PR

Fixes #60648 (the confirmed summary-budget bug; automatic-compaction policy is unchanged).

Type of change

  • Bug fix

What does this PR do?

With a 256k context override and an inherited 922k input limit, compaction sized its summary against the larger input window, leaving only 1,024 output tokens.

Summary sizing now uses the smaller known input/context limit, including the decision to send the full conversation unchanged. Lower input limits, unknown context limits, native compaction and the automatic threshold keep their existing behavior.

Related: #58492 and #59226. Input-based automatic-compaction semantics remain tracked in #52954.

How did you verify your code works?

On Windows with Bun 1.4.4:

  • Both regression tests fail on the base: 1,024 instead of 40,000 output tokens, and an oversized request kept unchanged.
  • Four targeted compaction/model-request suites pass: 54 tests, repeated 10 times (540 passes).
  • bun typecheck, bun run typecheck:tsc, focused oxlint and Prettier checks pass.
  • Root bun run check passes lint but fails on the unchanged packages/app/src/custom-elements.d.ts symlink checked out as plain text on Windows.

Reproduce from packages/core: bun run script/test.ts test/session-compaction.test.ts test/session-compaction-transport.test.ts test/session-model-request.test.ts test/session-model-request-hooks.test.ts --rerun-each 10.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72">
  <style>
    .reply { animation: reveal 3s ease-in-out infinite; }
    @keyframes reveal { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
    @media (prefers-reduced-motion: reduce) { .reply { animation: none; } }
  </style>
  <g fill="none" stroke="currentColor" stroke-width="2">
    <rect x="8" y="10" width="132" height="52" rx="6" opacity=".4"/>
    <path d="M20 24h82M20 36h108M20 48h62" opacity=".6"/>
    <path d="M150 36h20m-6-6 6 6-6 6" opacity=".7"/>
    <rect x="180" y="16" width="52" height="40" rx="6" opacity=".4"/>
    <g class="reply"><path d="M190 27h32M190 36h32M190 45h22"/></g>
  </g>
</svg>

Screenshots / recordings

No UI change.

Checklist

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

Added by the opencode bot (AI-generated).

Related: #52954, #50574

Sorry, something went wrong.

Uh oh!

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

All reactions
Wannes and others added 2 commits October 30, 2026 17:34
Wannes
fix(core): bound compaction summaries by the context window
1118113
@wannesdecraene
Merge branch 'dev' into compaction-window
eaef130
@wannesdecraene
wannesdecraene marked this pull request as ready for review October 30, 2026 16:51
opencodejr[bot]
opencodejr Bot reviewed Oct 30, 2026
View reviewed changes

@opencodejr opencodejr 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. I ran the #60648 reproduction from source (context 256k, input 922k, buffer 40k, then /compact). On the base, the summary request and its retry go out with max_completion_tokens: 1024. With this PR they go out with 40000. The compaction and model-request suites pass, both new tests fail on the base, and tsc passes.

Public API: unchanged. Only internal sizing logic in packages/core/src/session/compaction.ts changes.

Concerns:

  • Overlap with #60648's other PR, #60660. #60660 makes the same min(input, context) change in both calculateCeiling and summaryRoom. That also moves the automatic compaction threshold under the context window. This PR deliberately keeps the threshold on the input limit. In the reported setup that threshold stays at 882k on a 256k window, so automatic compaction (and background precompute) can never start before the provider rejects the request; compaction then only happens through overflow recovery. Maintainers will need to pick one scope; see the inline note.
  • First new test is larger than it needs to be. It also checks the auto "skipped" case and runs a five-case table. The 256k/922k manual case, plus the oversized-conversation test, already cover the fix. Trimming it down to those would keep it easy to follow.

Related: #52954, #50574

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
.pipe(Effect.orElseSucceed(() => undefined)))) ??
context.model
const ceiling = calculateCeiling(model.limit, buffer)
const limit = native ? model.limit : { ...model.limit, input: summaryWindow(model.limit) }

@opencodejr opencodejr Bot Oct 30, 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 affects the summary's size. The due check in compact (and in precompute) still uses calculateCeiling(context.model.limit, …), so with context 256k and input 922k the automatic threshold stays at 882k, past the window. Automatic compaction can then only start through provider-overflow recovery. #60660 applies min(input, context) inside calculateCeiling, which fixes both at once and avoids keeping two window definitions side by side. Is keeping the input-based threshold intended here?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/test/session-compaction.test.ts
}),
)

it.effect("summary compaction bounds its budget by the context window without changing the input threshold", () =>

@opencodejr opencodejr Bot Oct 30, 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 test checks a lot for one fix: an auto "skipped" check plus a five-case table that reconfigures the shared buffer on each iteration. The 256k/922k manual case asserting maxTokens 40000 (and maybe the lower-input control) is enough. Could you cut it down to that?

Sorry, something went wrong.

Uh oh!

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

All reactions
@wannesdecraene

wannesdecraene commented Oct 30, 2026

Copy link
Copy Markdown
Author

PR is obsolete as @rekram1-node was too quick fixed in #60660

All reactions

Sorry, something went wrong.

Uh oh!

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

@wannesdecraene wannesdecraene closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[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.

core: context-only limit leaves compaction using conflicting window sizes

Uh oh!

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

1 participant

@wannesdecraene
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.