diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py index f54c352fd6e..920955218d6 100644 --- a/litellm/llms/bedrock/chat/converse_transformation.py +++ b/litellm/llms/bedrock/chat/converse_transformation.py @@ -1063,6 +1063,17 @@ class AmazonConverseConfig(BaseConfig): ) for param, value in non_default_params.items(): + if param == "reasoning_effort" and isinstance(value, dict): + # Accept both the string form ("low") and the dict form + # ({"effort": "low", "summary": "concise"}). The Responses->Chat + # parser keeps the full dict whenever `summary` is set, so a dict + # is the standard shape Responses-bridge callers send. Every + # `reasoning_effort` branch below gates on `isinstance(value, str)`, + # so without this the dict matches nothing and is dropped silently. + # Same shape-tolerance the direct Anthropic chat path already does. + effort_value: object = cast(dict[str, object], value).get("effort") # cast-ok: caller-supplied dict + if isinstance(effort_value, str): + value = effort_value if param == "response_format" and isinstance(value, dict): optional_params = self._translate_response_format_param( value=value, diff --git a/tests/unit/llms/bedrock/chat/test_converse_transformation.py b/tests/unit/llms/bedrock/chat/test_converse_transformation.py index 154797bab5a..d2fb9755dd7 100644 --- a/tests/unit/llms/bedrock/chat/test_converse_transformation.py +++ b/tests/unit/llms/bedrock/chat/test_converse_transformation.py @@ -10789,3 +10789,26 @@ def test_a_deployment_with_a_batch_control_plane_endpoint_keeps_it_out_of_chat_r assert response.choices[0].message.content == "ok" assert "aws_bedrock_control_plane_endpoint" not in route.calls[0].request.content.decode() + + +@pytest.mark.parametrize( + "model", + [ + "us.anthropic.claude-3-7-sonnet-20250219-v1:0", + "bedrock/converse/us.anthropic.claude-3-7-sonnet-20250219-v1:0", + ], +) +def test_reasoning_effort_dict_is_coerced_converse(model): + """The Responses->Chat parser keeps `reasoning_effort` as a dict whenever + `summary` is set. Every branch gates on `isinstance(value, str)`, so without + coercion the dict matches nothing and thinking is dropped silently.""" + config = AmazonConverseConfig() + + optional_params = config.map_openai_params( + non_default_params={"reasoning_effort": {"effort": "low", "summary": "concise"}}, + optional_params={}, + model=model, + drop_params=False, + ) + + assert optional_params.get("thinking") == {"type": "enabled", "budget_tokens": 1024}