microsoft/autogen · error · ValueError

The tool '{tool_call.name}' is not available.

Error message

The tool '{tool_call.name}' is not available.

What it means

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.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py:390

    @property
    def _get_assistant_id(self) -> str:
        if self._assistant is None:
            raise ValueError("Assistant not initialized")
        return self._assistant.id

    @property
    def _thread_id(self) -> str:
        if self._thread is None:
            raise ValueError("Thread not initialized")
        return self._thread.id

    async def _execute_tool_call(self, tool_call: FunctionCall, cancellation_token: CancellationToken) -> str:
        """Execute a tool call and return the result."""
        if not self._original_tools:
            raise ValueError("No tools are available.")
        tool = next((t for t in self._original_tools if t.name == tool_call.name), None)
        if tool is None:
            raise ValueError(f"The tool '{tool_call.name}' is not available.")
        arguments = json.loads(tool_call.arguments)
        result = await tool.run_json(arguments, cancellation_token, call_id=tool_call.id)
        return tool.return_value_as_string(result)

    async def on_messages(self, messages: Sequence[BaseChatMessage], cancellation_token: CancellationToken) -> Response:
        """Handle incoming messages and return a response."""

        async for message in self.on_messages_stream(messages, cancellation_token):
            if isinstance(message, Response):
                return message
        raise AssertionError("The stream should have returned the final result.")

    async def on_messages_stream(
        self, messages: Sequence[BaseChatMessage], cancellation_token: CancellationToken
    ) -> AsyncGenerator[BaseAgentEvent | BaseChatMessage | Response, None]:
        """Handle incoming messages and return a response."""
        await self._ensure_initialized()

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Register a local tool whose name exactly matches the function in the error message: tools=[FunctionTool(get_stock_price, ...)].
  2. Or update/recreate the OpenAI assistant so its function definitions match the locally available tools.
  3. For callables, remember the registered name derives from the function name — wrap with FunctionTool(name=...) if you need to decouple them.

Example fix

# before
async def stock_price(ticker: str) -> str: ...
agent = OpenAIAssistantAgent(name="a", model="gpt-4o", client=cl,
                            assistant_id="asst_1", tools=[stock_price])
# server assistant asks for "get_stock_price" -> not available

# after
from autogen_core.tools import FunctionTool
agent = OpenAIAssistantAgent(
    name="a", model="gpt-4o", client=cl, assistant_id="asst_1",
    tools=[FunctionTool(stock_price, name="get_stock_price",
                        description="Get the price for a ticker")],
)
Defensive patterns

Strategy: validation

Validate before calling

registered = {t.name for t in agent._original_tools}
required = {fc.name for fc in pending_function_calls}
missing = required - registered
if missing:
    raise ConfigError(f"Server tools not registered locally: {missing}")

Try / catch

try:
    result = await agent.on_messages(msgs, ct)
except ValueError as e:
    if "is not available" in str(e):
        # register the named tool locally and retry
        raise  # after fixing tool registration
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/4737ca07f1383af5. Report an issue: GitHub.