Repository navigation
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found two potentially related PRs (excluding the current PR #46136):
These PRs may overlap in scope or provide context for understanding the compaction system. You should review them to ensure this fix doesn't conflict with existing approaches or duplicate efforts. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Thanks for the related-PR pointers. I reviewed #10123, #43713, and #14393 against this diff to be precise about overlap: This PR is a bug fix, not a config feature. Overlap check:
In short: this fixes a base-level trigger bug that exists independently of those efforts; it is not a duplicate. Happy to rebase or fold this into #43713/#10123 if maintainers prefer a single change. |
|
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. |
Issue for this PR
Closes #46137
Type of change
What does this PR do?
Auto-compaction never triggers for large-context models like
opencode-go/hy3.The overflow check in
packages/opencode/src/session/prompt.tspassed only the last finished message's token count (lastFinished.tokens) intocompaction.isOverflow({ tokens, model }).isOverflowcompares that number againstusable(model) = model.limit.context - maxOutputTokens. For hy3 that is256000 - 64000 = 192000. A single assistant message is only ~20k tokens, so20000 >= 192000is always false and thecompaction.create({ auto: true })branch is never reached.This PR accumulates the cumulative token usage of the whole context and passes that to
isOverflow, so auto-compaction fires once the full context crosses the usable threshold.overflow.tsis unchanged.How did you verify your code works?
usagecorrectly (1927/1935 assistant messages carry real input/output/reasoning/cache token counts), so the bug is single-message-vs-cumulative, not missing usage.isOverflow/usable(model)math: for hy3,usable = 192000; cumulative context now reaches it and triggers compaction.prompt.ts(+28/−4); no behavior change for models where a single message already exceeds the threshold.Screenshots / recordings
Not a UI change.
Checklist