Repository navigation
fix(responses): keep a flagged hosted deployment's prompt cache breakpoint on the chat bridge - #45500
Conversation
…point on the chat bridge Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
bugbot run |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…kpoints on the chat bridge and base_model
|
bugbot run |
…_mantle_chat_breakpoint
…esolver so the recursion check passes Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
…od id in the federation e2e spec Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
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 5dcbf4e. Configure here.
…breakpoint an input item Since this branch was cut, main carries prompt_cache_breakpoint markers through the bridge on input items' content blocks (BerriAI#42281, BerriAI#44119, BerriAI#45500), and its tests expect a leading system message whose block carries one to stay an input item so the marker survives. Folding that message into `instructions` dropped the marker and broke eight of those tests. The fold now skips a leading system message any of whose blocks carries a prompt_cache_breakpoint, alongside the non-text case it already skipped. A block with only cache_control, the shape BerriAI#42171 reports, still folds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TLDR
Problem this solves:
integration-providersonmainfails those wire cells on every scheduled runHow it solves it:
base_modelUser Flow
Before: a developer whose app sends a long, stable system prompt to a Bedrock Mantle GPT-5.6 deployment never gets an explicit cache write, so every call pays full input price
gpt-5.6-mantletobedrock_mantle/openai.gpt-5.6-solwith a systemcache_control_injection_pointsentry and restarts the proxy"prompt_cache_options": {"mode": "explicit"}cache_creation_tokens: 0(chat) orcache_creation_input_tokens: 0(messages), so nothing was written to the explicit cachecached_tokens: 4978, only the implicit prefix, while POST /v1/responses with the same prompt writes 5196 and reads 5196 backAfter: the same two requests write the whole prefix on the first call and read it back on the second
cache_creation_tokens: 5198(chat) orcache_creation_input_tokens: 5195(messages), the whole system prompt written to the explicit cachecached_tokens: 5198, matching what /v1/responses already didCircleCI evidence
Red on
mainin the scheduledintegrationworkflow, jobintegration-providers: 2252740 (pipeline 91058), 2252168, 2251477Failing tests:
tests/integration/providers/test_bedrock_mantle_gpt_prompt_cache_breakpoint_wire.pychat and messages cells, andtests/integration/providers/test_openai_dialect_prompt_cache_breakpoint_owned_proxy.pytest_e6,test_f2,test_f3. The native responses cells were greenCulprit: #38729 (7c7b0ea) taught the hook to honour a hosted deployment's flagged row, so the hook adds the breakpoint, but the chat-to-Responses bridge gate from #44119 still asked
supports_openai_prompt_cache_breakpoint("openai.gpt-5.6-sol")with the provider-stripped name, got False, and stripped the marker again. The two PRs were green on their own branches and conflicted only in meaning once both were onmain, so the fix is in product code, not in the testsDecisions: the serving provider comes from
litellm_params["custom_llm_provider"], which the bridge already receives, so no new plumbing.base_modelgoes through the same provider-aware check, since an alias deployment names the same provider-stripped model there. The one existing function gains an optional provider instead of a second helper, so the hook and the bridge keep one source of truth. The resolver moves to module level instead of carrying areportPrivateUsagesuppressionAlso red on the PR pipeline after merging
main, jobintegration-browser(2253057):tests/e2e/ui/tests/integrationCritical/anthropicFederationCredential.spec.tstests at lines 287, 461 and 612. Green onmainat 91058 and 91062, somainturns red on its next schedule. Culprits: #43148 (0d17f95) renamed the dialog's name field to "Credential Name:" with a new placeholder, and #45528 (a3236ba) moved the auth select id fromanthropic_auth_methodtocredential_auth_method. Both changes are intentional, so the spec now finds the field by its label and the select by its accessible name, and also checks the Edit dialog keeps the name read-onlyPR branch pipelines: 91066 at fb1efa6, 91067 at 5dcbf4e
PR pipeline 91067 at 5dcbf4e:
build_and_testgreen,integration-browsergreen, and all 75 cells of the two Mantle and OpenAI-dialect breakpoint files green inintegration-providers(2253096). That job stays red only on tests outside this fix:test_native_passthrough_spend_rows_record_usage_tags_and_spendandtest_test_connection_evaluation_mode_uses_typesafe_decisions_path, both red onmainat 91062, andtest_worker_and_peer_outages_preserve_markers_and_recover, which hit the worker-kill shutdown failure below and was red the same way onmainat 91050Deferred, equally red on
mainat 91062 and not claimed here:e2e_ui_testing(usageActivityTabs.spec.tsModel Activity card foropenai/fake-gpt-4),integration-accounting(test_vertex_image_regional_uplift.pygated burst never holds all 20 requests,test_shutdown_flush.pyspend never converges),integration-extensions(test_arize_otel_v2_a_cache[messages]second call still carriesx-litellm-cache-key, red at 91058 and 91062),integration-management,mcp-integration,proxy_store_model_in_db_tests,llm_translation_testing, and the shared worker-kill shutdown failure ("Owned proxy required forced cleanup" or a 90s stop timeout after a worker SIGKILL) that hits chaos tests acrossintegration-accounting,integration-management,integration-extensionsandintegration-providersonmainand on this branchPre-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
Setup, both legs: the alias
gpt-5.6-mantlepinned tobedrock_mantle/openai.gpt-5.6-solwith a system injection point,LITELLM_LOCAL_MODEL_COST_MAP=True, no database,--num_workers 2, andapi_basepointed at a local forwarding recorder in front ofhttps://bedrock-mantle.us-east-1.api.awsthat stores every request body as Mantle receives it. Each endpoint sends the same body twice, 3 seconds apart: a 40-section system prompt of about 5.2k tokens whose first line carries a fresh run id, one user question,"prompt_cache_options": {"mode": "explicit"}, 64 output tokens. Before imports litellm from the merge base a3236ba, After from fb1efa6, both checked throughlitellm.__file__. The later tip 5dcbf4e only edits an e2e spec, so this run carries to itBefore (a3236ba)
POST /v1/chat/completions
cached_tokens 0, cache_creation_tokens 0, call 2cached_tokens 4978, cache_creation_tokens 0keys=['text', 'type'] prompt_cache_breakpoint=nullon both calls,cache_write_tokens 0POST /v1/messages
{"input_tokens":5180,"output_tokens":64}, call 2{"input_tokens":202,"cache_read_input_tokens":4978}prompt_cache_breakpoint=nullon both calls,cache_write_tokens 0POST /v1/responses
cache_write_tokens 5158, call 2cached_tokens 5158keys=['prompt_cache_breakpoint', 'text', 'type'] prompt_cache_breakpoint={"mode":"explicit"}on both callsUnchanged paths
openai/gpt-5.6through the chat bridge, twice: HTTP 200, OpenAI receivedprompt_cache_breakpoint={"mode":"explicit"}bedrock_mantle/openai.gpt-5.5, once: HTTP 200, Mantle received no markerAfter (fb1efa6)
POST /v1/chat/completions
cached_tokens 0, cache_creation_tokens 5156, call 2cached_tokens 5156keys=['prompt_cache_breakpoint', 'text', 'type'] prompt_cache_breakpoint={"mode":"explicit"}on both calls, call 1cache_write_tokens 5156POST /v1/messages
{"input_tokens":25,"cache_creation_input_tokens":5154}, call 2{"input_tokens":25,"cache_read_input_tokens":5154}prompt_cache_breakpoint={"mode":"explicit"}on both calls, call 1cache_write_tokens 5154POST /v1/responses
cache_write_tokens 5155, call 2cached_tokens 5155prompt_cache_breakpoint={"mode":"explicit"}on both callsUnchanged paths
openai/gpt-5.6through the chat bridge, twice: HTTP 200, OpenAI receivedprompt_cache_breakpoint={"mode":"explicit"}, same as Beforebedrock_mantle/openai.gpt-5.5, once: HTTP 200, Mantle received no marker, same as BeforeType
🐛 Bug Fix
Caveats (if any)
Low
gpt-version rule, sohosted_vllm/gpt-5.6keeps a caller-sent marker the same way it did before this PR. This is the fix(responses): keep prompt_cache_breakpoint markers in the chat to responses bridge #44119 fallback, unchanged here; changing it would redefine the gate for every provider, which the ticket did not ask for, so leaving it is the better tradebase_modelis checked with the deployment's served provider, but the injection hook reads onlymodel, so a deployment whosemodelhas no row and whosebase_modelis the flagged Mantle row keeps a marker the caller sent and gains no injected one. The same shape as before this PR, minus the provider; teaching the hookbase_modelis its own feature with its own proof, so not worth folding inpatch.object(AnthropicCacheControlHook, "_resolve_provider")no longer reach the bridge's gate, which now calls the module-level_served_provider_for_modeldirectly; they still pass because the hook's own_targetskeeps using the class attribute. Test-only, and rewriting them buys no product coverage, so left aloneFinal Attestation
Note
Medium Risk
Changes when explicit prompt-cache markers survive the chat-to-Responses path, affecting caching behavior and input billing for hosted OpenAI-dialect models; scope is limited to aligning the bridge with existing hook/cost-map logic.
Overview
Fixes chat/messages → Responses bridging so
prompt_cache_breakpointis not stripped for hosted OpenAI-dialect deployments (e.g. Bedrock Mantle GPT-5.6) when the serving provider’s cost-map row flags support.supports_openai_prompt_cache_breakpointnow accepts an optionalcustom_llm_providerand consults the same provider-keyed hosted-dialect flag the cache hook uses before falling back to model-name/version rules. The Responses transformation passeslitellm_params["custom_llm_provider"](and applies the same check tobase_model) when decidingkeep_prompt_cache_breakpoints. Provider resolution is factored into shared helpers (_served_provider,_served_provider_for_model).Playwright anthropic federation credential tests are updated for the credential dialog’s “Credential Name:” label, “Authentication:” combobox, and read-only name on edit.
Reviewed by Cursor Bugbot for commit 5dcbf4e. Bugbot is set up for automated code reviews on this repo. Configure here.