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: compaction bugs #13946 and #13980 by andrea-tomassi · Pull Request #14245 · anomalyco/opencode

Conversation

@andrea-tomassi

@andrea-tomassi andrea-tomassi commented Feb 19, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Issue for this PR

Closes #13946
Closes #13980

Type of change

  • Bug fix

What does this PR do?

This PR fixes two separate bugs in the compaction logic, both of which I hit while running opencode in headless/daemon mode.

Fix #13946 — Compaction crash in headless mode

When the compaction processor runs and the summary itself exceeds the context window (result becomes "compact"), the code path that creates the synthetic "Continue..." user message was being skipped. That message is what lets the next turn resume — without it, opencode run exits silently mid-session instead of continuing. The fix adds a check for result === "compact" alongside the existing result === "continue" check so the resume message is always created when running in auto mode.

Fix #13980 — compaction.reserved ignored for Claude / models without limit.input

The shouldCompact function computes how many tokens are "usable" before triggering a summary. For models that do have limit.input set, it correctly subtracts the reserved buffer. But for models that only have limit.context (e.g. Claude via GitHub Copilot), the fallback branch was computing context - maxOutputTokens, ignoring the configured reserved value entirely. This made it impossible to tune the compaction threshold on those models. The fix applies context - reserved in the fallback branch, consistent with the behavior for models with explicit input limits.

How did you verify your code works?

  • Ran the patched binary as the backing process for a persistent AI assistant that triggers compaction regularly. Confirmed opencode run no longer exits after compaction turns, and that the reserved threshold is respected correctly across sessions.
  • Ran turbo typecheck — no type errors.

Screenshots / recordings

N/A — no UI changes.

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
@andrea-tomassi
fix: compaction bugs anomalyco#13946 (exit after compact) and anomaly…
567e162
…co#13980 (reserved config ignored)
Copilot AI review requested due to automatic review settings February 19, 2026 07:00
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 19, 2026
Copilot started reviewing on behalf of andrea-tomassi February 19, 2026 07:01
View session
Copilot AI reviewed Feb 19, 2026
View reviewed changes

Copilot AI 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.

Pull request overview

This PR fixes two critical bugs in the compaction system that could cause opencode run to exit prematurely and prevent users from tuning compaction thresholds.

Changes:

  • Fixed #13946: Ensures synthetic "Continue..." message is created even when the compaction processor itself overflows, preventing premature exit in headless mode
  • Fixed #13980: Makes compaction.reserved configuration apply consistently to models with and without explicit limit.input, allowing users to tune the compaction threshold

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

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

All reactions
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Feb 19, 2026
@github-actions

github-actions Bot commented Feb 19, 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.

This was referenced Feb 20, 2026
fix: preserve thinking block signatures and fix compaction headroom asymmetry #14393
Closed
feat: Switch compaction model from session model #14665
Closed
fix: recover from 413 Request Entity Too Large via auto-compaction #14707
Merged
feat(compaction): preserve original user prompt across compaction #14846
Closed
@andrea-tomassi

andrea-tomassi commented Feb 24, 2026

Copy link
Copy Markdown
Author

Hey @thdxr and @adamdotdevin — gentle ping on this one 🙂 It's a small 2-line fix for two compaction bugs in headless/daemon mode. All checks pass, no conflicts. Would appreciate a review if you get a chance!

All reactions

Sorry, something went wrong.

Uh oh!

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

This was referenced Feb 25, 2026
fix(opencode): skip overflow check on compaction summaries #15129
Closed
fix(opencode): handle context overflow error by triggering compaction #15320
Closed
fix(session): prevent infinite loop in auto-compaction when assistant ended its turn #15532
Closed
@Lee-SiHyeon Lee-SiHyeon mentioned this pull request Mar 1, 2026
Auto-compaction infinite loop when assistant ended its turn (finish !== tool-calls) #15533
Closed
@github-actions github-actions Bot mentioned this pull request Mar 5, 2026
fix: improve compaction continuation to prevent agent from stopping #16073
Closed
3 of 6 tasks
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 2f2ed11 to 9f201d6 Compare April 16, 2026 21:55
@github-actions

github-actions Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

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 Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot 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.

Bug: compaction.reserved config is ignored for models without explicit 'input' limit Bug: opencode run exits after compaction when compaction model's token usage exceeds overflow threshold

Uh oh!

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

2 participants

@andrea-tomassi
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.