From 74e86d3c0d16f50f541f155e41d4f1968ce8bf82 Mon Sep 17 00:00:00 2001 From: Matthew Lapointe Date: Tue, 25 Aug 2026 19:20:00 -0400 Subject: [PATCH] fix(bedrock): route reasoning_effort to reasoning.effort for OpenAI GPT-5.x on Converse OpenAI GPT-5.x models on Bedrock Converse expect reasoning effort under additionalModelRequestFields as {"reasoning": {"effort": ...}}. They were falling into the Anthropic branch and emitting a `thinking` block, which Converse rejects with unknown_parameter. The bedrock_converse gpt-5.6 entries were also missing supports_reasoning, so reasoning_effort was dropped before mapping. Setting the flag lets the existing config-driven supported-params path accept it, rather than adding another model-name branch. --- .../bedrock/chat/converse_transformation.py | 6 ++++ ...odel_prices_and_context_window_backup.json | 6 ++++ model_prices_and_context_window.json | 6 ++++ .../chat/test_converse_transformation.py | 31 +++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py index 767677cbcbf..38dabafa441 100644 --- a/litellm/llms/bedrock/chat/converse_transformation.py +++ b/litellm/llms/bedrock/chat/converse_transformation.py @@ -418,12 +418,18 @@ class AmazonConverseConfig(BaseConfig): Handle the reasoning_effort parameter based on the model type. - GPT-OSS models: passed through unchanged via additionalModelRequestFields. + - OpenAI GPT-5.x models: mapped to ``reasoning.effort`` via additionalModelRequestFields. - Nova 2 models: transformed to reasoningConfig. - Anthropic models: mapped to ``thinking`` (and ``output_config.effort`` on adaptive Claude 4.6 / 4.7). """ if "gpt-oss" in model: optional_params["reasoning_effort"] = reasoning_effort + elif "openai.gpt-5" in model: + # Converse rejects Anthropic's `thinking` for OpenAI GPT-5.x; effort goes + # under additionalModelRequestFields as {"reasoning": {"effort": ...}}. + optional_params.pop("thinking", None) + optional_params["reasoning"] = {"effort": reasoning_effort} elif self._is_nova_2_model(model): reasoning_config: Final = self._transform_reasoning_effort_to_reasoning_config(reasoning_effort) optional_params.update(reasoning_config) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 9ca8d9e1bac..7fa0e8b73d8 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -49473,6 +49473,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "global.openai.gpt-5.6-sol": { @@ -49498,6 +49499,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "us.openai.gpt-5.6-terra": { @@ -49523,6 +49525,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "global.openai.gpt-5.6-terra": { @@ -49548,6 +49551,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "us.openai.gpt-5.6-luna": { @@ -49573,6 +49577,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "global.openai.gpt-5.6-luna": { @@ -49598,6 +49603,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "bedrock_mantle/openai.gpt-5.5": { diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 9ca8d9e1bac..7fa0e8b73d8 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -49473,6 +49473,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "global.openai.gpt-5.6-sol": { @@ -49498,6 +49499,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "us.openai.gpt-5.6-terra": { @@ -49523,6 +49525,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "global.openai.gpt-5.6-terra": { @@ -49548,6 +49551,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "us.openai.gpt-5.6-luna": { @@ -49573,6 +49577,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "global.openai.gpt-5.6-luna": { @@ -49598,6 +49603,7 @@ ], "supports_function_calling": true, "supports_tool_choice": true, + "supports_reasoning": true, "supports_vision": true }, "bedrock_mantle/openai.gpt-5.5": { diff --git a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py index 4d2c077b548..66b588168e9 100644 --- a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py +++ b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py @@ -284,6 +284,37 @@ def test_reasoning_with_forced_tool_choice_switches_to_auto(): assert optional_params["tool_choice"] == {"auto": {}} +@pytest.mark.parametrize( + "model", + [ + "us.openai.gpt-5.6-sol", + "global.openai.gpt-5.6-terra", + "bedrock/converse/us.openai.gpt-5.6-luna", + ], +) +def test_reasoning_effort_maps_to_reasoning_effort_for_openai_gpt5_converse(model, local_model_cost_map): + """OpenAI GPT-5.x on Bedrock Converse routes reasoning_effort to + ``additionalModelRequestFields.reasoning.effort`` rather than Anthropic ``thinking``.""" + config = AmazonConverseConfig() + + assert "reasoning_effort" in config.get_supported_openai_params(model=model) + + optional_params = config.map_openai_params( + non_default_params={"reasoning_effort": "high"}, + optional_params={}, + model=model, + drop_params=False, + ) + + assert optional_params["reasoning"] == {"effort": "high"} + assert "thinking" not in optional_params + assert "reasoning_effort" not in optional_params + + _, additional_request_params, _, _ = config._prepare_request_params(optional_params, model) + assert additional_request_params["reasoning"] == {"effort": "high"} + assert "thinking" not in additional_request_params + + @pytest.mark.parametrize( "model", [