From 9640dd57654d78644703da1797888f54fa3f8eae Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Mon, 13 Apr 2026 16:59:27 -0700 Subject: [PATCH] fix(streaming): scope role-only chunk preservation to Azure only The Azure streaming fix (PR #25638) made is_chunk_non_empty() treat any first chunk with role!=None as non-empty, for all providers. This broke OpenAI/Mistral tests where the role-only first chunk was expected to be filtered, and test idx==0 assumed the first emitted chunk had actual content (tool_calls, logprobs, etc.). Restrict the condition to Azure, which is the provider that actually needs it: Azure sends prompt_filter_results before the first content chunk, which consumes sent_first_chunk and strips role from the real first chunk. Other providers should retain the original behavior. --- litellm/litellm_core_utils/streaming_handler.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index ca5f6a2f6db..058539f6c50 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -839,10 +839,7 @@ class CustomStreamWrapper: not self.sent_first_chunk and hasattr(model_response.choices[0].delta, "role") and model_response.choices[0].delta.role is not None - and not ( - model_response.choices[0].logprobs is not None - and not model_response.choices[0].logprobs.content - ) + and self.custom_llm_provider == "azure" ) ): return True