litellm/tests/test_litellm/responses
Mateo Wang 8a55e9e560
fix(bedrock): drop unmappable Responses tools instead of failing the request (LIT-3858) (#31663)
* fix(bedrock): drop unmappable Responses tools instead of failing the request (LIT-3858)

When an OpenAI Responses request is routed to a Bedrock Converse Anthropic model,
litellm translates the tools array into Bedrock toolConfig. Responses built-in tool
types beyond function (web_search, image_generation, namespace, tool_search, custom)
have no Bedrock equivalent, and previously caused two failures.

A web_search tool is derived into a web_search_options param. Bedrock Anthropic
models do not list web_search_options in get_supported_openai_params, so the request
raised UnsupportedParamsError (HTTP 400) even though it never needed web search. The
derived param is now dropped on the Bedrock chat-completion bridge for models that
do not support it, scoped to Bedrock so other providers are untouched and without
requiring drop_params. Nova still keeps it since it maps to a nova_grounding systemTool.

The remaining non-function tools reached _bedrock_tools_pt and were emitted as junk
litellm_unnamed_tool_N toolSpecs with empty schemas, polluting toolConfig with tools
the model could hallucinate calls to. They are now dropped because they carry neither
an OpenAI function nor an Anthropic input_schema, while mappable function and
input_schema tools survive untouched.

* refactor(responses): drop derived web_search_options via provider config

Greptile flagged that the LIT-3858 fix put Bedrock-specific logic in the
generic Responses->Chat Completion bridge: it imported AmazonConverseConfig
and branched on custom_llm_provider.startswith("bedrock").

Read web_search_options support from each provider's own
get_supported_openai_params instead, so the bridge stays provider-agnostic
and Bedrock capability knowledge lives in the Bedrock config that already
owns it. Behavior is unchanged for the cases the PR targeted (Bedrock
Anthropic drops, Bedrock Nova and OpenAI keep) and now generalizes correctly
to any provider whose config does not support the derived param.

Add a Cohere regression test proving the drop is provider-agnostic; it fails
under the old bedrock-only check and passes now.

* fix(responses): drop derived web_search_options for bedrock_converse alias

Greptile/T-Rex caught that the provider-agnostic drop regressed the
bedrock_converse route: get_supported_openai_params did not map the
bedrock_converse alias (only "bedrock"), so it returned None (unmapped) and
the derived web_search_options was forwarded for
model="bedrock/converse/us.anthropic.claude-sonnet-4-6",
custom_llm_provider="bedrock_converse" instead of being dropped. The previous
startswith("bedrock") check happened to match the alias.

Map bedrock_converse through AmazonConverseConfig in get_supported_openai_params,
mirroring the existing ["bedrock", "bedrock_converse"] pairing in
_strip_model_name. Add regression tests at both levels: the alias now drops the
derived param for Anthropic Converse models, still keeps it for Nova, and the
helper resolves identically to "bedrock".
2026-06-29 20:23:44 -07:00
..
litellm_completion_transformation fix(bedrock): drop unmappable Responses tools instead of failing the request (LIT-3858) (#31663) 2026-06-29 20:23:44 -07:00
mcp style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_metadata_codex_callback.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_no_duplicate_spend_logs.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_null_test_fix.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_responses_api_bridge_flag.py refactor(responses): drop use_responses_api_bridge; fix PLR0915 2026-04-13 18:22:17 +05:30
test_responses_api_request_body.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_responses_prompt_management.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_responses_router_cooldown.py fix(responses): register cooldowns on failure + fail fast on stale encrypted_content (#27820) 2026-05-13 09:03:13 -07:00
test_responses_utils.py [internal copy of #27491] fix(realtime): Fix Realtime Audio Token Cost Tracking (#29722) 2026-06-05 18:53:17 +05:30
test_responses_websocket_all_providers.py fix(responses): presidio PII masking for Azure WebSocket and streaming (#30003) 2026-06-12 07:27:03 -07:00
test_sse_output_recovery.py Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
test_text_format_conversion.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00