Uh oh!
There was an error while loading. Please reload this page.
fix: compaction bugs #13946 and #13980 - #14245
Conversation
…co#13980 (reserved config ignored)
There was a problem hiding this comment.
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.reservedconfiguration apply consistently to models with and without explicitlimit.input, allowing users to tune the compaction threshold
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
andrea-tomassi
commented
Feb 24, 2026
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! |
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. |
Issue for this PR
Closes#13946
Closes#13980
Type of change
What does this PR do?
This PR fixes two separate bugs in the compaction logic, both of which I hit while running
opencodein 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 runexits silently mid-session instead of continuing. The fix adds a check forresult === "compact"alongside the existingresult === "continue"check so the resume message is always created when running in auto mode.Fix#13980 —
compaction.reservedignored for Claude / models withoutlimit.inputThe
shouldCompactfunction computes how many tokens are "usable" before triggering a summary. For models that do havelimit.inputset, it correctly subtracts thereservedbuffer. But for models that only havelimit.context(e.g. Claude via GitHub Copilot), the fallback branch was computingcontext - maxOutputTokens, ignoring the configuredreservedvalue entirely. This made it impossible to tune the compaction threshold on those models. The fix appliescontext - reservedin the fallback branch, consistent with the behavior for models with explicit input limits.How did you verify your code works?
opencode runno longer exits after compaction turns, and that the reserved threshold is respected correctly across sessions.turbo typecheck— no type errors.Screenshots / recordings
N/A — no UI changes.
Checklist