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_convert_to_bedrock_format_post_call_streaming_hook

Sameer Kankute2153db5e64f2
diff --git a/tests/guardrails_tests/test_bedrock_guardrails.py b/tests/guardrails_tests/test_bedrock_guardrails.py
index 1795ff23605..cb594c221c4 100644
--- a/tests/guardrails_tests/test_bedrock_guardrails.py
+++ b/tests/guardrails_tests/test_bedrock_guardrails.py
@@ -1139,17 +1139,16 @@ async def test_convert_to_bedrock_format_post_call_streaming_hook():
result_chunks.append(chunk)
# Verify bedrock API calls were made
+ # Note: When event_hook is None (default), the guardrail is considered enabled for all hooks.
+ # In post_call, INPUT validation is skipped if pre_call/during_call is already enabled
+ # to avoid redundant validation. Since event_hook=None means all hooks are enabled,
+ # only OUTPUT validation should be performed in post_call.
assert (
- len(bedrock_calls) == 2
- ), f"Expected 2 bedrock calls (INPUT and OUTPUT), got {len(bedrock_calls)}"
+ len(bedrock_calls) == 1
+ ), f"Expected 1 bedrock call (OUTPUT only), got {len(bedrock_calls)}"
- # Find the OUTPUT call
- output_calls = [call for call in bedrock_calls if call["source"] == "OUTPUT"]
- assert (
- len(output_calls) == 1
- ), f"Expected 1 OUTPUT call, got {len(output_calls)}"
-
- output_call = output_calls[0]
+ # Verify the OUTPUT call
+ output_call = bedrock_calls[0]
assert output_call["source"] == "OUTPUT"
assert output_call["response"] is not None
assert output_call["messages"] is None # OUTPUT calls don't need messages
@@ -1176,7 +1175,10 @@ async def test_convert_to_bedrock_format_post_call_streaming_hook():
print(
"✅ Post-call streaming hook test passed - OUTPUT source used for masking"
)
- print(f"✅ Bedrock calls made: {[call['source'] for call in bedrock_calls]}")
+ print(
+ f"✅ Bedrock calls made: {[call['source'] for call in bedrock_calls]} "
+ "(INPUT validation skipped due to event_hook=None implying pre_call/during_call enabled)"
+ )
print(f"✅ Final masked content: {full_content}")
diff --git a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py
index 8fdaf4ea2df..953f54e4a54 100644
--- a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py
+++ b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py
@@ -440,7 +440,7 @@ def test_vertex_ai_complex_response_schema():
optional_params = {}
v.apply_response_schema_transformation(
- value=non_default_params["response_format"], optional_params=optional_params
+ value=non_default_params["response_format"], optional_params=optional_params, model="gemini-1.5-pro-preview-0409"
)
# Assertions for the transformed schema