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.
This commit is contained in:
Ishaan Jaffer 2026-04-13 16:59:27 -07:00
parent bd5740a367
commit 9640dd5765
No known key found for this signature in database

View file

@ -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