{"record":{"id":"e1ef3d76d03c9f13","repo":"BerriAI/litellm","slug":"tool-search-tool-must-have-a-valid-name","errorCode":null,"errorMessage":"Tool search tool must have a valid name","messagePattern":"Tool search tool must have a valid name","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/anthropic/chat/transformation.py","lineNumber":735,"sourceCode":"                if k != \"type\" and k != \"name\":\n                    additional_tool_params[k] = v\n\n            returned_tool = AnthropicHostedTools(\n                type=tool[\"type\"],\n                name=function_name,\n                **additional_tool_params,\n            )\n        elif tool[\"type\"] == \"url\":  # mcp server tool\n            mcp_server = AnthropicMcpServerTool(**tool)\n        elif tool[\"type\"] == \"mcp\":\n            mcp_server = self._map_openai_mcp_server_tool(cast(OpenAIMcpServerTool, tool))\n        elif tool[\"type\"] == \"tool_search_tool_regex_20251119\":\n            # Tool search tool using regex\n            from litellm.types.llms.anthropic import AnthropicToolSearchToolRegex\n\n            tool_name_obj = tool.get(\"name\", \"tool_search_tool_regex\")\n            if not isinstance(tool_name_obj, str):\n                raise ValueError(\"Tool search tool must have a valid name\")\n            tool_name = tool_name_obj\n            returned_tool = AnthropicToolSearchToolRegex(\n                type=\"tool_search_tool_regex_20251119\",\n                name=tool_name,\n            )\n        elif tool[\"type\"] == \"tool_search_tool_bm25_20251119\":\n            # Tool search tool using BM25\n            from litellm.types.llms.anthropic import AnthropicToolSearchToolBM25\n\n            tool_name_obj = tool.get(\"name\", \"tool_search_tool_bm25\")\n            if not isinstance(tool_name_obj, str):\n                raise ValueError(\"Tool search tool must have a valid name\")\n            tool_name = tool_name_obj\n            returned_tool = AnthropicToolSearchToolBM25(\n                type=\"tool_search_tool_bm25_20251119\",\n                name=tool_name,\n            )\n        elif tool[\"type\"] == ANTHROPIC_ADVISOR_TOOL_TYPE:","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/anthropic/chat/transformation.py#L717-L753","documentation":"Tool-mapping guard in the Anthropic chat transformation: an Anthropic hosted/tool-search tool was supplied whose name is not a valid string (missing or wrong type), so it cannot be sent to the API.","triggerScenarios":"Thrown at litellm/llms/anthropic/chat/transformation.py:735 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Give the tool search tool a valid non-empty 'name' string."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}