From 55f0e6605b2d3f0a7d328aaea3131fea73b83012 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Fri, 10 Apr 2026 11:48:39 -0700 Subject: [PATCH] test(anthropic): add advisor tool tests for /messages beta header path --- .../test_anthropic_chat_transformation.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py index 8fa679a7ac7..2e30ad0c98f 100644 --- a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py +++ b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py @@ -3503,3 +3503,29 @@ def test_advisor_tool_result_preserved_in_response(): assert len(tool_results) == 1 assert tool_results[0]["type"] == "advisor_tool_result" assert tool_results[0]["tool_use_id"] == "srvtoolu_abc123" + + +def test_messages_path_advisor_beta_header_injected(): + """advisor-tool-2026-03-01 beta header is auto-injected in /messages path.""" + config = AnthropicMessagesConfig() + headers: dict = {} + optional_params = { + "tools": [ + { + "type": "advisor_20260301", + "name": "advisor", + "model": "claude-opus-4-6", + } + ] + } + result = config._update_headers_with_anthropic_beta(headers, optional_params) + assert "advisor-tool-2026-03-01" in result.get("anthropic-beta", "") + + +def test_messages_path_advisor_beta_header_preserved_when_user_sends_it(): + """Existing anthropic-beta headers are preserved and advisor header is merged.""" + config = AnthropicMessagesConfig() + headers: dict = {"anthropic-beta": "advisor-tool-2026-03-01"} + optional_params: dict = {"tools": []} + result = config._update_headers_with_anthropic_beta(headers, optional_params) + assert "advisor-tool-2026-03-01" in result.get("anthropic-beta", "")