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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(headroom): cover stream conversion after deployment-level compression
mateo-berri2affd800eca0
diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_headroom.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_headroom.pyindex 22031abad8a..1fbc975e40a 100644--- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_headroom.py+++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_headroom.py@@ -2014,6 +2014,32 @@ async def test_pre_call_deployment_hook_still_compresses_for_deployment_level_coassert result["messages"] == EXPECTED_MESSAGES+async def test_pre_call_deployment_hook_converts_stream_after_deployment_level_compression(+ guardrail: HeadroomGuardrail,+):+ kwargs = {+ "model": "gpt-4o",+ "messages": [dict(m) for m in ORIGINAL_MESSAGES],+ "stream": True,+ "guardrails": ["headroom"],+ "metadata": {},+ }++ with patch.object(+ guardrail.async_handler,+ "post",+ new_callable=AsyncMock,+ return_value=_make_compress_response(COMPRESSED_MESSAGES_WITH_HASH),+ ):+ result = await guardrail.async_pre_call_deployment_hook(kwargs=kwargs, call_type=CallTypes.acompletion)++ assert result is not None+ assert has_headroom_retrieve_tool(result["tools"])+ assert result["stream"] is False+ assert result[HEADROOM_CONVERTED_STREAM_KEY] is True++@pytest.mark.asyncioasync def test_streaming_chat_completion_resolves_ccr_retrieval_end_to_end(guardrail: HeadroomGuardrail,