From 437d504ef08daaec129003c439d9941086e72d1b Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Wed, 18 Feb 2026 12:59:35 -0800 Subject: [PATCH] fix indentation and add clarifying comment for usage stripping --- litellm/litellm_core_utils/streaming_handler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index 73d3e6bb629..cdc480f610e 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -1960,6 +1960,10 @@ class CustomStreamWrapper: # The copy in self.chunks retains usage for # calculate_total_usage(). processed_chunk.usage = None # type: ignore + # After nullifying usage, check if the chunk has any + # remaining content (delta, finish_reason, etc.). + # is_model_response_stream_empty sees usage=None and + # correctly skips it, only checking meaningful fields. is_empty = is_model_response_stream_empty( model_response=cast(ModelResponseStream, processed_chunk) )