From 395fed3cb6697ebee762374e718696553bd3ed3b Mon Sep 17 00:00:00 2001 From: basil-k-aji-dev <70605804+basil-k-aji-dev@users.noreply.github.com> Date: Mon, 5 Oct 2026 09:40:48 +0530 Subject: [PATCH] refactor(streaming): drop explanatory comments AGENTS.md allows comments only for complex business logic, tool directives or TODOs. These three explained why the two reads are annotated: the values reach get_litellm_params and the handler through untyped kwargs and an extra field on GenericLiteLLMParams, so an unannotated read is an Any and counts against the unknown-argument budget. Declaring the fields would change the proxy OpenAPI spec --- litellm/litellm_core_utils/streaming_handler.py | 7 ------- litellm/main.py | 2 -- 2 files changed, 9 deletions(-) diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index 2013033041a..f2da2bc4a1f 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -230,9 +230,6 @@ class CustomStreamWrapper: dict(**self.logging_obj.model_call_details.get("litellm_params", {})) ) self.merge_reasoning_content_in_choices: bool = litellm_params.merge_reasoning_content_in_choices or False - # GenericLiteLLMParams allows extra fields, so the flag arrives without being - # declared on it. The annotation is what keeps this off the unknown-argument - # budget; declaring the field would change the proxy OpenAPI spec. request_strict: Final[bool | None] = getattr(litellm_params, "strict_stream_completion", None) self.strict_stream_completion: bool = ( bool(litellm.strict_stream_completion) if request_strict is None else bool(request_strict) @@ -1726,10 +1723,6 @@ class CustomStreamWrapper: @received_finish_reason.setter def received_finish_reason(self, value: str | None) -> None: - # A provider assigning this at all is the provider saying the stream - # ended, even when the reason it gives is empty. Recording that here - # rather than beside each of the dozen assignments keeps the two from - # drifting apart. self._received_finish_reason = value if value is not None: self.stream_reported_finished = True diff --git a/litellm/main.py b/litellm/main.py index 1c3d7c5082b..fa698c1612d 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -5658,8 +5658,6 @@ def completion( messages = function_call_prompt(messages=messages, functions=functions_unsupported_model) # For logging - save the values of the litellm-specific params passed in - # kwargs is untyped, so reading the flag straight into the call makes it an - # Any argument; the annotation keeps it off the unknown-argument budget. strict_stream_completion: bool | None = kwargs.get("strict_stream_completion", None) requested_litellm_params: Final = get_litellm_params( acompletion=acompletion,