From dfa26029207781fb1302e20c35a84375afa902af Mon Sep 17 00:00:00 2001 From: yuwk <1729065730@qq.com> Date: Sat, 5 Sep 2026 10:28:52 +0800 Subject: [PATCH] fix(anthropic): drop superseded adapters tool_reference test left over from main merge Upstream's _tool_result_part refactor now preserves tool_reference blocks as ChatCompletionToolReferenceObject on the /v1/messages path, so the older [Loaded tool: ...] text expectation in the adapters test is superseded. The responses_adapters path (LiteLLMAnthropicToResponsesAPIAdapter) still converts tool references to loaded-tool text and keeps its own regression test. --- ...al_pass_through_adapters_transformation.py | 64 ------------------- 1 file changed, 64 deletions(-) diff --git a/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py b/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py index 431aa2d15bf..2d74c00071b 100644 --- a/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py +++ b/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py @@ -1645,70 +1645,6 @@ def test_translate_anthropic_messages_to_openai_tool_result_single_item_backward assert tool_message["content"] == "72°F and sunny" -@pytest.mark.parametrize( - ("tool_references", "expected_content"), - [ - ( - [{"type": "tool_reference", "tool_name": "get_weather"}], - "[Loaded tool: get_weather]", - ), - ( - [ - {"type": "tool_reference", "tool_name": "get_weather"}, - {"type": "tool_reference", "tool_name": "search_docs"}, - ], - [ - {"type": "text", "text": "[Loaded tool: get_weather]"}, - {"type": "text", "text": "[Loaded tool: search_docs]"}, - ], - ), - ], -) -def test_translate_anthropic_messages_to_openai_tool_reference_results( - tool_references: list[dict[str, str]], expected_content: Any -): - anthropic_messages = [ - AnthopicMessagesAssistantMessageParam( - role="assistant", - content=[ - { - "type": "tool_use", - "id": "toolu_tool_search", - "name": "ToolSearch", - "input": {"query": "weather"}, - } - ], - ), - AnthropicMessagesUserMessageParam( - role="user", - content=[ - { - "type": "tool_result", - "tool_use_id": "toolu_tool_search", - "content": tool_references, - } - ], - ), - ] - - result = LiteLLMAnthropicMessagesAdapter().translate_anthropic_messages_to_openai( - messages=anthropic_messages - ) - - tool_messages = [ - message - for message in result - if isinstance(message, dict) and message.get("role") == "tool" - ] - assert tool_messages == [ - { - "role": "tool", - "tool_call_id": "toolu_tool_search", - "content": expected_content, - } - ] - - def test_streaming_chunk_with_both_text_and_tool_calls_issue_18238(): """ When a streaming choice contains both text content and tool_calls,