Repository navigation
fix(caching): scope automatic breakpoints to supported Claude transports - #41920
Conversation
|
@greptileai can you reply here with a score and why that score? Please review the final SHA and live evidence |
|
bugbot run |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
25d9b30 to
2b086dc
Compare
|
@greptileai review pls |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2b086dc. Configure here.
…e_injection_points_survive_client_marks Main's #41920 scoped the automatic breakpoints to supported Claude transports and taught the client-mark check to read the extra_body envelope. Both changes are kept: the defaults still stand down on any client mark, extra_body included. Configured injection points keep applying beside client marks, and the cap census now counts extra_body marks too, so a configured point never lands as a fifth block. test_new_transports_preserve_client_controls now expects configured points to apply beside client marks instead of standing down
TLDR
Problem this solves:
How it solves it:
The shared hook delegates provider eligibility to
llms/anthropic/common_utils.py. Chat seeding and affinity judge SDK alias targets, while native Messages retains its existing routing semantics. Client controls in the normal request orextra_bodysuppress gateway injection. Genericsupports_prompt_caching()remains unchanged for implicit-cache usage and pricingUser Flow
Before: OpenWebUI conversations with Vertex Claude do not receive automatic cache breakpoints
enable_anthropic_prompt_cachingon their gatewayhttp://localhost:16482, selectsvertex-sonnet, and sends a long reference followed by a second questionAfter: the same conversation receives cache breakpoints and gateway-attributed savings
enable_anthropic_prompt_cachingon their gatewayhttp://localhost:16482, selectsvertex-sonnet, and sends a long reference followed by a second questionRelevant issues
Related: #33573 deferred Vertex support because the provider also hosts Gemini. #41419 already filters unsupported Bedrock wire cache points; this fixes the earlier eligibility and attribution decision
Affected release
Linear ticket
Pre-Submission checklist
The mapped hook and Anthropic utility suites pass all 537 cases. All four response-round mutations are caught: chat alias identity, affinity alias identity, extra-body ownership, and Claude-family eligibility. The four caller suites produce 372 passes and the same one failure on both base and fix:
test_async_success_handler_truncates_large_base64_off_the_event_loop, asserting that the loop thread is absent from recorded scan threadsThe response-round
make checkpasses with CI's Python 3.12, including all four budget gates and formatting. Dashboard lint and both generated API artifacts passed on the initial revision; those files are unchanged by the response, whose staged scope skipped those checks. Final-revision CI and bot reviews are pendingScreenshots / Proof of Fix
All requests used synthetic content and paid upstream inference. Bedrock calls used AWS directly. Vertex requests traversed the actual Vertex adapter into a local recording relay, then a real gateway Vertex deployment; only local Google authentication was substituted. This verifies payloads, usage, attribution, and persistence, but is not a direct Google-credential test
The gateway enabled
enable_anthropic_prompt_caching: true, with aliasesvertex-sonnetforvertex_ai/claude-sonnet-5,bedrock-sonnetforbedrock/converse/global.anthropic.claude-sonnet-5, andbedrock-gptforbedrock/us.openai.gpt-6-astraReproduce the payloads and requests with an authenticated gateway using the same aliases:
Before (1d91fc2)
Chat completions
probe chat/completions vertex-sonnetResponses
probe responses responsesMessages
probe messages messagesBedrock model-family boundary
probe chat/completions bedrock-sonnet, thenprobe chat/completions bedrock-gptOpenWebUI conversation
http://127.0.0.1:16482, selectvertex-sonnet, send a long synthetic handbook asking forREADY ONE, then ask forREADY TWOusing the same referenceExisting Claude Code controls
READY ONE, then resume that session asking forREADY TWOAfter (2b086dc)
Chat completions
probe chat/completions vertex-sonnetcache-rig-vertexResponses
probe responses responsescache-rig-vertexMessages
probe messages messagescache-rig-vertexBedrock model-family boundary
probe chat/completions bedrock-sonnet, thenprobe chat/completions bedrock-gptOpenWebUI conversation
http://127.0.0.1:16482, selectvertex-sonnet, send a long synthetic handbook asking forREADY ONE, then ask forREADY TWOusing the same referencechatcmpl-00be1ebe-bde9-4b88-974a-8b5ae070bf92, with attribution tocache-rig-vertexExisting Claude Code controls
READY ONE, then resume that session asking forREADY TWO-pand--resumemodes, not an interactive TUIType
Bug Fix
Caveats
Medium
Low
Final Attestation
Note
Medium Risk
Changes when the gateway mutates outbound LLM payloads and spend attribution for prompt caching; mis-scoping could skip caching on Vertex/Azure or inject on wrong models, though tests and stand-down logic mitigate that.
Overview
Automatic Anthropic
cache_controlinjection is narrowed and extended so it only runs for Claude models on Anthropic, Bedrock, Vertex AI, and Azure AI, using a sharedsupports_anthropic_cache_control()helper instead of a Bedrock/Anthropic-only provider gate.Client-owned breakpoints are detected in both the top-level request and
extra_body, so gateway auto-injection stands down when the SDK putscache_controlin the envelope. Stand-down and default-injection paths now threadrequest_kwargsthrough configured injection-point judgment.Router cache affinity resolves
litellm.model_alias_mapbefore deciding defaults, so aliased models (e.g. router replacements) get the same eligibility as their target Claude deployment.Proxy/UI docs for
enable_prompt_cachingnow list Vertex AI and Azure AI. Tests cover new transports, non-Claude Bedrock/Vertex models,extra_bodycontrols, and alias-aware completion flows.Reviewed by Cursor Bugbot for commit 2b086dc. Bugbot is set up for automated code reviews on this repo. Configure here.