From a552da9ad2d39bde3707665f436e6493d6e2c9cc Mon Sep 17 00:00:00 2001 From: Rishab Motgi Date: Mon, 18 May 2026 16:33:41 -0700 Subject: [PATCH] fix: reset _repeated_messages_count on empty-choices early return Address Greptile review: the adjacent null-content guard resets _repeated_messages_count = 1 before returning, but the new empty-choices guard did not. Add the reset for consistency so metadata chunks don't leave a stale counter that could affect repetition detection on the next real content chunk. --- litellm/litellm_core_utils/streaming_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index 2956db122d5..bf70a3c712c 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -270,6 +270,7 @@ class CustomStreamWrapper: return if not self.chunks[-1].choices or not self.chunks[-2].choices: + self._repeated_messages_count = 1 return last_content = self.chunks[-1].choices[0].delta.content