[Bug Fix] Ensure supported bedrock/converse/ params = bedrock/ params (#12466)

* fix bedrock converse

* fix supports reasoning checks

* test_get_supported_openai_params_bedrock_converse

* fix
This commit is contained in:
Ishaan Jaff
2025-07-09 16:14:07 -07:00
committed by GitHub
parent afd382d09f
commit f62b0ca52b
2 changed files with 48 additions and 2 deletions
@@ -138,6 +138,7 @@ class AmazonConverseConfig(BaseConfig):
or base_model.startswith("meta.llama3-1")
or base_model.startswith("meta.llama3-2")
or base_model.startswith("meta.llama3-3")
or base_model.startswith("meta.llama4")
or base_model.startswith("amazon.nova")
or supports_function_calling(
model=model, custom_llm_provider=self.custom_llm_provider
@@ -145,8 +146,14 @@ class AmazonConverseConfig(BaseConfig):
):
supported_params.append("tools")
if litellm.utils.supports_tool_choice(
model=model, custom_llm_provider=self.custom_llm_provider
if (
litellm.utils.supports_tool_choice(
model=model, custom_llm_provider=self.custom_llm_provider
)
or litellm.utils.supports_tool_choice(
model=base_model,
custom_llm_provider=self.custom_llm_provider
)
):
# only anthropic and mistral support tool choice config. otherwise (E.g. cohere) will fail the call - https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ToolChoice.html
supported_params.append("tool_choice")
@@ -155,10 +162,15 @@ class AmazonConverseConfig(BaseConfig):
"claude-3-7" in model
or "claude-sonnet-4" in model
or "claude-opus-4" in model
or "deepseek.r1" in model
or supports_reasoning(
model=model,
custom_llm_provider=self.custom_llm_provider,
)
or supports_reasoning(
model=base_model,
custom_llm_provider=self.custom_llm_provider
)
):
supported_params.append("thinking")
supported_params.append("reasoning_effort")
@@ -10,6 +10,7 @@ sys.path.insert(
) # Adds the parent directory to the system path
from unittest.mock import MagicMock, patch
import litellm
from litellm.llms.bedrock.chat.converse_transformation import AmazonConverseConfig
from litellm.types.llms.bedrock import ConverseTokenUsageBlock
@@ -234,3 +235,36 @@ def test_transform_tool_call_with_cache_control():
transformed_cache_msg = result["toolConfig"]["tools"][1]
assert "cachePoint" in transformed_cache_msg
assert transformed_cache_msg["cachePoint"]["type"] == "default"
def test_get_supported_openai_params():
config = AmazonConverseConfig()
supported_params = config.get_supported_openai_params(
model="bedrock/converse/us.anthropic.claude-sonnet-4-20250514-v1:0"
)
assert "tools" in supported_params
assert "tool_choice" in supported_params
assert "thinking" in supported_params
assert "reasoning_effort" in supported_params
def test_get_supported_openai_params_bedrock_converse():
"""
Test that all documented bedrock converse models have the same set of supported openai params when using
`bedrock/converse/` or `bedrock/` prefix.
Note: This test is critical for routing, if we ever remove `litellm.BEDROCK_CONVERSE_MODELS`,
please update this test to read `bedrock_converse` models from the model cost map.
"""
for model in litellm.BEDROCK_CONVERSE_MODELS:
print(f"Testing model: {model}")
config = AmazonConverseConfig()
supported_params_without_prefix = config.get_supported_openai_params(
model=model
)
supported_params_with_prefix = config.get_supported_openai_params(
model=f"bedrock/converse/{model}"
)
assert set(supported_params_without_prefix) == set(supported_params_with_prefix), f"Supported params mismatch for model: {model}. Without prefix: {supported_params_without_prefix}, With prefix: {supported_params_with_prefix}"
print(f"✅ Passed for model: {model}")