Repository navigation
fix(prompt-caching): default injected /v1/messages breakpoints to implicit lookup - #45121
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ryan-crabbe-berri
enabled auto-merge (squash)
October 7, 2026 18:38
Contributor
|
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.
TLDR
Problem this solves:
/v1/messageson GPT-5.6 still sendsprompt_cache_options: {"mode": "explicit"}for configured breakpointsindex: -1checkpoint rewrites instead of reading/v1/chat/completionsand/v1/responsesonlyHow it solves it:
/v1/messagesinjection path now defaults to{"mode": "implicit"}, same as the chat pathprompt_cache_optionsfrom the caller orlitellm_paramsstill winsIntentional product change: configured breakpoints arriving on
/v1/messagesnow also let OpenAI keep its automatic checkpoint and read earlier prefixes. Deployments that want explicit-only writes setprompt_cache_options: {mode: explicit}inlitellm_params, the same opt-in the chat path has had since #42281User Flow
Before: a developer using the Anthropic SDK or Claude Code against a GPT-5.6 deployment with configured breakpoints sees cache reads stall while writes keep growing
cache_control_injection_points(role: systemandindex: -1) on anopenai/gpt-5.6deploymentcache_creation_input_tokens: 2609tool_useandtool_resultand returnscache_read_input_tokens: 2144,cache_creation_input_tokens: 1415cache_read_input_tokens: 2144again withcache_creation_input_tokens: 1883, so what turn 2 wrote is never read backAfter: the same conversation reads back everything the previous turn wrote
cache_control_injection_pointson the same deploymentcache_creation_input_tokens: 2609cache_read_input_tokens: 2609,cache_creation_input_tokens: 950cache_read_input_tokens: 3559,cache_creation_input_tokens: 468Relevant issues
Follow-up to #42281
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Both runs hit the real OpenAI API through a DB-less proxy started from the given commit with
python litellm/proxy/proxy_cli.py --config cache_mode_config.yaml --port <port> --detailed_debug. The salt in the system prompt keeps the two runs on separate OpenAI cache prefixesBefore (740d043)
bash messages_turns.sh 4281 before-r1Every one of the three upstream
litellm.aresponses(...)calls in the proxy log carriesprompt_cache_options={'mode': 'explicit'}. Turn 3 reads the same 2144 tokens turn 2 read and rewrites 1883, so the moving checkpoint never pays offAfter (98c4d35)
bash messages_turns.sh 4282 after-r1Every one of the three upstream
litellm.aresponses(...)calls in the proxy log carriesprompt_cache_options={'mode': 'implicit'}. Turn 2 reads all 2609 tokens turn 1 wrote and turn 3 reads all 3559 tokens turn 2 left cachedType
🐛 Bug Fix
Caveats (if any)
Low
/v1/messagesare now an opt-in viaprompt_cache_options: {mode: explicit}inlitellm_paramsexplicitdefault back failstest_v1_messages_and_chat_paths_default_to_the_same_implicit_modeandtest_v1_messages_string_system_gets_block_breakpoint, so the two paths cannot drift apart again silently