Skip to content

fix(responses): keep a flagged hosted deployment's prompt cache breakpoint on the chat bridge - #45500

Merged
mateo-berri merged 5 commits into
mainfrom
litellm_circleci_heal_mantle_chat_breakpoint
Oct 9, 2026
Merged

mateo-berri merged 5 commits into
mainfrom
litellm_circleci_heal_mantle_chat_breakpoint

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Bedrock Mantle GPT-5.6 chat and messages requests lose the configured prompt cache breakpoint
  • The explicit cache is never written, so every call pays full input price
  • CircleCI integration-providers on main fails those wire cells on every scheduled run

How it solves it:

  • The chat-to-Responses bridge reads the deployment's provider-keyed cost-map row, the same row the hook reads
  • The bridge passes the serving provider for the model and for base_model
  • The provider resolver moves to module level so the gate needs no private-access suppression
  • The federation credential e2e spec follows the credential dialog's new name field and auth select

User 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

  1. The proxy admin pins gpt-5.6-mantle to bedrock_mantle/openai.gpt-5.6-sol with a system cache_control_injection_points entry and restarts the proxy
  2. The developer sends POST https://litellm-domain/v1/chat/completions (or /v1/messages) with a ~5,200-token system prompt, a one-line question, and "prompt_cache_options": {"mode": "explicit"}
  3. The 200 reports cache_creation_tokens: 0 (chat) or cache_creation_input_tokens: 0 (messages), so nothing was written to the explicit cache
  4. The same request sent again reports cached_tokens: 4978, only the implicit prefix, while POST /v1/responses with the same prompt writes 5196 and reads 5196 back

After: the same two requests write the whole prefix on the first call and read it back on the second

  1. The proxy admin pins the same deployment with the same injection point and restarts the proxy
  2. The developer sends the same POST https://litellm-domain/v1/chat/completions (or /v1/messages)
  3. The 200 reports cache_creation_tokens: 5198 (chat) or cache_creation_input_tokens: 5195 (messages), the whole system prompt written to the explicit cache
  4. The same request sent again reports cached_tokens: 5198, matching what /v1/responses already did

CircleCI evidence

Red on main in the scheduled integration workflow, job integration-providers: 2252740 (pipeline 91058), 2252168, 2251477

Failing tests: tests/integration/providers/test_bedrock_mantle_gpt_prompt_cache_breakpoint_wire.py chat and messages cells, and tests/integration/providers/test_openai_dialect_prompt_cache_breakpoint_owned_proxy.py test_e6, test_f2, test_f3. The native responses cells were green

Culprit: #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 on main, so the fix is in product code, not in the tests

Decisions: the serving provider comes from litellm_params["custom_llm_provider"], which the bridge already receives, so no new plumbing. base_model goes 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 a reportPrivateUsage suppression

Also red on the PR pipeline after merging main, job integration-browser (2253057): tests/e2e/ui/tests/integrationCritical/anthropicFederationCredential.spec.ts tests at lines 287, 461 and 612. Green on main at 91058 and 91062, so main turns 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 from anthropic_auth_method to credential_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-only

PR branch pipelines: 91066 at fb1efa6, 91067 at 5dcbf4e

PR pipeline 91067 at 5dcbf4e: build_and_test green, integration-browser green, and all 75 cells of the two Mantle and OpenAI-dialect breakpoint files green in integration-providers (2253096). That job stays red only on tests outside this fix: test_native_passthrough_spend_rows_record_usage_tags_and_spend and test_test_connection_evaluation_mode_uses_typesafe_decisions_path, both red on main at 91062, and test_worker_and_peer_outages_preserve_markers_and_recover, which hit the worker-kill shutdown failure below and was red the same way on main at 91050

