fix(anthropic): anchor rolling cache breakpoint before transient addendum - #48
Merged
Merged
Conversation
…ndum The per-call system addendum is appended to messages_for_call but never kept in history, and the rolling prompt-cache breakpoint was placed on msgs[-1] -- i.e. on the addendum. The next request replaces it with the real turn, so no conversation prefix was ever reused: cache_read stayed constant at the static head while cache_create re-wrote the whole conversation every turn. Flag the addendum `transient` (stripped by for_wire) and have the Anthropic provider anchor the rolling breakpoint on the last persistent message. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Problem
system_addendum_per_callis appended only tomessages_for_call(not history), and_add_prompt_cachemarkedmsgs[-1]— the addendum. Next turn it is replaced by the real assistant/tool turn, so the cached prefix never matches again. Observed in Forge (claude-sonnet-5, stateful-react-agent):cache_readconstant at 3610 every turn,cache_creategrowing; ~4x billed input vs claude_code.Fix
Message.transientflag (in-process only; dropped byfor_wire).transient.system_addendum_min_turn) behaviour is unchanged.Tests
for_wirestripstransient.Full suite: 1605 passed; ruff clean.
🤖 Generated with Claude Code