The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Fix converse handling for parallel_tool_calls
Sameer Kankuted0445e1e3359
diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.pyindex d4fd0606302..a0f2f65fb7f 100644--- a/litellm/llms/bedrock/chat/converse_transformation.py+++ b/litellm/llms/bedrock/chat/converse_transformation.py@@ -1217,15 +1217,15 @@ class AmazonConverseConfig(BaseConfig):# Handle parallel_tool_calls configurationparallel_tool_use_config = additional_request_params.pop("_parallel_tool_use_config", None)- if parallel_tool_use_config is not None:- # Merge the tool_choice config from parallel_tool_calls into additional_request_params+ if parallel_tool_use_config is not None and is_claude_4_5_on_bedrock(model):for key, value in parallel_tool_use_config.items():if key in additional_request_params and isinstance(additional_request_params[key], dict) and isinstance(value, dict):- # Merge dictionariesadditional_request_params[key].update(value)else:additional_request_params[key] = value+ additional_request_params.pop("parallel_tool_calls", None)+# Only set the topK value in for models that support itadditional_request_params.update(self._handle_top_k_value(model, inference_params)diff --git a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.pyindex 26395597166..2b996977d8d 100644--- a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py+++ b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py@@ -3382,59 +3382,78 @@ def test_output_config_applies_additional_properties():-def test_parallel_tool_calls_in_request_transformation():- """Test that parallel_tool_calls is correctly placed in additionalModelRequestFields after full transformation"""- config = AmazonConverseConfig()-- messages = [- {"role": "user", "content": "What's the weather in SF and NYC?"}- ]-- non_default_params = {- "parallel_tool_calls": False,- "tools": [- {- "type": "function",- "function": {- "name": "get_weather",- "description": "Get the weather",- "parameters": {- "type": "object",- "properties": {- "location": {- "type": "string",- "description": "The location to get weather for"- }- },- "required": ["location"]+_TOOL_PARAM = [+ {+ "type": "function",+ "function": {+ "name": "get_weather",+ "description": "Get the weather",+ "parameters": {+ "type": "object",+ "properties": {+ "location": {+ "type": "string",+ "description": "The location to get weather for",}- }- }- ],- "max_tokens": 100,+ },+ "required": ["location"],+ },+ },}-+]+++def test_parallel_tool_calls_newer_model_adds_disable_flag():+ """Newer Claude models (4.5+) should get disable_parallel_tool_use in additionalModelRequestFields."""+ config = AmazonConverseConfig()+ model = "anthropic.claude-sonnet-4-5-20250929-v1:0"+ messages = [{"role": "user", "content": "What's the weather in SF and NYC?"}]+optional_params = config.map_openai_params(- non_default_params=non_default_params,+ non_default_params={"parallel_tool_calls": False, "tools": _TOOL_PARAM},optional_params={},- model="anthropic.claude-sonnet-4-5-v2:0",+ model=model,drop_params=False,)-- # Transform the request+request_data = config.transform_request(- model="anthropic.claude-sonnet-4-5-v2:0",+ model=model,messages=messages,optional_params=optional_params,litellm_params={},headers={},)-- # Verify the structure+assert "additionalModelRequestFields" in request_dataassert "tool_choice" in request_data["additionalModelRequestFields"]- assert "disable_parallel_tool_use" in request_data["additionalModelRequestFields"]["tool_choice"]assert request_data["additionalModelRequestFields"]["tool_choice"]["disable_parallel_tool_use"] is True+ assert "parallel_tool_calls" not in request_data["additionalModelRequestFields"]+++def test_parallel_tool_calls_older_model_drops_disable_flag():+ """Older Claude models (pre-4.5) must NOT receive disable_parallel_tool_use — Bedrock rejects it."""+ config = AmazonConverseConfig()+ model = "anthropic.claude-3-5-sonnet-20241022-v2:0"+ messages = [{"role": "user", "content": "What's the weather in SF and NYC?"}]++ optional_params = config.map_openai_params(+ non_default_params={"parallel_tool_calls": False, "tools": _TOOL_PARAM},+ optional_params={},+ model=model,+ drop_params=False,+ )++ request_data = config.transform_request(+ model=model,+ messages=messages,+ optional_params=optional_params,+ litellm_params={},+ headers={},+ )++ additional = request_data.get("additionalModelRequestFields", {})+ assert "tool_choice" not in additional+ assert "parallel_tool_calls" not in additionalclass TestBedrockMinThinkingBudgetTokens: