{"record":{"id":"4737ca07f1383af5","repo":"microsoft/autogen","slug":"the-tool-tool-call-name-is-not-available-4737ca","errorCode":null,"errorMessage":"The tool '{tool_call.name}' is not available.","messagePattern":"The tool '(.+?)' is not available\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py","lineNumber":390,"sourceCode":"    @property\n    def _get_assistant_id(self) -> str:\n        if self._assistant is None:\n            raise ValueError(\"Assistant not initialized\")\n        return self._assistant.id\n\n    @property\n    def _thread_id(self) -> str:\n        if self._thread is None:\n            raise ValueError(\"Thread not initialized\")\n        return self._thread.id\n\n    async def _execute_tool_call(self, tool_call: FunctionCall, cancellation_token: CancellationToken) -> str:\n        \"\"\"Execute a tool call and return the result.\"\"\"\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 on_messages(self, messages: Sequence[BaseChatMessage], cancellation_token: CancellationToken) -> Response:\n        \"\"\"Handle incoming messages and return a response.\"\"\"\n\n        async for message in self.on_messages_stream(messages, cancellation_token):\n            if isinstance(message, Response):\n                return message\n        raise AssertionError(\"The stream should have returned the final result.\")\n\n    async def on_messages_stream(\n        self, messages: Sequence[BaseChatMessage], cancellation_token: CancellationToken\n    ) -> AsyncGenerator[BaseAgentEvent | BaseChatMessage | Response, None]:\n        \"\"\"Handle incoming messages and return a response.\"\"\"\n        await self._ensure_initialized()\n","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py#L372-L408","documentation":"OpenAIAssistantAgent._execute_tool_call looks up the requested function name in self._original_tools; if no registered Tool has that name it raises ValueError. The OpenAI assistant is asking to call a function that the local Python agent never registered — a server/local tool-definition mismatch.","triggerScenarios":"An existing assistant (assistant_id) defines a function 'get_stock_price' server-side, but the agent was constructed with tools that don't include a tool of exactly that name; tool renamed locally; name typos between server definition and local FunctionTool name.","commonSituations":"Attaching to pre-created assistants whose function sets drifted from the code; renaming Python functions without updating the OpenAI assistant definition (or vice versa); multiple agents sharing one assistant_id with different tool sets.","solutions":["Register a local tool whose name exactly matches the function in the error message: tools=[FunctionTool(get_stock_price, ...)].","Or update/recreate the OpenAI assistant so its function definitions match the locally available tools.","For callables, remember the registered name derives from the function name — wrap with FunctionTool(name=...) if you need to decouple them."],"exampleFix":"# before\nasync def stock_price(ticker: str) -> str: ...\nagent = OpenAIAssistantAgent(name=\"a\", model=\"gpt-4o\", client=cl,\n                            assistant_id=\"asst_1\", tools=[stock_price])\n# server assistant asks for \"get_stock_price\" -> not available\n\n# after\nfrom autogen_core.tools import FunctionTool\nagent = OpenAIAssistantAgent(\n    name=\"a\", model=\"gpt-4o\", client=cl, assistant_id=\"asst_1\",\n    tools=[FunctionTool(stock_price, name=\"get_stock_price\",\n                        description=\"Get the price for a ticker\")],\n)","handlingStrategy":"validation","validationCode":"registered = {t.name for t in agent._original_tools}\nrequired = {fc.name for fc in pending_function_calls}\nmissing = required - registered\nif missing:\n    raise ConfigError(f\"Server tools not registered locally: {missing}\")","typeGuard":null,"tryCatchPattern":"try:\n    result = await agent.on_messages(msgs, ct)\nexcept ValueError as e:\n    if \"is not available\" in str(e):\n        # register the named tool locally and retry\n        raise  # after fixing tool registration\n    raise","preventionTips":["Mirror server-side function names exactly; use FunctionTool(name=...) to pin names.","Rename functions in one place (the assistant definition) and regenerate the other.","Log tool-call names in tests to catch drift early."],"tags":["openai","assistants-api","tools","name-mismatch"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}