The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(advisor): replace hardcoded "advisor_20260301" with ANTHROPIC_ADVISOR_TOOL_TYPE constant
Ishaan Jaffer9897c6d46b7f
diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.pyindex 185e1b5de3f..e78c72c13d0 100644--- a/litellm/llms/anthropic/chat/transformation.py+++ b/litellm/llms/anthropic/chat/transformation.py@@ -19,6 +19,7 @@ from litellm.litellm_core_utils.core_helpers import map_finish_reasonfrom litellm.llms.base_llm.base_utils import type_to_response_format_paramfrom litellm.llms.base_llm.chat.transformation import BaseConfig, BaseLLMExceptionfrom litellm.types.llms.anthropic import (+ ANTHROPIC_ADVISOR_TOOL_TYPE,ANTHROPIC_BETA_HEADER_VALUES,ANTHROPIC_HOSTED_TOOLS,AllAnthropicMessageValues,@@ -513,7 +514,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):type="tool_search_tool_bm25_20251119",name=tool_name,)- elif tool["type"] == "advisor_20260301":+ elif tool["type"] == ANTHROPIC_ADVISOR_TOOL_TYPE:from litellm.types.llms.anthropic import AnthropicAdvisorTool_tool_dict = cast(dict, tool)@@ -521,7 +522,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):if not isinstance(advisor_model, str):raise ValueError("Advisor tool must have a valid model")_advisor_tool = AnthropicAdvisorTool(- type="advisor_20260301",+ type=ANTHROPIC_ADVISOR_TOOL_TYPE,name="advisor",model=advisor_model,)@@ -1334,7 +1335,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):headers, ANTHROPIC_BETA_HEADER_VALUES.FAST_MODE_2026_02_01.value)for tool in _tools:- if tool.get("type") == "advisor_20260301":+ if tool.get("type") == ANTHROPIC_ADVISOR_TOOL_TYPE:self._ensure_beta_header(headers, ANTHROPIC_BETA_HEADER_VALUES.ADVISOR_TOOL_2026_03_01.value)@@ -1422,7 +1423,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):## Prevents Anthropic 400: advisor_tool_result in history requires advisor tool._all_tools = optional_params.get("tools") or []_has_advisor = any(- isinstance(t, dict) and t.get("type") == "advisor_20260301"+ isinstance(t, dict) and t.get("type") == ANTHROPIC_ADVISOR_TOOL_TYPEfor t in _all_tools)if not _has_advisor:diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.pyindex 6fac6b5e351..46af1f7fbd1 100644--- a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py+++ b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py@@ -8,6 +8,7 @@ from litellm.llms.base_llm.anthropic_messages.transformation import (BaseAnthropicMessagesConfig,)from litellm.types.llms.anthropic import (+ ANTHROPIC_ADVISOR_TOOL_TYPE,ANTHROPIC_BETA_HEADER_VALUES,AnthropicMessagesRequest,)@@ -220,7 +221,8 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig):# Prevents Anthropic 400: advisor_tool_result in history requires advisor tool._tools = anthropic_messages_optional_request_params.get("tools") or []_has_advisor = any(- isinstance(t, dict) and t.get("type") == "advisor_20260301" for t in _tools+ isinstance(t, dict) and t.get("type") == ANTHROPIC_ADVISOR_TOOL_TYPE+ for t in _tools)if not _has_advisor:messages = strip_advisor_blocks_from_messages(messages) # type: ignore[assignment]@@ -339,7 +341,10 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig):tools = optional_params.get("tools")if tools:for tool in tools:- if isinstance(tool, dict) and tool.get("type") == "advisor_20260301":+ if (+ isinstance(tool, dict)+ and tool.get("type") == ANTHROPIC_ADVISOR_TOOL_TYPE+ ):beta_values.add(ANTHROPIC_BETA_HEADER_VALUES.ADVISOR_TOOL_2026_03_01.value)diff --git a/litellm/types/llms/anthropic.py b/litellm/types/llms/anthropic.pyindex b9e1ebd4173..c76f27bdd6c 100644--- a/litellm/types/llms/anthropic.py+++ b/litellm/types/llms/anthropic.py@@ -126,6 +126,9 @@ class AnthropicToolSearchToolBM25(TypedDict, total=False):input_examples: Optional[List[Dict[str, Any]]]+ANTHROPIC_ADVISOR_TOOL_TYPE = "advisor_20260301"++class AnthropicAdvisorTool(TypedDict, total=False):"""Advisor tool — pairs a fast executor model with a high-intelligence advisor model."""