Repository navigation
fix(core): keep the prompt cache when compaction retains sent messages - #54107
AnnoyingTechnology wants to merge 1 commit into
Conversation
Summary compaction sent only the older part. When the retained recent part held exchanges the provider had already seen, that request was a truncated copy of the session's last request, and breakpoint or recurrent-state caches missed on it. Summarize through the latest assistant reply when it fits, and fall back to the older part otherwise. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
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: |
|
Wow, it does work! I've hit multiple auto-compactions running this branch, and cache hit rate stays at 1 until the compacted (new) prompt is sent to the model. |
|
they fixed it in a different PR #57091 |
|
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 #52761
Fixes #52761
Type of change
What does this PR do?
Summary compaction sends only
split.older.recentstarts at a user message and usually holds exchanges the provider has already seen, so the summary request is a truncated copy of the last request instead of an extension of it. Caches that only match at their own breakpoints (Anthropic) or at saved recurrent states (hybrid models on SGLang) miss, and the older part is billed or prefilled again.When the compaction model is the session model and there is room, the summary request now runs through the latest assistant reply, so it extends the last request. Unanswered trailing input stays out and the stored
recentis unchanged. If that request is rejected as too long or too large, or the summary hits the output limit, it falls back to the existing older-only path. Both attempts share one retry allowance, and the autoStartedevent is published once.Known limitation: after a cut-off first reply, the mini TUI shows the discarded draft before the final summary, as the template-reminder retry already does. The stored summary is correct. This does not explain the OpenAI rows in #52761.
How did you verify your code works?
v2and pass here: wire-level prefix for manual and auto on OpenAI Chat, Responses and Anthropic Messages; fallback after a cut-off reply, without room, over the input limit; one retry allowance across the fallback; configured session model vs another model.bun run checkpasses.packages/corepasses except "isolates global home and XDG roots", which fails the same way onv2on this machine.Screenshots / recordings
Not applicable.
Checklist
Patch, tests and live runs by Claude Opus 5.5 (via Claude Code), for @AnnoyingTechnology. Reviewed by GPT 6.1 Sol (xhigh, via Codex).
🤖 Generated with Claude Code