Repository navigation
fix(responses): keep cache breakpoints on blocks the bridge stringifies - #40032
Conversation
…ponses API The chat-completions bridge rebuilt every content block without the prompt_cache_breakpoint marker the cache-control hook had just placed on it, so the request went out with prompt_cache_options set to explicit mode and nothing actually marked. Explicit mode caches only what is marked, so those deployments lost the implicit caching they were getting before the injection point was added The native surface had a second miss. The bridging check looked the provider config up with the still-prefixed model while the config keys on the bare one, so every bedrock_mantle model read as having no native Responses support, and role-targeted injection points were deferred to a chat-completions pass that never runs for them
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
bugbot run |
|
bugbot run |
|
bugbot run |
| patch.object( | ||
| import_module("litellm.responses.mcp.litellm_proxy_mcp_handler").LiteLLM_Proxy_MCP_Handler, | ||
| "_should_use_litellm_mcp_gateway", | ||
| return_value=False, | ||
| ), | ||
| patch.object( | ||
| import_module("litellm.responses.main").base_llm_http_handler, | ||
| "response_api_handler", | ||
| return_value=MagicMock(), |
There was a problem hiding this comment.
Tests Monkeypatch Class Attributes
These new tests replace class and module attributes with patch.object. The repository requires dependency injection for test doubles, so this must be addressed before merging. The same pattern also appears at lines 411-419
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…onses_prompt_cache_breakpoint # Conflicts: # litellm/completion_extras/litellm_responses_transformation/transformation.py # litellm/responses/main.py # tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py
…ady routes the hook #42281 landed the text, image_url and file branch carry and the implicit default on main, and the Responses routing lookup this branch changed has no observable effect there, so the PR shrinks to the unknown-block fallback branch and its regression test
|
bugbot run |
…arams in the chat-to-Responses bridge
…_params OpenAI's Responses API takes a ttl of 30m on an explicit breakpoint marker, so the drop_params validation keeps it instead of stripping it as an unknown key. Trims the bridge test docstrings to the dated vendor citation.
…e chat-to-Responses bridge Adds the /audit cells for the bridge's prompt_cache_breakpoint carry: valid and malformed markers on every carrying block kind and on tool and assistant content, the drop_params on and off contract, the hook-injected system marker, the Anthropic SDK path through the Responses adapter, upstream errors, idempotent spend rows, and the chaos cells (mixed burst, upstream outage, slow streams, worker SIGKILL and a proxy restart mid burst), all against a scripted Responses endpoint with the request it received read back by response id
…onses_prompt_cache_breakpoint # Conflicts: # litellm/completion_extras/litellm_responses_transformation/transformation.py # tests/integration/providers/test_responses_bridge_prompt_cache_breakpoint_chaos.py
The prompt-cache-breakpoint audit's scripted upstream minted the response id from the request's marker, so three identical marked requests shared one id. The spend-log writer skips rows whose request_id already landed, and the idempotent-logging cell saw one row for three calls on every leg. The upstream now mints a unique id per reply like a real provider, and the cells match a response to its request by the marker inside that id.
|
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 0135dad. Configure here.
#40032 landed first and added the wire helper that drops a malformed prompt_cache_breakpoint under drop_params, so the input_audio branch now carries its marker through that helper like the text and image branches, with a regression test for the malformed case. Main's unknown-block marker test used input_audio as its unmappable example and now uses a video_url part. The audio test fixture registers its fake models through monkeypatch on the price map, so nothing leaks into the provider model sets, and the new tests carry the Final and fixture annotations the repo asks for
TLDR
Problem this solves:
input_audio) cached nothingprompt_cache_options: {mode: explicit}are affecteddrop_paramson, a malformed hand-written marker on a text, image or file block still reached the provider and failed the whole requestHow it solves it:
prompt_cache_breakpoint, like the text, image and file branches already dodrop_params, a marker that is not a validPromptCacheBreakpointis dropped on every carrying branch instead of reaching the provider; withoutdrop_paramsit goes out verbatim and the provider's 400 names the fieldPromptCacheBreakpointgains thettl: "30m"field OpenAI accepts, so a valid ttl survives that validationUser Flow
Before: a developer whose OpenAI deployment runs over the Responses API with explicit prompt caching sends a system prompt that ends in an audio block, and their cached token count stays at zero
openai/responses/gpt-6.1-solwithprompt_cache_options: {mode: explicit}and acache_control_injection_pointsentry forrole: systeminput_audioblock, plus a one word user message"prompt_tokens_details": {"cached_tokens": 0}"cached_tokens": 8104, so the breakpoint works until the prompt ends in a block the gateway cannot mapAfter: the same block-split system prompt reads its cached prefix on the second request
"cached_tokens": 0and the second with"cached_tokens": 8140"cached_tokens": 8104on its second call, so the two shapes now agreeBefore, with
drop_params: true: a developer hand-writesprompt_cache_breakpoint: "yes"on the system text block of a POST https://litellm-domain/v1/chat/completions request, and the whole request failslitellm_settings: drop_params: trueInvalid type for 'input[0].content[0].prompt_cache_breakpoint': expected an object, but got a string insteadAfter: the same request answers 200 with the malformed marker left out
drop_paramsstill gets OpenAI's 400 naming the fieldRelevant issues
None filed on GitHub
#42281 landed the breakpoint carry for the text, image and file branches of this conversion and made the hook leave OpenAI's implicit caching on unless the caller asks for explicit mode. This PR finishes the one branch it left out. An earlier revision also changed how the Responses entry point decides whether a request bridges to chat completions; that part was dropped because main already behaves the same there end to end
#38729 is separate: it decides which hosted deployments are eligible for an OpenAI-dialect breakpoint. Nothing here changes eligibility
Linear ticket
Part of LIT-7108, which also tracks follow-ups that stay open after this merges
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
Last updated: 0135dad. QA and /live-pr-risk ran on eca0a96, the last commit written for this PR's product code; 18a8185 merges main (which landed #44119, the same bridge's strip of
prompt_cache_breakpointfor models without breakpoint support) into the branch, resolves the conflict so both behaviors compose, and ships this audit'stests/integrationcells; 0135dad changes only those cells (its scripted upstream now mints a unique response id per reply). The product diff against the merge base bf9bd35 is the same three behaviors as before, threaded through the converter main renamed. /live-pr-risk's merged-tree check and the /qa probes were re-run at 18a8185 (below the A/B section), and /audit ran every cell at 0135dad against bf9bd35, its live OpenAI rows at 18a8185Shared setup. Two proxies on the same box, one booted at the merge base and one at the PR tip, each from its own worktree, both with 2 uvicorn workers, no database, hitting the real OpenAI API:
Each case sends the same ~8000 token system prompt twice and reads the cached token count back. Every case picks its own nonce, so no case reads a prefix another case already cached.
blockssends the system prompt as a text block followed by aninput_audioblock, which is the block type the bridge has no mapping for;textsends it as one plain string:The
/v1/messagescontrol sends the same system prompt through the Anthropic-shaped route:/v1/responseson this deployment goes to OpenAI natively and never runs the chat-to-Responses conversion this PR changes, so it has no caseBefore (7921716)
/v1/chat/completions, explicit mode, system prompt as blocks ending in input_audio
zsh proof_case.sh 29818 cache-explicit blocks/v1/chat/completions, explicit mode, system prompt as a plain string
zsh proof_case.sh 29818 cache-explicit text/v1/chat/completions, default mode, same block-split prompt
zsh proof_case.sh 29818 cache-default blocks/v1/chat/completions, no injection point
zsh proof_case.sh 29818 cache-nopoints text/v1/messages, explicit mode deployment
zsh proof_messages_case.sh 29818 cache-explicitAfter (eca0a96)
/v1/chat/completions, explicit mode, system prompt as blocks ending in input_audio
zsh proof_case.sh 37130 cache-explicit blocks/v1/chat/completions, explicit mode, system prompt as a plain string
zsh proof_case.sh 37130 cache-explicit text/v1/chat/completions, default mode, same block-split prompt
zsh proof_case.sh 37130 cache-default blocks/v1/chat/completions, no injection point
zsh proof_case.sh 37130 cache-nopoints text/v1/messages, explicit mode deployment
zsh proof_messages_case.sh 37130 cache-explicitLive A/B against the merge base (/live-pr-risk)
Rig: three no-DB proxies with 2 uvicorn workers each, base 7921716 and head eca0a96 from the same config plus a second head proxy from that config minus
drop_params: true, each with its own forwarding recorder in front of api.openai.com (the recorder logs the request and forwards it, so every call hit the real provider). Deployments:openai/responses/gpt-6.1-solwith and withoutprompt_cache_options: {mode: explicit}plus a system injection point,bedrock_mantle/openai.gpt-6.1-sol,xai/grok-4.20-multi-agent,perplexity/openai/gpt-5.2,drop_params: true. Same cells in the same order on the base and head sides; the proxy withoutdrop_paramsran the four cells of its own table[text, input_audio], two callsstream: true{"mode": "explicit"}on theinput_audioblock, no injection point, on OpenAI, Bedrock Mantle, xAI, Perplexitytextblockinput_audioblock (string, int, list, empty string, 5 KB string,{"mode": "bogus"}),drop_paramson{"mode": "explicit", "ttl": "1h"}on theinput_audioblock,drop_paramson{"mode": "explicit", "ttl": "30m"}on theinput_audioblockinput_audioblockstextblock,drop_paramsonexpected an object, but got a stringPOST /v1/responsescarrying the markerSame head,
drop_paramsoff:drop_paramsinput_audioblockexpected an object, but got a string instead{"mode": "bogus"}on theinput_audioblockInvalid value: 'bogus'. Value must be 'explicit'{"mode": "explicit", "ttl": "1h"}on theinput_audioblockInvalid value: '1h'. Supported values are: '30m'{"mode": "explicit", "ttl": "30m"}on theinput_audioblockWire: 17 recorded OpenAI requests per side, one per cell that reached the provider, plus 4 on the proxy without
drop_params. After dropping the recorder's own timestamps and the per-side nonce, the differences between base and head are the addedprompt_cache_breakpointon the second (input_text) item of the system message where the source block carried a valid one (both items on the duplicate cell,modeplusttlon the 30m cell) and, on the string-marker text cell, the base'sprompt_cache_breakpoint: "yes"gone from the head's request. The malformedinput_audiocells carry no marker on either side (the base stringified the block, the head dropped the marker). The proxy withoutdrop_paramssent every marker verbatim, the string,bogusand1hones included. No header, path, or request-count changeSuites on the head tree: the mapped unit files (bridge transformation, cache-control hook) pass, and the three
tests/llm_translation/test_openai.pytests that runopenai/responses/*through the bridge pass against the live API. The twotests/integrationfiles namingprompt_cache_breakpointdrive Anthropic deployments, which never enter this bridge, and no integration fixture marks a bridged block, so they were not run here (that suite needs its CircleCI harness)Findings
textblock withdrop_paramson goes from OpenAI's 400 to a 200 with the marker droppeddrop_paramson, aprompt_cache_breakpointthat does not validate asPromptCacheBreakpoint(mode: "explicit", optionalttl: "30m") is dropped on every carrying branch (text,image_url,fileand the fallback), where fix(responses): preserve prompt cache reuse in chat bridge #42281 forwarded it verbatim on the first three and OpenAI answered 400 naming the field. Withdrop_paramsoff nothing changes on those three branches, and the fallback branch joins them: the marker goes out verbatim and the provider's 400 names the field, where main stringified the whole block and answered 200. Both halves follow the repo'sdrop_paramsconvention (an unsupported or malformed value drops underdrop_paramsand answers 400 without it, the shape o-seriestemperaturetakes), chosen over two alternatives: dropping only the offending key (keepingmodewhenttlis wrong, which sends a marker the caller did not write) and forwarding verbatim regardless ofdrop_params(what the previous revision of this PR did, recorded as a Low caveat). The validation treats the marker as one unit: a badmodeorttldrops the whole marker, an unknown key is left out.ttljoined the type because OpenAI accepts"30m"(its 400 on 2026-10-07:Invalid value: '1h'. Supported values are: '30m') and the type without it would have stripped a valid ttl underdrop_params. Shipped in f2c6ade and eca0a96drop_paramsdefault of off, so they see the same verbatim markers as before, and were not driven_prompt_cache_breakpoint_for_wire-> the four carrying branches of_convert_content_to_responses_format->convert_chat_completion_messages_to_responses_api->transform_request, which readsdrop_paramsfrom the call's litellm params or the global setting, verified live streaming and not, with and withoutdrop_params; the noma guardrail, Responses guardrail translation and complexity router callers, untested here; every Responses-mode provider receiving bridged input: OpenAI verified for cache hits and for the 400s, Bedrock Mantle, xAI and Perplexity verified for statusObservations
input_audioblocks go out asinput_textrepr, pre-existing, unchanged hereusermessage instead caches the bulkimageblocks fail validation with a 500, pre-existingAudit (/audit, 0135dad vs bf9bd35; live rows at 18a8185)
Every cell below is a checked-in
tests/integration/providers/test (test_responses_bridge_prompt_cache_breakpoint_wire.py,test_responses_bridge_prompt_cache_breakpoint_wire_chaos.py, helpers intests/integration/_support/prompt_cache_breakpoint.py; main's owntest_responses_bridge_prompt_cache_breakpoint*.pyfiles from #44119 are untouched), run withuv run --no-sync python tests/integration/run.py providers <node ids>on a two-worker proxy with its own Postgres database, Redis and owned upstream per leg, the Responses deployment pointed at a scripted Responses endpoint that records every request it receives. Each cell reads back the client's response, the request on the wire and the spend row bylitellm_call_id. The merge-base leg ran the same cells against bf9bd35 (its tests overlaid); the head leg ran them twice at 0135dad (lanesround3-head-run1277 s andround3-head-run2on the head leg,round3-base285 s on the base leg, run one after the other since the box had under 4 GB free per lane;round3-baselost one cell,test_flipping_drop_params_mid_burst_keeps_every_marked_request_answered, to the harness client's 15 s ReadTimeout on/model/updatewhile the base proxy logged a localhost Redis read timeout in the same second and another rig's four lanes ended on the box, so that one cell re-ran on the base leg asround3-base-e3once the box was quiet (passed, 7.0 s) and the matrix names that lane on its row). The fourLrows are live cells against the real OpenAI API through the same proxies (openai/responses/gpt-6.1-sol, a model main's new strip rule keeps breakpoints for), run once per leg at 18a8185 and kept over the tests-only 0135dad, not committed; their artifacts are the proxy response, the OpenAIresponse_id, usage and the spend row per legwire::test_openai_sdk_sends_a_valid_marker_through_the_bridgewire::test_openai_sdk_stream_carries_the_system_list_markerwire::test_async_openai_sdk_keeps_the_ttl_without_drop_paramswire::test_valid_marker_shapes_reach_the_wire_unchanged[explicit-on]wire::test_valid_marker_shapes_reach_the_wire_unchanged[explicit-off]wire::test_valid_marker_shapes_reach_the_wire_unchanged[ttl-on]wire::test_valid_marker_shapes_reach_the_wire_unchanged[ttl-off]wire::test_marker_with_an_unknown_key[normalized-on]wire::test_marker_with_an_unknown_key[verbatim-off]wire::test_valid_marker_is_carried_on_every_block_kind[text-on]wire::test_valid_marker_is_carried_on_every_block_kind[text-off]wire::test_valid_marker_is_carried_on_every_block_kind[image_url-on]wire::test_valid_marker_is_carried_on_every_block_kind[image_url-off]wire::test_valid_marker_is_carried_on_every_block_kind[file-on]wire::test_valid_marker_is_carried_on_every_block_kind[file-off]wire::test_valid_marker_is_carried_on_every_block_kind[input_audio-on]wire::test_valid_marker_is_carried_on_every_block_kind[input_audio-off]wire::test_malformed_marker_is_dropped_on_every_block_kind[text]wire::test_malformed_marker_is_dropped_on_every_block_kind[image_url]wire::test_malformed_marker_is_dropped_on_every_block_kind[file]wire::test_malformed_marker_is_dropped_on_every_block_kind[input_audio]wire::test_tool_output_marker[valid-on]wire::test_tool_output_marker[valid-off]wire::test_tool_output_marker[malformed-on]wire::test_tool_output_marker[malformed-off]wire::test_assistant_list_marker[valid-on]wire::test_assistant_list_marker[valid-off]wire::test_assistant_list_marker[malformed-on]wire::test_assistant_list_marker[malformed-off]wire::test_injected_system_marker_survives_a_trailing_audio_blockwire::test_injected_marker_on_a_string_system_messagewire::test_anthropic_sdk_marker_on_user_text[valid-on]wire::test_anthropic_sdk_marker_on_user_text[valid-off]wire::test_anthropic_sdk_marker_on_user_text[malformed-on]wire::test_anthropic_sdk_marker_on_user_text[malformed-off]wire::test_anthropic_sdk_system_string_gets_the_injected_markerwire::test_native_responses_request_never_enters_the_bridgewire::test_malformed_marker_is_dropped_under_drop_params[string]wire::test_malformed_marker_is_dropped_under_drop_params[int]wire::test_malformed_marker_is_dropped_under_drop_params[list]wire::test_malformed_marker_is_dropped_under_drop_params[empty-string]wire::test_malformed_marker_is_dropped_under_drop_params[5kb-string]wire::test_malformed_marker_is_dropped_under_drop_params[empty-object]wire::test_malformed_marker_is_dropped_under_drop_params[bogus-mode]wire::test_malformed_marker_is_dropped_under_drop_params[bad-ttl]wire::test_malformed_marker_passes_verbatim_without_drop_params[string]wire::test_malformed_marker_passes_verbatim_without_drop_params[int]wire::test_malformed_marker_passes_verbatim_without_drop_params[list]wire::test_malformed_marker_passes_verbatim_without_drop_params[empty-string]wire::test_malformed_marker_passes_verbatim_without_drop_params[5kb-string]wire::test_malformed_marker_passes_verbatim_without_drop_params[empty-object]wire::test_malformed_marker_passes_verbatim_without_drop_params[bogus-mode]wire::test_malformed_marker_passes_verbatim_without_drop_params[bad-ttl]wire::test_two_marked_blocks_are_both_carriedwire::test_wrong_key_is_refused_before_the_wirewire::test_upstream_error_reaches_the_caller_once[400-on]wire::test_upstream_error_reaches_the_caller_once[400-off]wire::test_upstream_error_reaches_the_caller_once[401-on]wire::test_null_drop_params_on_the_deployment_means_offwire::test_null_or_missing_marker_sends_a_plain_block[null-on]wire::test_null_or_missing_marker_sends_a_plain_block[null-off]wire::test_null_or_missing_marker_sends_a_plain_block[missing-on]wire::test_null_or_missing_marker_sends_a_plain_block[missing-off]wire::test_flipping_drop_params_mid_burst_keeps_every_marked_request_answeredround3-base-e3)wire::test_three_identical_marked_requests_are_each_sent_and_loggedchaos::test_global_drop_params_drops_a_malformed_marker[deployment-unset]chaos::test_global_drop_params_drops_a_malformed_marker[deployment-false]chaos::test_mixed_burst_carries_every_marker_oncechaos::test_upstream_outage_fails_cleanly_and_the_restarted_upstream_serves_marked_callschaos::test_concurrent_slow_streams_each_complete_with_one_upstream_callchaos::test_worker_sigkill_mid_burst_leaves_the_sibling_answeringchaos::test_proxy_restart_mid_burst_never_lands_a_served_call_twicelive/18a818530f/<leg>/L1*.jsonlive/18a818530f/<leg>/L2*.jsonlive/18a818530f/<leg>/L3*.jsonlive/18a818530f/<leg>/L4*.jsonInventory walk
Failures
C5 restart-mid-burst counts (head run 1)
{"served": "20", "landed": "20", "lost_responses": "0"}
Lane counts (passed/collected)
{"base": [52, 72], "run1": [72, 72], "run2": [72, 72]}
Rows marked
red (expected)on the base are the behaviors this PR changes;greenon the base is a regression guard that reads the same on both legs. The run before this one, at 18a8185, hadtest_three_identical_marked_requests_are_each_sent_and_loggedred on every leg for a reason inside the audit's own scripted upstream: it minted the response id from the request's marker, so three identical requests shared one id, and the spend-log writer skips a row whoserequest_idalready landed; 0135dad makes that upstream mint a unique id per reply, as a real provider does, and every cell was rerun there. Two things the matrix does not show: an unknown chat block type ({"type": "custom_blob"}) is refused before the bridge with a 500 on both legs, so the fallback branch is proven throughinput_audio, the one valid chat block type without a mapping; and the/v1/messagescells (Anthropic SDK) are served by the Anthropic-to-Responses adapter, which never enters this bridge, so they are regression guards and the malformed-marker cell there pins the adapter's current verbatim forwarding (the Low caveat below)Merged-tree check at 18a8185 (/live-pr-risk merge-ref drift, /qa probes)
Main moved under this branch (#44119 landed in the same bridge), so the /live-pr-risk top scenarios and the /qa probes were re-run on the merged tree at 18a8185: one laptop proxy from the merged worktree (
proxy_cli.py --config qa_config.yaml --num_workers 2, no database,drop_params: true, the same deployments as the A/B above, a forwarding recorder in front of api.openai.com), the same cell script with a fresh nonce, every call against the real providersttlcells)input_textitem where the source block carried a valid one,modeplusttlon the 30m cell, no marker on any malformed cellcached_tokens9040 of 9059 (non-stream), 9041 of 9060 (stream)proof_case.sh,proof_messages_case.sh)/v1/messagesThe three non-OpenAI deployments were observed as status and usage only (200, as before); for their models
supports_openai_prompt_cache_breakpointis false, so main's #44119 now strips a hand-written marker before the wire, which is main's behavior and outside this diffType
🐛 Bug Fix
Caveats (if any)
Low
The
imagebranch of the bridge (an Anthropic style{"type": "image", "source": ...}block) is the one carrying branch left without a breakpoint carry{"type": "input_image", **item}lets the spread put"type": "image"back, so a marker there would ride a block the Responses API refusesPOST /v1/chat/completionsthat block never reaches the bridge on this run: the proxy rejects the message first with a 500Invalid user message at index 0, on the merge base and the tip alike, so the branch was left alone deliberately, and that 500 is a pre-existing wart outside this diffWithout
drop_params, a malformedprompt_cache_breakpointhand-written on an unmapped block (input_audio) now gets the provider's 400 where main answered 200 with the block stringifieddrop_paramsconvention, and what the same marker on atextblock gets on main since fix(responses): preserve prompt cache reuse in chat bridge #42281; withdrop_paramson the marker drops and the request answers 200drop_paramstoo, a silent edit of the caller's request on a route where every other unsupported value answers 400, for a caller who hand-writes OpenAI's Responses dialect with the wrong type on an audio blockAn Anthropic-shaped request (
/v1/messages, Claude Code, the Anthropic SDK) to a Responses-served deployment is translated by the Anthropic-to-Responses adapter, not by this bridge, and that adapter forwards a malformedprompt_cache_breakpointverbatim withdrop_paramson, so the provider's 400 still reaches that caller where the chat path now drops the markertest_anthropic_sdk_marker_on_user_text[malformed-on]pins the current behavior so the flip is visible when the adapter gets the same validationSince main's fix(responses): keep prompt_cache_breakpoint markers in the chat to responses bridge #44119 (merged into this branch), a
prompt_cache_breakpointon a chat block is stripped before the wire for any model that failssupports_openai_prompt_cache_breakpoint(no cost-map flag and nogpt-5.6+name), with or withoutdrop_params, so the 400-without-drop_paramshalf of this PR's convention only reaches callers of models that keep breakpointsdrop_paramssupports_openai_prompt_cache_breakpointis false for their models, so main's rule strips the marker thereFinal Attestation
drop_paramsvalidation fails the two drop tests (2 failed, 5 passed across the breakpoint tests)Note
Medium Risk
Changes how outbound Responses API input is built for all bridged chat traffic when explicit cache markers or drop_params are used; malformed markers are silently dropped under drop_params, which is intentional but alters prior verbatim-forwarding behavior on some branches.
Overview
Fixes explicit prompt caching when chat completions are bridged to the Responses API:
prompt_cache_breakpointis now attached on content blocks that fall through the unmapped fallback (e.g. trailinginput_audio), matching text/image/file behavior so injected system markers survive on the wire.When
drop_paramsis on (per-call or global), markers are validated againstPromptCacheBreakpointbefore send; malformed values are omitted instead of causing upstream 400s, while valid{"mode":"explicit"}and optionalttl":"30m"are kept (the type gainsttl: "30m").drop_paramsis threaded through message/content conversion fromtransform_request.Adds unit tests for carry/drop behavior and integration wire/chaos tests for SDK paths, block kinds, tool/assistant content, and proxy failure modes.
Reviewed by Cursor Bugbot for commit 0135dad. Bugbot is set up for automated code reviews on this repo. Configure here.