From 307b47190295b4438b57f04d22f5aeb2a7e29f42 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 28 Aug 2026 16:45:45 -0700 Subject: [PATCH] style(guardrails): drop narrative comments from the deferred logging path --- .../messages/streaming_iterator.py | 6 ------ litellm/proxy/common_request_processing.py | 5 ----- litellm/proxy/utils.py | 6 ------ 3 files changed, 17 deletions(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/messages/streaming_iterator.py index e0ddd54c24f..a282d5f4d4f 100644 --- a/litellm/llms/anthropic/experimental_pass_through/messages/streaming_iterator.py +++ b/litellm/llms/anthropic/experimental_pass_through/messages/streaming_iterator.py @@ -367,12 +367,6 @@ class BaseAnthropicMessagesStreamingIterator: deferred_dispatch_armed: Final = ( getattr(self.litellm_logging_obj, "_on_deferred_stream_complete", None) is not None ) - # Post-call guardrails run their end-of-stream scan AFTER this iterator - # is exhausted, so enqueueing now would build the spend log before the - # scan writes guardrail_information. Park the coroutine instead; the - # proxy fires it via _fire_deferred_stream_logging once the guardrail - # chain drains. Teardown (client disconnect) keeps enqueueing - # immediately: the scan never runs there and billing must not be lost. if deferred_dispatch_armed and not stream_teardown: self.litellm_logging_obj._deferred_stream_complete_args = (logging_coroutine,) return diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py index 936ca1607b5..ff6c8d1b1f8 100644 --- a/litellm/proxy/common_request_processing.py +++ b/litellm/proxy/common_request_processing.py @@ -2377,11 +2377,6 @@ class ProxyBaseLLMRequestProcessing: and route_type == "anthropic_messages" and self._is_streaming_response(response) ): - # Native /v1/messages SSE streams bypass CSW, so the raw - # iterator parks its logging coroutine at stream end (see - # BaseAnthropicMessagesStreamingIterator._handle_streaming_logging) - # and _fire_deferred_stream_logging hands it here after the - # guardrail end-of-stream scans complete. from litellm.litellm_core_utils.logging_worker import ( GLOBAL_LOGGING_WORKER, ) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 516a50610d0..9fbe1b4bd06 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -3227,12 +3227,6 @@ class ProxyLogging: ), ) - # Actually iterate through the chained async generator and yield chunks. - # A guardrail block raised after upstream exhaustion (e.g. - # unified_guardrail re-raising HTTPException) must still flush any - # parked deferred logging, or the blocked stream loses its spend log. - # GeneratorExit/CancelledError stay untouched: disconnect cleanup owns - # those. try: async for chunk in current_response: yield chunk