{"record":{"id":"3bc2c70a6b2f71eb","repo":"microsoft/autogen","slug":"the-tool-tool-call-name-is-not-available","errorCode":null,"errorMessage":"The tool '{tool_call.name}' is not available.","messagePattern":"The tool '(.+?)' is not available\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/agents/azure/_azure_ai_agent.py","lineNumber":560,"sourceCode":"    async def _execute_tool_call(self, tool_call: FunctionCall, cancellation_token: CancellationToken) -> str:\n        \"\"\"\n        Execute a tool call requested by the Azure AI agent.\n\n        Args:\n            tool_call (FunctionCall): The function call information including name and arguments\n            cancellation_token (CancellationToken): Token for cancellation handling\n\n        Returns:\n            str: The string representation of the tool call result\n\n        Raises:\n            ValueError: If the requested tool is not available or no tools are registered\n        \"\"\"\n        if not self._original_tools:\n            raise ValueError(\"No tools are available.\")\n        tool = next((t for t in self._original_tools if t.name == tool_call.name), None)\n        if tool is None:\n            raise ValueError(f\"The tool '{tool_call.name}' is not available.\")\n        arguments = json.loads(tool_call.arguments)\n        result = await tool.run_json(arguments, cancellation_token, call_id=tool_call.id)\n        return tool.return_value_as_string(result)\n\n    async def _upload_files(\n        self,\n        file_paths: str | Iterable[str],\n        purpose: str = \"assistant\",\n        polling_interval: float = 0.5,\n        cancellation_token: Optional[CancellationToken] = None,\n    ) -> List[str]:\n        \"\"\"\n        Upload files to the Azure AI Assistant API.\n\n        This method handles uploading one or more files to be used by the agent\n        and tracks their IDs in the agent's state.\n\n        Args:","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/agents/azure/_azure_ai_agent.py#L542-L578","documentation":"Raised while handling a tool call when a tool with the requested name exists in _original_tools lookup but the exact name from the model's function call doesn't match any registered tool. The service (model) emitted a function call whose name has no counterpart among the client-side Tool objects registered on this agent.","triggerScenarios":"The model hallucinates or mutates a tool name (e.g. get_weather_2, camelCase vs snake_case); the tool set changed between the run that produced the pending call and the current agent; a FunctionTool was registered under a different name than the FunctionToolDefinition advertised.","commonSituations":"Renaming a function without updating its schema/name; resuming an old thread after deploying new tool names; schemas generated from docstrings where the name drifted from the implementation.","solutions":["Make the registered Tool's name exactly match the name in the tool definition sent to the service (verify FunctionTool(name=...) vs the definition).","Re-attach the original tools before resuming a thread that has pending tool calls.","If the model invented the name, tighten the tool description/prompt or lower temperature; optionally retry the turn.","Add a fallback handler that returns an error string to the model instead of raising, so the run can continue."],"exampleFix":"# before\nFunctionTool(get_weather, name=\"weather\")  # service calls \"get_weather\"\n# after\nFunctionTool(get_weather, name=\"get_weather\")  # match the advertised name","handlingStrategy":"validation","validationCode":"registered = {t.name for t in original_tools}\nadvertised = {d.name for d in api_tool_definitions}\nmismatch = advertised - registered\nassert not mismatch, f\"Definitions without implementations: {mismatch}\"","typeGuard":null,"tryCatchPattern":"try:\n    resp = await agent.on_messages(msgs, ct)\nexcept ValueError as e:\n    if \"is not available\" in str(e):\n        # name drift: rebuild tools so FunctionTool.name matches the definition\n        ...","preventionTips":["Set FunctionTool(name=...) explicitly to match the advertised definition name.","Never rename a tool without redeploying its schema and clearing old threads.","Consider a catch-all tool or error-reply fallback so mismatched names don't kill the run."],"tags":["azure","tools","llm-output","azure-ai-agent"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}