BerriAI/litellm · error · ValueError
Advisor tool must have a valid model
Error message
Advisor tool must have a valid model
What it means
For the Anthropic advisor tool (ANTHROPIC_ADVISOR_TOOL_TYPE), LiteLLM requires tool['model'] to be a string naming the advisor model; it builds AnthropicAdvisorTool(name='advisor', model=...). A missing or non-string 'model' raises this ValueError client-side.
Source
Thrown at litellm/llms/anthropic/chat/transformation.py:759
elif tool["type"] == "tool_search_tool_bm25_20251119":
# Tool search tool using BM25
from litellm.types.llms.anthropic import AnthropicToolSearchToolBM25
tool_name_obj = tool.get("name", "tool_search_tool_bm25")
if not isinstance(tool_name_obj, str):
raise ValueError("Tool search tool must have a valid name")
tool_name = tool_name_obj
returned_tool = AnthropicToolSearchToolBM25(
type="tool_search_tool_bm25_20251119",
name=tool_name,
)
elif tool["type"] == ANTHROPIC_ADVISOR_TOOL_TYPE:
from litellm.types.llms.anthropic import AnthropicAdvisorTool
_tool_dict: Final = cast(dict, tool)
advisor_model: Final = _tool_dict.get("model")
if not isinstance(advisor_model, str):
raise ValueError("Advisor tool must have a valid model")
_advisor_tool: Final = AnthropicAdvisorTool(
type=ANTHROPIC_ADVISOR_TOOL_TYPE,
name="advisor",
model=advisor_model,
)
if _tool_dict.get("max_uses") is not None:
_advisor_tool["max_uses"] = _tool_dict["max_uses"]
if _tool_dict.get("caching") is not None:
_advisor_tool["caching"] = _tool_dict["caching"]
returned_tool = _advisor_tool
if returned_tool is None and mcp_server is None:
raise ValueError(f"Unsupported tool type: {tool['type']}")
## check if cache_control is set in the tool
_cache_control: Final = tool.get("cache_control", None)
_cache_control_function: Final = tool.get("function", {}).get("cache_control", None)
if returned_tool is not None:
# Only set cache_control on tools that support it (not tool search tools)View on GitHub (pinned to 6c2dcb801b)
Solutions
- Add 'model': '<model-id>' (a string, e.g. the advisor model Anthropic documents) to the advisor tool dict.
- Verify optional extras (max_uses, caching) are separate keys; only 'model' is mandatory.
- Default empty strings from config to a concrete model id before building the tool.
Example fix
# before
{"type": "advisor_20251119", "max_uses": 2}
# after
{"type": "advisor_20251119", "model": "claude-sonnet-4-5", "max_uses": 2} Defensive patterns
Strategy: validation
Validate before calling
if tool.get("type") == "advisor_20251119":
m = tool.get("model")
if not isinstance(m, str) or not m:
raise ValueError("advisor tool requires a non-empty string 'model'") Type guard
def advisor_tool_valid(tool) -> bool:
return isinstance(tool.get("model"), str) and len(tool["model"]) > 0 Prevention
- Default advisor model from config with a concrete fallback string.
- Reject empty-string model values early — they pass 'is not None' but fail isinstance checks downstream in spirit.
When it happens
Trigger: Passing {'type': <advisor type>, 'max_uses': 2} without 'model', or with 'model': None / a dict. The advisor tool always needs the backing model specified.
Common situations: Enabling the advisor feature from release notes without copying the full required fields; environment-driven configs where the model variable was empty and serialized as None.
Related errors
- advisor tool definition must include a 'model' field specify
- Missing required parameter: parameters
- Missing required parameter: display_width_px or display_heig
- Missing required parameter: name
- Tool search tool must have a valid name
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/8127354fae33233a.
Report an issue: GitHub.