| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PR Found:
This PR appears to be related as it also addresses double compaction issues in sessions. You should verify if PR #26235 overlaps with the fix in PR #26484 or if they address different scenarios of the same problem. |
Sorry, something went wrong.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Sorry, something went wrong.
After compaction, filterCompacted retains tail assistant messages with stale cumulative token counts. The backward scan picks up these retained tails as lastFinished, and the overflow pre-check fires a second compaction immediately. Add a guard: only trigger auto-compaction when lastFinished is newer than the last compaction user message. Retained tails have older IDs, so they fail this check. Resolves anomalyco#26230 Resolves anomalyco#20621
|
I'm not sure if the root cause analysis is right. But it fixed the issue I encountered. May serve as a workround. |
Sorry, something went wrong.
|
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:
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. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Issue for this PR
Resolves #26230
Resolves #20621
Type of change
What does this PR do?
After auto-compaction, filterCompacted retains tail assistant messages that carry stale cumulative token counts (~100K). The backward scan in the prompt loop picks up these retained tails as lastFinished, and the overflow pre-check immediately fires a second compaction — every single time. This wastes tokens and doubles Copilot request consumption.
Root cause: The backward scan at prompt.ts:1418-1426 searches from the end of filterCompacted's output and breaks as soon as it finds lastUser + lastFinished. After compaction, the output is:
The scan finds lastUser=[21] and lastFinished=[20] (a retained tail), then breaks — never reaching the compaction part at [0]. Since tasks is empty, the compaction task handler is skipped. The pre-check then sees lastFinished with stale 103K tokens, isOverflow returns true, and a second compaction fires.
Fix: Add a guard that only triggers the overflow pre-check when lastFinished is newer than the last compaction user message. Retained tails have IDs older than the compaction user, so they fail this check.
4-line production change in packages/opencode/src/session/prompt.ts.
How did you verify your code works?
Screenshots / recordings
N/A — no UI changes.
Checklist