From ce3612e316ca9dec46566e42726cc1dcdf0894ca Mon Sep 17 00:00:00 2001 From: Ultronen <82553854+Ultronen@users.noreply.github.com> Date: Wed, 9 Sep 2026 11:32:09 +0800 Subject: [PATCH] refactor(proxy): simplify streaming hook response guard --- litellm/proxy/utils.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 80157b2768b..13f1071f1fa 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -3685,17 +3685,12 @@ class ProxyLogging: user_api_key_dict=user_api_key_dict, response=complete_response, ) - if callback_response is not None: - # A text result cannot represent a structured empty-text - # chunk such as a tool-call delta. Preserve the chunk - # only when the callback returned its input unchanged. - if _is_unchanged_structured_streaming_hook_response( - callback_response=callback_response, - complete_response=complete_response, - response_str=response_str, - response=response, - ): - continue + if callback_response is not None and not _is_unchanged_structured_streaming_hook_response( + callback_response=callback_response, + complete_response=complete_response, + response_str=response_str, + response=response, + ): response = callback_response except Exception as e: raise e