Skip to content

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]

Fix test_claude_agent_sdk_streaming

Sameer Kankutef5be79419c7c
diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py
index d210f294c64..7dd32b99bc0 100644
--- a/litellm/llms/bedrock/chat/converse_transformation.py
+++ b/litellm/llms/bedrock/chat/converse_transformation.py
@@ -1199,6 +1199,9 @@ class AmazonConverseConfig(BaseConfig):
+ supported_config_params
)
inference_params.pop("json_mode", None) # used for handling json_schema
+ # Anthropic-only key. Bedrock expects `outputConfig` (camelCase) and
+ # will reject `output_config` if it leaks through pass-through routes.
+ inference_params.pop("output_config", None)
# Extract requestMetadata before processing other parameters
request_metadata = inference_params.pop("requestMetadata", None)
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 345f3ae7c5d..317faa5457a 100644
--- a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py
+++ b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py
@@ -2616,11 +2616,11 @@ def test_empty_assistant_message_handling():
empty or whitespace-only content with a placeholder to prevent AWS Bedrock
Converse API 400 Bad Request errors.
"""
+ # Import the litellm module that factory.py uses to ensure we patch the correct reference
+ import litellm.litellm_core_utils.prompt_templates.factory as factory_module
from litellm.litellm_core_utils.prompt_templates.factory import (
_bedrock_converse_messages_pt,
)
- # Import the litellm module that factory.py uses to ensure we patch the correct reference
- import litellm.litellm_core_utils.prompt_templates.factory as factory_module
# Test case 1: Empty string content - test with modify_params=True to prevent merging
messages = [
@@ -3135,7 +3135,12 @@ def test_native_structured_output_no_fake_stream():
def test_transform_request_with_output_config():
"""Test that outputConfig flows through _transform_request_helper into the final request."""
- from litellm.types.llms.bedrock import OutputConfigBlock, OutputFormat, OutputFormatStructure, JsonSchemaDefinition
+ from litellm.types.llms.bedrock import (
+ JsonSchemaDefinition,
+ OutputConfigBlock,
+ OutputFormat,
+ OutputFormatStructure,
+ )
config = AmazonConverseConfig()
@@ -3170,6 +3175,29 @@ def test_transform_request_with_output_config():
assert result["outputConfig"]["textFormat"]["structure"]["jsonSchema"]["name"] == "TestSchema"
+def test_transform_request_strips_anthropic_output_config():
+ """
+ output_config is Anthropic-specific and must never be forwarded to Bedrock.
+ """
+ config = AmazonConverseConfig()
+ messages = [{"role": "user", "content": "hello"}]
+
+ result = config._transform_request(
+ model="us.amazon.nova-pro-v1:0",
+ messages=messages,
+ optional_params={
+ "maxTokens": 64,
+ "output_config": {"effort": "low"},
+ },
+ litellm_params={},
+ headers={},
+ )
+
+ assert "outputConfig" not in result
+ additional_fields = result.get("additionalModelRequestFields", {})
+ assert "output_config" not in additional_fields
+
+
def test_transform_response_native_structured_output():
"""Test response handling when model returns JSON as text content (native structured output)."""
response_json = {