fix(opencode): skip overflow check on compaction summaries#15129
Open
marklubin wants to merge 1 commit intoanomalyco:devfrom
Open
fix(opencode): skip overflow check on compaction summaries#15129marklubin wants to merge 1 commit intoanomalyco:devfrom
marklubin wants to merge 1 commit intoanomalyco:devfrom
Conversation
When running in headless mode (`opencode run`), the process exits after compaction when the compaction model's response exceeds the overflow threshold. This is because `isOverflow()` in processor.ts runs on the compaction model's own response, returning "compact" instead of "continue", so the synthetic continuation message is never created and the prompt loop exits. The fix adds a guard to skip the overflow check when the current message is already a compaction summary (`summary === true`), since re-compacting a compaction is never the intended behavior. 100% reproducible across 82 compaction events — all 11 deaths correlated with compaction responses exceeding the overflow threshold. Closes anomalyco#13946
6 tasks
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #14245: fix: compaction bugs #13946 and #13980 This PR directly addresses issue #13946, which is the same issue that current PR #15129 claims to close. PR #14245 appears to be an earlier attempt to fix the same compaction-related bugs. You should verify whether #14245 has already been merged or if it's still pending, as it may already contain a solution to this problem. |
This was referenced Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #13946
Type of change
What does this PR do?
In headless mode (
opencode run), the process exits cleanly after compaction when the compaction model generates a large response. The root cause is inprocessor.tsline 282:isOverflow()runs on the compaction model's own response tokens. When that response exceeds the overflow threshold,needsCompactionis set totrue, the processor returns"compact"instead of"continue", the synthetic continuation message is never created, and the prompt loop exits.The fix is a one-line guard: skip the
isOverflow()check wheninput.assistantMessage.summary === true(i.e., the current message is already a compaction summary). Re-compacting a compaction is never the intended behavior.This was 100% reproducible in my testing — across 82 compaction events, all 11 "deaths" (clean exits after compaction) correlated with compaction responses where total tokens exceeded the overflow threshold.
How did you verify your code works?
bun test packages/opencode/test/session/)write.test.ts— environment-specific umask issue, unrelated)Checklist