feat(provider): apply system_and_3 multi-breakpoint cache strategy for Anthropic#905
Open
sytone wants to merge 19 commits into
Open
feat(provider): apply system_and_3 multi-breakpoint cache strategy for Anthropic#905sytone wants to merge 19 commits into
sytone wants to merge 19 commits into
Conversation
…r Anthropic Extends ApplyLastUserMessageCacheControl into ApplyMultiBreakpointCacheControl which places cache-control breakpoints on the last 3 non-system messages, matching the Anthropic system_and_3 strategy. Anthropic supports 4 cache breakpoints total; the system prompt already consumes one, so up to 3 more are placed on recent messages. - Add ApplyMultiBreakpointCacheControl(messages, retention, baseUrl, maxBreakpoints=3) walking backwards from the last message, stamping up to maxBreakpoints entries - Preserve ApplyLastUserMessageCacheControl as a 1-breakpoint delegate for back compat - Update AnthropicRequestBuilder to call ApplyMultiBreakpointCacheControl directly - Add InternalsVisibleTo for test project access to internal converter methods - 10 new tests: None no-op, 1-turn, 2-turn, 3-turn, 5-turn, string-content wrapping, assistant block attachment, BuildCacheControl Short/Long/NonAnthropicUrl variants Closes #804 Part of #702
Owner
Author
PR Review -- #905
Responses to comments:
Notes:
Farnsworth (autonomous maintenance) -- BotNexus -- Last updated: 2026-06-08 05:24 UTC |
This was referenced Jun 6, 2026
added 9 commits
June 6, 2026 12:04
Owner
Author
|
This needs a full review after the recent reactors in the providers, |
This was referenced Jun 7, 2026
Merged
4 tasks
added 7 commits
June 7, 2026 16:23
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.
Closes #804
Part of #702
Changes
AnthropicMessageConverter.cs
AnthropicRequestBuilder.cs
BotNexus.Agent.Providers.Anthropic.csproj
AnthropicCacheControlTests.cs (new)
10 new tests: None no-op, 1-turn, 2-turn, 3-turn, 5-turn (max 3), string wrapping, assistant blocks, BuildCacheControl Short/Long/NonAnthropicUrl.
Tests
Merge Notes
Independent -- zero file overlap with any open PR. Safe to merge in any order.