From f6a0299e914b028cb88e214e57a1e5941a0c1723 Mon Sep 17 00:00:00 2001 From: Yucheng Date: Mon, 5 Oct 2026 00:13:24 -0700 Subject: [PATCH] fix(responses): cast content block before reading prompt_cache_breakpoint basedpyright flags the raw dict.get read as reportUnknownArgumentType (+2 against the error budget); cast the isinstance-narrowed block to dict[str, object] first, matching the strip helpers' cast-ok idiom. --- .../transformation.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.py index 9a710a5ac99..94a71bd6d7d 100644 --- a/litellm/completion_extras/litellm_responses_transformation/transformation.py +++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py @@ -1117,7 +1117,9 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge): if original_type == "text": converted = with_prompt_cache_breakpoint( self._convert_content_str_to_input_text(item.get("text", ""), role), - item.get("prompt_cache_breakpoint"), + cast(dict[str, object], item).get( # cast-ok: isinstance confirms the content block is a mapping + "prompt_cache_breakpoint" + ), ) result.append(converted) verbose_logger.debug("Chat provider: text -> %s", converted) @@ -1130,7 +1132,9 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge): role, ) ), - item.get("prompt_cache_breakpoint"), + cast(dict[str, object], item).get( # cast-ok: isinstance confirms the content block is a mapping + "prompt_cache_breakpoint" + ), ) result.append(converted) verbose_logger.debug("Chat provider: image_url -> %s", converted) @@ -1146,7 +1150,9 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge): _input_file_from_file_value( cast("ChatCompletionFileObject", item).get("file"), # cast-ok: type tag checked ), - item.get("prompt_cache_breakpoint"), + cast(dict[str, object], item).get( # cast-ok: isinstance confirms the content block is a mapping + "prompt_cache_breakpoint" + ), ) result.append(converted) verbose_logger.debug("Chat provider: file -> %s", converted)