microsoft/autogen · error · ValueError

tool_choice specified but no tools provided

Error message

tool_choice specified but no tools provided

What it means

Error "tool_choice specified but no tools provided" thrown in microsoft/autogen.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py:639

        # Add system message if present
        if system_message is not None:
            request_args["system"] = system_message

        has_tool_results = any(isinstance(msg, FunctionExecutionResultMessage) for msg in messages)

        # Store and add tools if present
        if len(tools) > 0:
            converted_tools = convert_tools(tools)
            self._last_used_tools = converted_tools
            request_args["tools"] = converted_tools
        elif has_tool_results:
            # anthropic requires tools to be present even if there is any tool use
            request_args["tools"] = self._last_used_tools

        # Process tool_choice parameter
        if isinstance(tool_choice, Tool):
            if len(tools) == 0 and not has_tool_results:
                raise ValueError("tool_choice specified but no tools provided")

            # Validate that the tool exists in the provided tools
            tool_names_available: List[str] = []
            if len(tools) > 0:
                for tool in tools:
                    if isinstance(tool, Tool):
                        tool_names_available.append(tool.schema["name"])
                    else:
                        tool_names_available.append(tool["name"])
            else:
                # Use last used tools names if available
                for tool_param in self._last_used_tools:
                    tool_names_available.append(tool_param["name"])

            # tool_choice is a single Tool object
            tool_name = tool_choice.schema["name"]
            if tool_name not in tool_names_available:
                raise ValueError(f"tool_choice references '{tool_name}' but it's not in the available tools")

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Provide tools or remove tool_choice

Example fix

Pass tools=[...] alongside tool_choice

When it happens

Trigger: Thrown at python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py:639 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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