Repository navigation
fix(anthropic): map /v1/messages fields onto OpenAI Responses equivalents or reject them (lts/1.108.x) - #54367
Conversation
…ents or reject them The Responses bridge for /v1/messages dropped several Anthropic fields and still answered 200. disable_parallel_tool_use now sets parallel_tool_calls false, speed fast asks for the priority service tier, mcp_servers become Responses mcp tools with their toolset allowlist, web_search keeps its domain filters, user_location, and max_uses, a json_schema output format goes up strict, and a 1h cache_control mark asks OpenAI for its 12h breakpoint TTL A field with no Responses equivalent (container, allowed_callers, an unknown speed, a toolset denylist, defer_loading, max_uses next to another built-in tool) answers 400 UnsupportedParamsError naming every such field, and drop_params drops them instead strict_json_schema moves to base_utils so the Codex harness, the chat-completions bridge, and the Responses bridge share one walker, which now leaves property names and enum, const, and examples values alone (cherry picked from commit 0ba6bad)
…ompletions rejects a breakpoint ttl (cherry picked from commit 2d05686)
… on the Responses wire (cherry picked from commit 07299c5)
… the 1.108 line The 1h to 12h breakpoint ttl the picks carry needs the 12h prompt cache ttl type and the 12h cache write rate, and this line has neither, so a 12h write would be billed at the 30m write rate. A 1h mark keeps the default explicit breakpoint here, as it did before the picks, until the 12h billing reaches the line
…iews (cherry picked from commit b94ad06)
…r 400 for a container id Picks the main fix onto lts/1.108.x. The line lacks BerriAI#51337, so this copies its strict-schema helper into the pass-through utils for the Responses bridge, and the chat bridge keeps its own closing logic. A container id string and a malformed mcp_servers entry now answer 400, or are dropped under drop_params, instead of a 500
…rt_messages_openai_field_mapping_lts_1_108_x # Conflicts: # litellm/llms/anthropic/pass_through/responses_adapters/handler.py # litellm/llms/anthropic/pass_through/responses_adapters/transformation.py # tests/unit/llms/anthropic/pass_through/responses_adapters/test_responses_adapters_transformation.py
…rt_messages_openai_field_mapping_lts_1_108_x
…rt_messages_openai_field_mapping_lts_1_108_x # Conflicts: # litellm/llms/anthropic/pass_through/responses_adapters/handler.py # litellm/llms/anthropic/pass_through/responses_adapters/transformation.py # litellm/llms/anthropic/pass_through/utils.py # tests/unit/llms/anthropic/pass_through/responses_adapters/test_responses_adapters_handler.py
…erriAI#53740) An MCP server entry in a /v1/messages request carries its credential as authorization_token. The key name list both redactors share had auth_token, access_token and refresh_token but not this one, so an opaque token under it stayed in debug logs. It is added to the Python list and to the Rust list, which must agree. A value under one of these key names may start with an auth scheme, as in Bearer abc. The key name pattern took the value up to the first space, so it hid the scheme and left the credential. It now takes a Bearer or Basic scheme together with the value. (cherry picked from commit f409bfd)
…e OpenAI bridge and redact the MCP authorization top_k and inference_geo have no Responses equivalent, so they now answer 400 like container unless drop_params or additional_drop_params drops them, instead of a silent 200. An mcp_toolset that names no mcp_servers entry answers 400 the same way. The error says to set drop_params: true in the model's litellm_params or under litellm_settings. A forwarded service_tier of auto no longer beats speed fast, since auto asks for nothing specific. A top-level cache_control marks the last block of the conversation the way Anthropic caches it, and an mcp_call output comes back as mcp_tool_use and mcp_tool_result blocks that replay on the next turn. The server token goes out as the Responses mcp tool's authorization field, so both redactors now scrub a value under a quoted authorization key in JSON or a Python repr. A value litellm already masked, like the Authorization header in the JSON debug log, keeps its hint, and an Authorization header name is left alone. On the 1.108 line a 1h cache mark keeps the default breakpoint TTL, so the automatic top-level mark maps to the default breakpoint too, and the Rust redaction pattern lives in litellm-rust/crates/tracing. (cherry picked from commit 3308019)
…rt_messages_openai_field_mapping_lts_1_108_x
…t drops cache_control (cherry picked from commit 6079beb)
(cherry picked from commit c7b29fe)
The standard logging payload copied tools and mcp_servers into model_parameters as sent, so an MCP server's authorization or authorization_token reached every logging callback in plain text. (cherry picked from commit f5f1806)
Mark AnthropicMessagesRequestOptionalParams.container ReadOnly and pass it when the Responses adapter builds its request instead of setting it afterwards (cherry picked from commit 9194d39)
PR overviewThe PR updates Anthropic /v1/messages handling to map fields to OpenAI Responses equivalents or reject them, including web-search parameters and MCP tool-call processing. Three issues have been addressed, but two remain open. With drop_params enabled, a retry can remove web-search domain restrictions and permit retrieval outside an application's intended sources. Separately, masking guardrails can redact MCP arguments without those changes reaching the client, leaving the original content exposed. Open issues (2)
Fixed/addressed: 3 · PR risk: 6/10 Reviews |
[High impact] The PR appears safe to merge, with the remaining numbered finding fixed and no new blocking issues found
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…arrow the authorization log pattern OpenAI strict structured outputs reject a map or a free-form object, so a Messages output schema that leaves an object open now goes to the Responses API with strict false instead of answering 400. Guardrails on /v1/messages now read mcp_tool_use input and mcp_tool_result text in requests and replies, and write a masked result back, the way they already handle tool_use and tool_result. That covers replayed history too. The quoted authorization log pattern now needs a word boundary and skips null, None and booleans, so keys like requires_authorization log as sent. (cherry picked from commit 49bd187)
…rt_messages_openai_field_mapping_lts_1_108_x # Conflicts: # litellm/llms/anthropic/pass_through/convertible_blocks.py
…uardrail (lts/1.108.x)
…rt_messages_openai_field_mapping_lts_1_108_x # Conflicts: # tests/unit/llms/anthropic/chat/guardrail_translation/test_anthropic_guardrail_handler.py
…p a top-level cache mark before a prefill (lts/1.108.x)
…th null or a boolean (lts/1.108.x) The exception for a literal null, None, true or false authorization value now needs the whole value to be that literal, so a token such as null-<rest> is redacted in Python and Rust
|
bugbot run |
…I strict mode would reject it (lts/1.108.x)
|
bugbot run |
…d_mapping_lts_1_108_x
…I refuses them under drop_params (cherry picked from commit 6134a53)
|
|
||
| def _unfiltered(tool: object) -> object: | ||
| search: Final = _filtered_web_search(tool) | ||
| return tool if search is None else {key: value for key, value in search.items() if key != "filters"} |
There was a problem hiding this comment.
Medium: Preserve domain restrictions on retry
With global or deployment-level drop_params=True, an upstream filters refusal resends web_search without its allowed_domains/blocked_domains, allowing unrestricted retrieval for applications that use these fields to constrain trusted sources. Fail closed or drop the entire search tool unless removing domain restrictions has a separate explicit opt-in.
There was a problem hiding this comment.
This matches main's filters retry, which runs only under drop_params, litellm's opt-in to drop what a model refuses, else 400
|
bugbot run |
…rt_messages_openai_field_mapping_lts_1_108_x # Conflicts: # litellm/llms/anthropic/chat/guardrail_translation/handler.py # tests/unit/llms/anthropic/chat/guardrail_translation/test_anthropic_guardrail_handler.py
|
|
||
| # Extract tool calls | ||
| elif content_type == "tool_use" and isinstance(content_block, dict): | ||
| elif content_type in _TOOL_CALL_BLOCK_TYPES and isinstance(content_block, dict): |
There was a problem hiding this comment.
Medium: Persist MCP tool-call redactions
convert_tool_use_to_openai_format() serializes input into a separate arguments string, but process_output_response() only writes back returned texts, so a masking guardrail can return redacted MCP arguments while the client still receives the originals. This applies to both in-place and replacement-list returns. Track the original call-block positions and apply returned tool_calls back to those blocks, rejecting rewrites that cannot be applied safely.
There was a problem hiding this comment.
On lts/1.108.x a post-call rewrite of any tool call's input is dropped, function tools too, since #50413 is main only. A follow-up tracks it
Comments Outside DiffThese findings could not be posted inline.
|
…sponses adapter tests
|
bugbot run |
| if block.get("type") == "text": | ||
| block["text"] = guardrail_response | ||
| elif block.get("type") == "mcp_tool_result": | ||
| _write_back_mcp_tool_result_text(block, mapping[1], guardrail_response) |
There was a problem hiding this comment.
Output guardrail MCP result write-back skips Pydantic objects
Low Severity
The new mcp_tool_result write-back in _apply_guardrail_responses_to_output only handles dict content blocks, while the existing text block write-back also handles Pydantic objects via the elif hasattr(content_block, "type") branch. When a native Anthropic model returns mcp_tool_result blocks as Pydantic model instances (as the Anthropic SDK may do), a post-call guardrail mask for that block's text is scanned and matched but silently not written back, leaving the original unmasked text in the response.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 437c970. Configure here.
There was a problem hiding this comment.
Every mcp_tool_result block litellm returns is a dict, built here or parsed from Anthropic's JSON, and main's write-back is the same
| tools=({**_mcp_tool(server), "allowed_tools": list(names)},), unsupported=unsupported | ||
| ) | ||
| case _NoEquivalent(field=field): | ||
| return _ResponsesTools(unsupported=(*unsupported, field)) |
There was a problem hiding this comment.
Match statement in _mcp_server_tools lacks default return
Low Severity
_mcp_server_tools uses a match statement on access: _McpAccess without a default branch. While all current variants (_AllTools, _OnlyTools, _NoEquivalent) are covered, if a new variant is added to _McpAccess without updating this function, it implicitly returns None where _ResponsesTools is expected, causing an AttributeError when the caller accesses .tools or .unsupported.
Reviewed by Cursor Bugbot for commit 437c970. Configure here.
There was a problem hiding this comment.
The declared _ResponsesTools return makes basedpyright fail any new _McpAccess variant this match misses, and main's same function has no default either
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
2 issues from previous reviews remain unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 437c970. Configure here.


