From a524926ebaf1dbed9d948538d1c671826291ebe7 Mon Sep 17 00:00:00 2001 From: mateo Date: Tue, 27 Oct 2026 20:29:35 +0000 Subject: [PATCH] fix(types): read the Anthropic response as a Mapping when building provider_specific_fields Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/llms/anthropic/chat/transformation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index 162b7190b00..462e91ab781 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -2920,7 +2920,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): def _build_provider_specific_fields( self, - completion_response: dict[str, object], + completion_response: Mapping[str, object], citations: Sequence[object] | None, thinking_blocks: list[ChatCompletionThinkingBlock | ChatCompletionRedactedThinkingBlock] | None, web_search_results: Sequence[object] | None, @@ -2952,7 +2952,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): provider_specific_fields["tool_results"] = tool_results container: Final = completion_response.get("container") - container_fields: Final[dict[str, object] | None] = container if isinstance(container, dict) else None + container_fields: Final[Mapping[str, object] | None] = container if isinstance(container, dict) else None if tool_results is not None and any(result.get("type") != "tool_search_tool_result" for result in tool_results): raw_container_id: Final = container_fields.get("id") if container_fields is not None else None container_id: Final = raw_container_id if isinstance(raw_container_id, str) else None