Deferred, equally red on main at 91062 and not claimed here: e2e_ui_testing (usageActivityTabs.spec.ts Model Activity card for openai/fake-gpt-4), integration-accounting (test_vertex_image_regional_uplift.py gated burst never holds all 20 requests, test_shutdown_flush.py spend never converges), integration-extensions (test_arize_otel_v2_a_cache[messages] second call still carries x-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 across integration-accounting, integration-management, integration-extensions and integration-providers on main and on this branch

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. 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
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to 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-mantle pinned to bedrock_mantle/openai.gpt-5.6-sol with a system injection point, LITELLM_LOCAL_MODEL_COST_MAP=True, no database, --num_workers 2, and api_base pointed at a local forwarding recorder in front of https://bedrock-mantle.us-east-1.api.aws that 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 through litellm.__file__. The later tip 5dcbf4e only edits an e2e spec, so this run carries to it

model_list:
  - model_name: gpt-5.6-mantle
    litellm_params:
      model: bedrock_mantle/openai.gpt-5.6-sol
      aws_region_name: us-east-1
      api_base: http://127.0.0.1:<recorder port>
      cache_control_injection_points:
        - location: message
          role: system

Before (a3236ba)

POST /v1/chat/completions

  1. Send the body twice
  2. Proxy usage: call 1 cached_tokens 0, cache_creation_tokens 0, call 2 cached_tokens 4978, cache_creation_tokens 0
  3. Mantle received keys=['text', 'type'] prompt_cache_breakpoint=null on both calls, cache_write_tokens 0

POST /v1/messages

  1. Send the body twice
  2. Proxy usage: call 1 {"input_tokens":5180,"output_tokens":64}, call 2 {"input_tokens":202,"cache_read_input_tokens":4978}
  3. Mantle received prompt_cache_breakpoint=null on both calls, cache_write_tokens 0

POST /v1/responses

  1. Send the body twice
  2. Proxy usage: call 1 cache_write_tokens 5158, call 2 cached_tokens 5158
  3. Mantle received keys=['prompt_cache_breakpoint', 'text', 'type'] prompt_cache_breakpoint={"mode":"explicit"} on both calls

Unchanged paths

  1. openai/gpt-5.6 through the chat bridge, twice: HTTP 200, OpenAI received prompt_cache_breakpoint={"mode":"explicit"}
  2. Unflagged bedrock_mantle/openai.gpt-5.5, once: HTTP 200, Mantle received no marker

After (fb1efa6)

POST /v1/chat/completions

  1. Send the body twice
  2. Proxy usage: call 1 cached_tokens 0, cache_creation_tokens 5156, call 2 cached_tokens 5156
  3. Mantle received keys=['prompt_cache_breakpoint', 'text', 'type'] prompt_cache_breakpoint={"mode":"explicit"} on both calls, call 1 cache_write_tokens 5156

POST /v1/messages

  1. Send the body twice
  2. Proxy usage: call 1 {"input_tokens":25,"cache_creation_input_tokens":5154}, call 2 {"input_tokens":25,"cache_read_input_tokens":5154}
  3. Mantle received prompt_cache_breakpoint={"mode":"explicit"} on both calls, call 1 cache_write_tokens 5154

POST /v1/responses

  1. Send the body twice
  2. Proxy usage: call 1 cache_write_tokens 5155, call 2 cached_tokens 5155
  3. Mantle received prompt_cache_breakpoint={"mode":"explicit"} on both calls

Unchanged paths

  1. openai/gpt-5.6 through the chat bridge, twice: HTTP 200, OpenAI received prompt_cache_breakpoint={"mode":"explicit"}, same as Before
  2. Unflagged bedrock_mantle/openai.gpt-5.5, once: HTTP 200, Mantle received no marker, same as Before

Type

🐛 Bug Fix

Caveats (if any)

Low

  • A hosted deployment whose served provider has no row of its own still falls back to the bare gpt- version rule, so hosted_vllm/gpt-5.6 keeps 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 trade
  • base_model is checked with the deployment's served provider, but the injection hook reads only model, so a deployment whose model has no row and whose base_model is 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 hook base_model is its own feature with its own proof, so not worth folding in
  • The two existing tests that patch.object(AnthropicCacheControlHook, "_resolve_provider") no longer reach the bridge's gate, which now calls the module-level _served_provider_for_model directly; they still pass because the hook's own _targets keeps using the class attribute. Test-only, and rewriting them buys no product coverage, so left alone

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

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_breakpoint is 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_breakpoint now accepts an optional custom_llm_provider and consults the same provider-keyed hosted-dialect flag the cache hook uses before falling back to model-name/version rules. The Responses transformation passes litellm_params["custom_llm_provider"] (and applies the same check to base_model) when deciding keep_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.

…point on the chat bridge

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

devin-ai-integration Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue remains.

Summary

The PR keeps prompt_cache_breakpoint when the serving provider’s model row enables it. The bridge checks both model and base_model.

  • Chat and messages requests keep cache markers for flagged hosted models.
  • Federation credential tests follow the dialog’s current field labels.

Reviews (4) · Last reviewed commit: "test(ui): follow the credential dialog's..." · Reviewed by Greptile

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_circleci_heal_mantle_chat_breakpoint (5dcbf4e) with main (cdba36a)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (a3236ba) during the generation of this report, so cdba36a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

mateo-berri and others added 2 commits October 9, 2026 08:09
…esolver so the recursion check passes

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…od id in the federation e2e spec

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit bbe5595 into main Oct 9, 2026
123 of 127 checks passed
@mateo-berri
mateo-berri deleted the litellm_circleci_heal_mantle_chat_breakpoint branch October 9, 2026 11:00
poodle64 added a commit to poodle64/litellm that referenced this pull request Oct 10, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant