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 — feat(core): allow per-model compaction buffer by PzaThief · Pull Request #56443 · anomalyco/opencode

Conversation

@PzaThief

@PzaThief PzaThief commented Oct 17, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Issue for this PR

Closes #43703

Type of change

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

What does this PR do?

Adds an optional buffer to the existing per-provider/model compaction policy:

{
  "providers": {
    "openai": {
      "models": {
        "gpt-4.1": { "settings": { "compaction": { "buffer": 40000 } } }
      }
    }
  }
}

The effective buffer is the model setting, then the provider setting, then the top-level compaction.buffer. This lets models with different context windows keep independent headroom instead of sharing one global value. buffer remains an absolute token count; percentage scaling was intentionally not added.

How did you verify your code works?

  • bun test test/config/provider.test.ts test/config/compaction.test.ts test/session-compaction.test.ts in packages/core (49 pass)
  • bun test test/model.test.ts in packages/schema (9 pass)
  • bun run typecheck in packages/core, packages/schema, and packages/client
  • bunx oxlint on changed files
  • Regenerated packages/client types and packages/protocol/openapi.json; bun run check:generated in packages/protocol passes.
  • The pre-push full bun run check fails on packages/app/src/custom-elements.d.ts because this Windows checkout has symlinks disabled, unrelated to this change.

Screenshots / recordings

N/A — not a UI change.

Checklist

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

Sorry, something went wrong.

Uh oh!

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

All reactions
@PzaThief
feat(core): allow per-model compaction buffer
46dcc8a
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 17, 2026
@PzaThief PzaThief mentioned this pull request Oct 17, 2026
[FEATURE]: per-model compaction threshold (reserved/buffer) #43703
Open
1 task done
@github-actions

github-actions Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

All reactions

Sorry, something went wrong.

Uh oh!

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

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

This works as described, but one generated file needs updating before it's ready. I checked it with the core config, compaction and shared-schema tests and the schema model tests (all pass) and with type checks of packages/core and packages/schema (pass). I also read through the settings merge: Provider.mergeOverlay merges provider and model settings deeply, so a model { buffer } keeps the provider's type, and the order model → provider → top-level compaction.buffer holds. Using the session model's buffer for the "is it due" check and the compaction model's buffer for the summary budget is consistent, since each is measured against that model's own window.

Public API:

  • Config: adds settings.compaction.buffer (non-negative integer) to providers and models. Existing configs still validate.
  • Schema and SDK: Provider.Compaction / ProviderCompaction changes from { type: "summary" } | { type: "native" } to { type?: "summary" | "native"; buffer?: number }. Configs are backwards compatible, and a missing type still means summary. TypeScript code that read compaction.type as always set now has to handle undefined.
  • The OpenAPI document wasn't regenerated (see the inline comment).

Concern: packages/protocol/openapi.json is stale, so bun run check:generated in packages/protocol fails with this change but passes on the base.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/schema/src/provider.ts Resolved

Uh oh!

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

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

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

@PzaThief
chore(protocol): regenerate OpenAPI for compaction buffer
926ae54
This was referenced Oct 18, 2026
V2: compaction fires on first request / loops when compaction.buffer >= model context limit #56783
Closed
V2: compaction fires on the first request and repeats every turn when compaction.buffer >= model context limit #56813
Closed
A large compaction.buffer leaves small models no room before compaction #58146
Closed
compaction: buffer of 180,904 reduces 200k window ceiling to just 15k tokens #58774
Closed
@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
@cevr cevr mentioned this pull request Nov 4, 2026
[FEATURE]: per-agent compaction window #61696
Open
1 task done
@pma1999

pma1999 commented Nov 5, 2026

Copy link
Copy Markdown

Tested this branch locally against head 926ae54 (Windows, Bun 1.4.0):

  • packages/schema: full suite 69 pass / 0 fail; tsgo --noEmit clean.
  • packages/core: session-compaction.test.ts + config/provider.test.ts 48 pass / 0 fail; tsgo -b clean.

The model-level buffer overrides the global value in due() and survives the provider/model settings merge, which covers the mixed-window case (1M model with buffer: 550000 compacts at 450K; 200K model with buffer: 50000 compacts at 150K).

One rebase note: current dev has moved the buffer into selectModel(...), so this needs a refresh before it can merge (mergeable_state: dirty).

All reactions

Sorry, something went wrong.

Uh oh!

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

@pierangeloc pierangeloc mentioned this pull request Nov 13, 2026
[FEATURE]: Context-size warning in the sidebar, at absolute token thresholds #63732
Closed
1 task done
@github-actions

github-actions Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot closed this Nov 17, 2026
@github-actions github-actions Bot added the automated-pr-cleanup label Nov 17, 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

automated-pr-cleanup

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[FEATURE]: per-model compaction threshold (reserved/buffer)

Uh oh!

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

2 participants

@PzaThief @pma1999
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.