Handwritten 1-3 sentence description
Backport of #54173 to the 1.108 LTS line. Anthropic apps calling an OpenAI model through /v1/messages silently lost settings like turning off parallel tool calls, fast mode and web search filters, and MCP servers were refused. Each now turns into the matching OpenAI setting, and one OpenAI has nothing for gets a clear 400 unless the admin turned on dropping unsupported params
Details
TLDR
Problem this solves:
disable_parallel_tool_use,speedand web search filters did nothingmcp_serversanswered 400, whilecontainerandallowed_callersanswered 200 as if they ranHow it solves it:
lts/1.108.x, as the table below showsstrict: falseREDACTEDin the logged model parameters, on any modelauthorization_tokenredaction from fix(redaction): scrub authorization_token values by their key name #53740 is picked first, since an MCP pick builds on itIntentional product change:
container,top_k,inference_geoandallowed_callersother than["direct"]now answer 400 instead of being ignored. A key allowlist, tool policy or content guardrail now acts onmcp_serversentries and MCP blocks on any modelPicks
How the picks applied, and the commits that are not picks
"Files moved" means the change applied as is after following this line's older paths, where
litellm/llms/anthropic/messages/is stilllitellm/llms/anthropic/pass_through/. The first pick also adds a token counter test this line has and main does not. The 06f4f7c pick also copies #51337's strict-schema helper, which this line lacks, intopass_through/utils.py. The Rust redaction change goes inlitellm-rust/crates/tracing/src/redaction.rs, and main's Rust logging test has no file to go in here. The c7b29fe pick checks amcp_serversentry with a pydantic adapter, since this line has no_dict_or_nonehelper. The f5f1806 pick takes main's typedget_standard_logging_model_parametersand its pydantic import, which this line lacked. The 49bd187 pick adds thetool_result_text_parthelper main already had, which its guardrail change readsThree commits are not picks of #54173. 43b2b48 keeps a 1h cache mark at OpenAI's default cache TTL, because this line has neither the 12h cache TTL type nor the 12h cache write price, so a 12h write would be billed at the 30m price. 0ef163b picks #53740's
authorization_tokenredaction, which the MCP authorization redaction in 188f1e6 extends. dd87c56 kept anmcp_toolsetout of the guardrail round trip, and the merge 2fe9f5c replaced it with #54323's fix, which main has tooThe merge 8df6262 brings in
lts/1.108.xat 5da336d. Its one conflict, inconvertible_blocks.py, kept the new helpers from both sides. The merge 6b1a0fe brings inlts/1.108.xat f57b2c5, and its one conflict, the import lines of the guardrail handler test, kept both sides' imports. The 1761d9a pick was ported by hand to this line's paths, and its prefill test expects OpenAI's default TTL, as Decision 5 says. The b021dfa pick puts its Rust change in the sameredaction.rsas 3308019. The merge b4cad6b brings inlts/1.108.xat 1b6d623, and its conflicts in the Responses bridge transformation and the guardrail handler kept both sides. It also drops a cast in the messages handler that the type gate flagged oncetool_choicewas typedThe merge 2fe9f5c brings in
lts/1.108.xat 9b6796a, which has #54323. Its conflicts in the guardrail handler and its test took the base's tool write-back, which sends an unchangedmcp_toolseton as it came the way main does, and kept the picks' MCP block scanning and both sides' tests. It also adds a cast in the guardrail handler that the type gate flaggedUser Flow
Before: an Anthropic SDK app on an OpenAI model loses some settings silently, and its MCP servers are refused
"model": "gpt-6.2-sol", aget_weathertool andtool_choice: {"type": "auto", "disable_parallel_tool_use": true}, asking for the weather in four citiestool_useblocks, as if the flag was never sentmcp_serverswith the DeepWiki MCP server and gets a 400After: the same requests take effect
tool_useblockmcp_serversrequest returns 200 with an answer from the DeepWiki MCP serverDecisions
The decisions are #54173's, except that a
cache_controlmark of any TTL stays at OpenAI's default cache TTL here, since this line has no 12h TTLEvery decision, as this line ships them
speed: "fast"maps toservice_tier: "priority", the faster and pricier tier, per OpenAI's fast mode docs."standard"sends nothing and any other value answers 400. A forwardedservice_tiersuch as"flex"wins over fast, but"auto"does notmcptool withrequire_approval: "never", since Anthropic's connector runs tools without asking. Anmcp_toolsetallowlist becomesallowed_tools. A toolset that turns off only some tools, setsdefer_loadingor names no server answers 400, and so does a malformedmcp_serversentry unlessdrop_paramsis on. Anmcp_callreturns asmcp_tool_useandmcp_tool_resultblocks and replays as the same call, each result found by its call's id. The access match has no default branch, as on main, since basedpyright fails a variant it missesweb_search, the tool that takes filters.max_usesbecomesmax_tool_calls, a cap on every built-in tool, only when web search is the only one, and answers 400 otherwise. A model that refuses domain filters, such as gpt-4o-mini, answers OpenAI's 400, and withdrop_paramsthe turn goes again once without them, as on main$refanddefaultkeep working, and objects with properties close as on main, even ones allowing extra keys, since Anthropic accepts onlyadditionalProperties: false. A schema using anything OpenAI's strict mode rejects, such as a map, a free-form object,allOf, aconstwith notype, a$refbeside other keywords or auriformat, goes up as is withstrict: false, as every schema did here Before (code). OpenAI then does not enforce that schema. The other choices were a 400, or rewriting the schema into OpenAI's subset the way Anthropic's SDK does, which drops constraints the caller set. Like OpenAI's SDK, strict mode lists every property as required, so the model fills optional fields too, andstrict: falsekeeps them optionalcache_controlmark of any TTL stays an explicit cache breakpoint at OpenAI's default TTL on this line, as it was before. A top-levelcache_controlnow marks the last block, or the last block before an assistant prefill since OpenAI takes no mark on assistant text, unless the deployment listscache_controlinadditional_drop_params. A tool's cache mark now reaches OpenAI too, at the same default TTLmcp_serversentry by itsname, the way/v1/responsescountsserver_label, so native Anthropic models get this too. Matching a server by its URL stays a separate feature requestmcp_tool_useinput andmcp_tool_resulttext the way they readtool_useandtool_result, on any model, and a mask goes back into the block it came from. A streamed reply's MCP blocks still skip guardrails, as they did Before on native Anthropic, and a follow-up tracks it. A post-call guardrail's rewrite of any tool call's input is dropped here as Before, since fix(guardrails): write rewritten tool_calls from the Generic Guardrail API back to the client #50413 is main only. Every returnedmcp_tool_resultblock is a dict, built here or parsed from Anthropic's JSON, so the write-back reads dicts only, as main doesPre-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 moreDelays 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: 2fe9f5c. All 70 request cases ran again there against 9b6796a, and make check, 3282 unit tests and 564 of 566 integration tests pass there, and the 2 others fail the same on the base
What carries from earlier runs
2fe9f5c merges
lts/1.108.xat 9b6796a, which has #54323 and the base's guardrail changes. All 70 cases ran again at 2fe9f5c against 9b6796a, and each After answers as it did at 4ad5e05, apart from one extraredacted_thinkingblock in one MCP reply. The guardrail, allowlist, tool policy, generic guardrail API and canary cases ran again at 2fe9f5c206d and After answers the same. Before at 9b6796a has #54323, so its claude-haiku guardrail and toolset cases answer 200 instead of the Anthropic 400 below. The merge changes no cache, cost, logging or redaction code, so the cache and debug log cases carry. 4ad5e05 picks main's filters retry, and the 3 drop_params filter tests fail without it437c970 only adds type annotations to four tests, so the 2fe9f5c runs carry to it, and make check and those tests pass there
a0342b7 changes only how the Responses bridge picks
strictfor an output schema, and every schema case on an OpenAI Responses model ran again there. The Gemini schema cases take the chat adapter, which it leaves alone. The cache cases ran at ad83790 and the tool cache and web search cases at 743a957, both against ff47f81, and they carry to ce62add. Neither base merge touches the shared cache code, which matches f57b2c5 at ce62add. 454e948 changes only where a top-level mark goes before an assistant prefill, and the prefill case ran that at ce62add. dd87c56 changes only the guardrail handler and ce62add only the log redaction pattern, and those cases run no guardrail and log nothing they checkSetup, the same on both legs
Each leg booted its own tree on one box with its own Postgres database and 2 workers, on a free port. Env var names are
OPENAI_API_KEY,GEMINI_API_KEY,ANTHROPIC_API_KEY,LITELLM_MASTER_KEY,DATABASE_URL,OPENAI_BASE_URL,LITELLM_LOCAL_MODEL_COST_MAP=TrueandPYTHON_DOTENV_DISABLED=1.OPENAI_BASE_URLpoints at a small recorder that logs each request and forwards it unchanged tohttps://api.openai.com/v1, which is where the "OpenAI got" lines come fromconfig.yaml, also in the gist
Client code,
anthropic0.84.0. A case that setsmcp_servers,containerorspeedgoes throughclient.beta.messageswith the matching beta header, as its step says. The full script is sdk_leg.py, and the allowlist cases are sdk_allowlist.pyThe cache cases ran on a second set of proxies with no recorder and no database, since LiteLLM sends a cache breakpoint only to OpenAI's own host and the recorder's URL looks like another host. Their config.yaml has only the
gpt-6.2-solandgpt-6.2-sol-nocacheentries above, started withlitellm --config config.yaml --port <port> --num_workers 2. Besides Before and After, a third proxy ran the tip with 43b2b48 reverted, which is what the picks alone would ship on this line. Each call sends a prompt of about 6,000 tokens markedcache_control: {"type": "ephemeral", "ttl": "1h"}, salted per leg so the legs never share a cache entry, and repeats it 40 s later. The script is sdk_cache.py, and its output is cache-progress.txt with each call's full reply beside it28 requests through the Anthropic SDK, Before and After
Both legs sent the same 28 requests through the Anthropic Python SDK, plain and streaming. The OpenAI cases went to real OpenAI
gpt-6.1-sol, served asgpt-6.2-solsince 6.1 is the newest Sol in this line's cost map, one schema case went togpt-4.1, and two schema cases went to Geminigemini-3.8-flash. Each OpenAI case quotes what OpenAI received, read from a recorder that forwards to api.openai.com. The table says what each request answered and, in brackets, what the OpenAI request carriedA key's tool allowlist counts each mcp_servers entry, on any model
The tool allowlist now counts each
mcp_serversentry by its name, on OpenAI and native Anthropic models alike. Two virtual keys were made with/key/generate, one withmetadata.allowed_tools: ["lookup"]and one with["lookup", "deepwiki"], and each sent DeepWiki throughmcp_serversplus itsmcp_toolset. The script is sdk_allowlist.py, and its output is Before and Afterinvalid_request_errortool_access_deniedinvalid_request_errortool_access_deniedA 1h cache mark keeps the 30m TTL and its logged price on this line
43b2b48 keeps a 1h mark at OpenAI's default 30m cache TTL. With the picks alone, OpenAI writes that cache for 12h, which main's cost map prices at about twice the 30m write, while this line logs it at the 30m price because its cost map has no 12h write price. After writes for 30m as Before did, so the logged cost matches the write. Each cost covers the call's whole prompt at the same rate per token on every leg
/v1/responses1h mark, write TTL/v1/responsesfirst call cost/v1/messages1h mark, first call cost/v1/messagestop-level mark, first call costCallbacks get the MCP token as REDACTED
A logging callback reads
model_parametersfrom the standard logging payload. Each leg sent a canary MCP token asauthorization_tokenon two OpenAI calls and one native Anthropic call. Before answered 400 to the OpenAI calls and gave the callback the Anthropic call's token in plain text atmodel_parameters.mcp_servers[0].authorization_token. After answered 200 to all three and shows the token 0 times in the callback payload, the proxy log and spend logs (script, Before, After)With debug logs on, an MCP token that starts with
null-was logged 2 times in plain and 2 times in JSON debug logs at 454e948 and 0 times at ce62add, which keeps thenulland boolean exception to whole values (script, output)A split MCP replay and an assistant prefill
When the first turn called two MCP tools and the replay sends both uses before either result, or puts text between a use and its result, After answers 200 and OpenAI gets both
mcp_callitems with their outputs. Before answers 400, since it refusesmcp_serverson OpenAI models. count_tokens answers 400 on these blocks on both legs before any OpenAI call, as on main (script, output)A top-level 1h
cache_controlnow puts the mark on the last user turn at OpenAI's default TTL, before an assistant prefill too, where Before sent no mark. All six calls answered 200, plain and streaming. These ran against api.openai.com with no recorder, reading each proxy's own outbound body (script, output)A json_schema within OpenAI's strict mode goes to OpenAI with
strict: trueand any other withstrict: false, all 200 (wire summary)Schema cases
strict: falsestrict: truestrict: falsestrict: falsestrict: falsestrict: falseallOfwith a$refstrict: falsestrict: falseconstwith notypestrict: falsestrict: false$refwith a descriptionstrict: falsestrict: falseuriformatstrict: falsestrict: falsemessages.parsewithHttpUrlstrict: falsestrict: falsedate-timestrict: falsestrict: true$refstrict: falsestrict: trueEach ran plain and streaming at a0342b7 with the same result, and
strictis what OpenAI received (first three, the rest). Before replies arer8-base-<case>-plain.txtin the r8 gist for the first three andl-base-<case>-plain.txtin the schema gist for the rest, and After replies arel-head-<case>-plain.txtthere, for exampleuriBefore anduriAfterContent guardrails now block and mask words inside MCP blocks (guardrail wire diff, mask wire summary)
Guardrail cases
These guardrails were added to the same config.yaml, and each request turns one on with
"guardrails": ["<name>"]in its bodyclaude-haiku goes straight to Anthropic and gpt-6.2-sol goes to OpenAI through the recorder. "blocked" is the guardrail's 400
Content blocked: keyword ... detected, and on gpt-6.2-sol Before answered 400 on every row, blocked on the user text row andmcp_serversunsupported on the rest. "Anthropic 400" is Anthropic refusing a request whosemcp_toolseta pre_call guardrail dropped, which #54323 fixed in the base at 9b6796a. This table's Before ran on an older base, and Before at 9b6796a is in the 2fe9f5c206d runmcp_tool_resultmcp_tool_usemcp_tool_resultmcp_tool_result[KEYWORD_REDACTED]mcp_tool_result[KEYWORD_REDACTED][KEYWORD_REDACTED]mcp_toolsetthat turns on one toolallowed_toolsallowed_toolsA blocked request never reached OpenAI, and a blocked reply came after one OpenAI call. Each request is
r8-cell-<case>.jsonin the gist and its replies arer8-base-<case>.txtandr8-head-<case>.txt, for example request, Before and After for the toolset row on claude-haikuTool policy cases
The tool policy guardrail reads
mcp_serversnames on native Anthropic models too, and a toolset it lets through reaches Anthropic (script, Before, After)Both legs restarted with a
tool_policyguardrail,mode: pre_callanddefault_on: true, andstore_model_in_db: true. Each policy was set withPOST /v1/tool/policyand given 25 s to sync. Each call is claude-haiku with DeepWiki inmcp_serversand itsmcp_toolsetViolated tool policyTool cache marks and web search filters were checked on the real OpenAI host too (outbound bodies)
Tool cache marks and web search filters
A
cache_controlmark on a tool now reaches OpenAI as that tool'sprompt_cache_breakpoint, plain and streaming, where Before sent the tool with no mark, and a 1h TTL on it stays at OpenAI's default TTL, like a message mark on this line. Web search withblocked_domainsandmax_usesgoes out asweb_searchwithfilters.blocked_domainsandmax_tool_calls, where Before sent a bareweb_search_preview. All eight calls answered 200. These ran at 743a957 and ff47f81 against api.openai.com with no recorder, reading each proxy's own outbound body, since LiteLLM sends cache marks only to OpenAI's own host. The requests are tool mark, 1h tool mark, streamed and web search/live-pr-risk on 43b2b48, no breaking change
43b2b48 removes the 12h mapping the picks added, so the shared cache code (
common_utils.py, the OpenAI Responses and Chat Completions transformations, the Anthropic cache control hook and the OpenAI-like config) matches f57b2c5 at ce62add, andgit diff --stat f57b2c584f3 ce62add3900on those files prints nothing. The Messages bridge itself does change, since the picks add a tool's cache mark, so that path ran live at 743a957 in the tool cache cases above, where OpenAI got the tool's mark at the default TTL. The cache legs above ran at ad83790 and show the same write TTL and cost as ff47f81 on/v1/responsesand/v1/messages. Later commits change no shared cache code, so the pass carries to ce62add/live-pr-risk on dd87c56, no breaking change
dd87c56 changes what a /v1/messages guardrail scans and writes back, on any model. Its dependents are the content filter, which ran in the guardrail cases above on both models, the tool policy guardrail, which ran in the tool policy cases, and any guardrail that reads the scanned
tools, which no longer gets the toolset as a function with no name. Function tools and provider tools such as web search take the same path as Before. 8df6262 merged the base in, so this tip is what lands onlts/1.108.xBackward incompatible
container,top_k,inference_geo, a code executionallowed_callersand a malformedmcp_serversentry answer 400 where they answered 200 and did nothing. Underdrop_paramsanmcp_serversentry now goes upstream instead of being dropped. This follows litellm'sdrop_paramsconvention, and the drop_params legs show the 200. Kept in Caveats for Mateo's reviewspeed: "fast"now asks for OpenAI's priority tier, billed about 2x. It is the mapping this PR was asked for, kept in Caveatsallowed_toolsleaves out anmcp_serversentry, a tool policy that blocks one, or a content guardrail whose word shows up in an MCP block now refuses the request on any model, native Anthropic included, where Before let it through. This closes gaps in the allowlist and the guardrails, kept in Caveats for Mateo's reviewRegression risk
/live-pr-risk on ce62add, no breaking change
The merge 6b1a0fe brings base changes to the Anthropic guardrail translation handler and to the /v1/messages stream assembly and streaming iterators, which the picks' MCP guardrail and stream code sit beside. The guardrail, mask, tool policy and streamed cases above ran at ce62add and answer as they did at dd87c56. 454e948 adds two helpers with one caller each in the Messages adapter, one pairing a replayed MCP result with its call by id and one placing the top-level cache mark, and the split replay and prefill cases ran both. ce62add applies the
nulland boolean exception in log redaction to whole values only, so it only redacts more, and everyredact_stringcaller gets it, which the debug log case covers. Since thenlts/1.108.xmoved to 1e96f26 with #53768, a previous_response_id fix that shares no file with this PR. On ce62add merged with 1e96f26, the SDK, allowlist, prefill and split replay cases answer as they did at ce62add, apart from one extraredacted_thinkingblock in a schema reply (output)/live-pr-risk on 2fe9f5c, no breaking change
The merge 2fe9f5c brings in #54323's tool write-back, #54327's Bedrock guardrail scan of /v1/messages, and the generic guardrail API's
tool_calls,toolsandstructured_messagesfields. Each reads what the picks' guardrail handler hands it, so the dependents are the content filter, the tool policy, the generic guardrail API and the Bedrock guardrail on /v1/messages. The 2fe9f5c206d run drove the first three on both legs, with a recorder in front of the generic guardrail API, and every After answers as it did at 4ad5e05. The tool allowlist and the canary cases also answer the sameBackward incompatible
mcp_tool_result's text intextsand itsmcp_tool_useintool_calls, which it did not get at 9b6796a. This is Decision 7 reaching a guardrail the base added, and no auth header reaches the vendor on either leg. Kept in Caveats for Mateo's reviewRegression risk
Every Before request, with what OpenAI got, is in cases-before-f57b2c584f3.md
After (ce62add), every request and what OpenAI got
disable_parallel_tool_use, 4 cities
m1_parallel.jsonthe same way as Before{"stop_reason": "tool_use", "tool_use": 1, "cost": "0.000468"}, and streaming gave the same status. OpenAI got{"parallel_tool_calls": false, "tool_choice": "auto", "tools": [{"type": "function", "name": "get_weather", "strict": false}]}. Raw output is in the gist, the stream run beside itNo parallel flag, 4 cities
m1_no_flag.jsonthe same way as Before{"stop_reason": "tool_use", "tool_use": 4, "cost": "0.000912"}, and streaming gave the same status. OpenAI got{"tool_choice": "auto", "tools": [{"type": "function", "name": "get_weather", "strict": false}]}. Raw output is in the gist, the stream run beside itstop_sequences
m0_stop_sequences.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.00016600000000000002"}, text1 2 3 4 5, and streaming gave the same status. OpenAI got none of the case's fields. Raw output is in the gist, the stream run beside itStrict schema on gpt-4.1
h1_chat_bridge_strict.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.000194"}, text{"city": "Paris", "country": "France"}, and streaming gave the same status. OpenAI got{"text.format.strict": true}. Raw output is in the gist, the stream run beside itStrict tool
m2_strict.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["redacted_thinking", "text"], "cost": "0.0007320000000000001"}, text{"color":"red","note":"The color must be either red or blue...., and streaming gave the same status. OpenAI got{"text.format.strict": true}. Raw output is in the gist, the stream run beside itStrict tool, every field required
m2b_strict_required.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["redacted_thinking", "text"], "cost": "0.0007"}, text{"answer": "yes", "confidence": 1}, and streaming gave the same status. OpenAI got{"text.format.strict": true}. Raw output is in the gist, the stream run beside itspeed fast
m3_speed_fast.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.00014800000000000002"}, textHi, and streaming gave the same status. OpenAI got{"service_tier": "priority"}. Raw output is in the gist, the stream run beside itNo speed
m3_speed_none.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "8.400000000000001e-05"}, textHi!, and streaming gave the same status. OpenAI got none of the case's fields. Raw output is in the gist, the stream run beside itspeed fast, service_tier auto
m3c_speed_fast_auto.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.00016800000000000002"}, textHi!, and streaming gave the same status. OpenAI got{"service_tier": "priority"}. Raw output is in the gist, the stream run beside itmcp_servers
m4_mcp_servers.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["mcp_tool_use", "mcp_tool_result", "text"], "cost": "0.00333"}, textThe first 3 top-level topics for **BerriAI/litellm** are: 1..., and streaming gave the same status. OpenAI got{"tools": [{"type": "mcp", "server_label": "deepwiki", "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never"}]}. Raw output is in the gist, the stream run beside itmcp_toolset
m5_mcp_toolset.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["mcp_tool_use", "mcp_tool_result", "text"], "cost": "0.003094"}, textThe first 3 top-level topics forBerriAI/litellmare: 1. ..., and streaming gave the same status. OpenAI got{"tools": [{"type": "mcp", "server_label": "deepwiki", "server_url": "https://mcp.deepwiki.com/mcp", "allowed_tools": ["read_wiki_structure"], "require_approval": "never"}]}. Raw output is in the gist, the stream run beside itmcp_toolset with a disabled tool
m5b_mcp_toolset_blocked_tool.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.000484"}, textASK_QUESTION_UNAVAILABLE, and streaming gave the same status. OpenAI got{"tools": [{"type": "mcp", "server_label": "deepwiki", "server_url": "https://mcp.deepwiki.com/mcp", "allowed_tools": ["read_wiki_structure"], "require_approval": "never"}]}. Raw output is in the gist, the stream run beside itmcp_toolset naming no server
m5c_orphan_toolset.jsonthe same way as Beforeopenai/gpt-6.1-sol is served through the OpenAI Responses API, which has no equivalent for mcp_toolset 'github' without a matching mcp_servers entry. To drop it, set 'litellm.drop_params=Tru..., and streaming gave the same status. Raw output is in the gist, the stream run beside itmcp_servers, drop_params model
m5d_orphan_toolset_drop.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["mcp_tool_use", "mcp_tool_result", "text"], "cost": "0.00333"}, textThe first 3 top-level topics for **BerriAI/litellm** are: 1..., and streaming gave the same status. OpenAI got{"tools": [{"type": "mcp", "server_label": "deepwiki", "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never"}]}. Raw output is in the gist, the stream run beside itweb_search allowed_domains
m6_websearch_domains.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.030021"}, textLiteLLM is an open-source Python SDK and AI gateway that pro..., and streaming gave the same status. OpenAI got{"tools": [{"type": "web_search", "filters": {"allowed_domains": ["docs.litellm.ai"]}}]}. Raw output is in the gist, the stream run beside itweb_search user_location
m6b_websearch_location.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.031876"}, textSan Francisco — Today, Wednesday, November 25, expect **morn..., and streaming gave the same status. OpenAI got{"tools": [{"type": "web_search_preview", "user_location": {"type": "approximate", "city": "San Francisco", "region": "California", "country": "US", "timezone": "America/Los_Angeles"}}]}. Raw output is in the gist, the stream run beside itcontainer skills
m7_container_callers.jsonthe same way as Beforeopenai/gpt-6.1-sol is served through the OpenAI Responses API, which has no equivalent for allowed_callers on tool 'get_weather'; container. To drop them, set 'litellm.drop_params=True', or ..., and streaming gave the same status. Raw output is in the gist, the stream run beside itcontainer skills, drop_params model
m7b_container_callers_drop.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.000156"}, textHi!, and streaming gave the same status. OpenAI got{"tools": [{"type": "function", "name": "get_weather", "strict": false}]}. Raw output is in the gist, the stream run beside itcontainer id
r2_container_id.jsonthe same way as Beforeopenai/gpt-6.1-sol is served through the OpenAI Responses API, which has no equivalent for container. To drop it, set 'litellm.drop_params=True', or 'drop_params: true' in the model's 'litel..., and streaming gave the same status. Raw output is in the gist, the stream run beside itcontainer id, drop_params model
r2b_container_id_drop.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "8.400000000000001e-05"}, textHi!, and streaming gave the same status. OpenAI got none of the case's fields. Raw output is in the gist, the stream run beside ittop_k
m8_top_k.jsonthe same way as Beforeopenai/gpt-6.1-sol is served through the OpenAI Responses API, which has no equivalent for top_k. To drop it, set 'litellm.drop_params=True', or 'drop_params: true' in the model's 'litellm_p..., and streaming gave the same status. Raw output is in the gist, the stream run beside ittop_k, drop_params model
m8b_top_k_drop.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["redacted_thinking", "text"], "cost": "0.00018800000000000002"}, textRed, and streaming gave the same status. OpenAI got none of the case's fields. Raw output is in the gist, the stream run beside itinference_geo
m9_inference_geo.jsonthe same way as Beforeopenai/gpt-6.1-sol is served through the OpenAI Responses API, which has no equivalent for inference_geo. To drop it, set 'litellm.drop_params=True', or 'drop_params: true' in the model's 'l..., and streaming gave the same status. Raw output is in the gist, the stream run beside itinference_geo, drop_params model
m9b_inference_geo_drop.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["redacted_thinking", "text"], "cost": "0.00022800000000000004"}, textRed, and streaming gave the same status. OpenAI got none of the case's fields. Raw output is in the gist, the stream run beside itSchema with a root $ref
r1_root_ref.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.000288"}, text{"name":"Ada","age":36}, and streaming gave the same status. OpenAI got{"text.format.strict": true}. Raw output is in the gist, the stream run beside itRoot $ref on Gemini
r1g_root_ref_gemini.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.00114825"}, text{"name": "Ada", "age": 36}, and streaming gave the same status. Nothing went through the OpenAI recorder. Raw output is in the gist, the stream run beside itMap fields on Gemini
r3_maps_gemini.jsonthe same way as Before{"stop_reason": "end_turn", "block_types": ["text"], "cost": "0.0012202500000000002"}, text{"name":"Ada","metadata":{ } ,"tags":{"color":"blue"}}, and streaming gave the same status. Nothing went through the OpenAI recorder. Raw output is in the gist, the stream run beside itMalformed mcp_servers entry
r4_mcp_malformed.jsonthe same way as Beforeopenai/gpt-6.1-sol is served through the OpenAI Responses API, which has no equivalent for a malformed mcp_servers entry. To drop it, set 'litellm.drop_params=True', or 'drop_params: true' i..., and streaming gave the same status. Raw output is in the gist, the stream run beside itType
🐛 Bug Fix
Caveats (if any)
Copied from #54173 without main-only items, plus this line's own
Medium
speed: "fast"asks for OpenAI's priority tier, billed about 2x, unlessadditional_drop_paramslistsspeedcontainer,top_k,inference_geoand refused domain filters answer 400 unless dropped, anddrop_paramsnow keepsmcp_servers, which a customopenai/host may rejectallowed_callerswith a code execution caller answers 400, and a follow-up tracks itheadersasREDACTEDLow
defer_loadingon anmcp_toolsetanswers 400, with no tool search round tripdrop_params, a partialmcp_toolsetdenylist drops the whole MCP serverstop_sequencesto OpenAI, as Before, and a follow-up tracks itrouter_code_coveragefails on the base too, naming the same four router functionsFinal Attestation
Bugbot summary