From e40ad5203eb3a6a07a7d171f60f642f97ac75666 Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Tue, 16 Dec 2025 09:28:04 +0530 Subject: [PATCH] Add container field as provider specific field --- litellm/llms/anthropic/chat/transformation.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index 628121ab11c..72c95eef12b 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -1132,22 +1132,12 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): if content["type"] == "text": text_content += content["text"] ## TOOL CALLING - elif content["type"] == "tool_use": + elif content["type"] == "tool_use" or content["type"] == "server_tool_use": tool_call = AnthropicConfig.convert_tool_use_to_openai_format( anthropic_tool_content=content, index=idx, ) tool_calls.append(tool_call) - ## SERVER TOOL USE (for tool search) - elif content["type"] == "server_tool_use": - # Server tool use blocks are for tool search - treat as tool calls - # Note: using .get("input", {}) for server_tool_use as input may not be present - content_with_input = {**content, "input": content.get("input", {})} - tool_call = AnthropicConfig.convert_tool_use_to_openai_format( - anthropic_tool_content=content_with_input, - index=idx, - ) - tool_calls.append(tool_call) ## TOOL SEARCH TOOL RESULT (skip - this is metadata about tool discovery) elif content["type"] == "tool_search_tool_result": # This block contains tool_references that were discovered @@ -1343,6 +1333,8 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): "context_management" ) + container: Optional[Dict] = completion_response.get("container") + provider_specific_fields: Dict[str, Any] = { "citations": citations, "thinking_blocks": thinking_blocks, @@ -1351,7 +1343,9 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): provider_specific_fields["context_management"] = context_management if web_search_results is not None: provider_specific_fields["web_search_results"] = web_search_results - + if container is not None: + provider_specific_fields["container"] = container + _message = litellm.Message( tool_calls=tool_calls, content=text_content or None,