microsoft/autogen · error · ValueError

Model does not support function calling

Error message

Model does not support function calling

What it means

Thrown by OpenAIChatCompletionClient when tools are passed to create/create_stream but the client's model_info declares function_calling as False. The check runs after message conversion but before tools are converted, failing client-side. It prevents sending tool schemas to models that cannot invoke functions.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py:629

        if create_args.get("model", "unknown").startswith("claude-"):
            # When Claude models last message is AssistantMessage, It could not end with whitespace
            messages = self._rstrip_last_assistant_message(messages)

        oai_messages_nested = [
            to_oai_type(
                m,
                prepend_name=self._add_name_prefixes,
                model=create_args.get("model", "unknown"),
                model_family=self._model_info["family"],
                include_name_in_message=self._include_name_in_message,
            )
            for m in messages
        ]

        oai_messages = [item for sublist in oai_messages_nested for item in sublist]

        if self.model_info["function_calling"] is False and len(tools) > 0:
            raise ValueError("Model does not support function calling")

        converted_tools = convert_tools(tools)

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

            # Validate that the tool exists in the provided tools
            tool_names_available: List[str] = []
            for tool in tools:
                if isinstance(tool, Tool):
                    tool_names_available.append(tool.schema["name"])
                else:
                    tool_names_available.append(tool["name"])

            # tool_choice is a single Tool object
            tool_name = tool_choice.schema["name"]

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Use a function-calling-capable model (e.g. gpt-4o) whose model_info has function_calling=True
  2. If the backend does support tools, correct the model_info dict passed to the constructor to set 'function_calling': True
  3. Remove tools from the call and rely on prompt-based tool selection if the model cannot call functions

Example fix

# before
client = OpenAIChatCompletionClient(model="my-model", model_info={"vision": False, "function_calling": False, "json_output": False, "family": "unknown"})
await client.create([msg], tools=[get_weather_tool])

# after
client = OpenAIChatCompletionClient(model="my-model", model_info={"vision": False, "function_calling": True, "json_output": False, "family": "unknown"})
await client.create([msg], tools=[get_weather_tool])
Defensive patterns

Strategy: validation

Validate before calling

if tools and not client.info.get("function_calling", False):
    tools = []  # or raise / switch model
    tool_choice = "none"

Type guard

def supports_tools(client, tools) -> bool:
    return len(tools) == 0 or bool(client.info.get("function_calling", False))

Try / catch

try:
    result = await client.create(messages, tools=tools)
except ValueError as e:
    if "function calling" in str(e):
        result = await client.create(messages)  # toolless fallback
    else:
        raise

Prevention

When it happens

Trigger: Calling create with a non-empty tools=[...] (Tool or ToolSchema objects) while model_info['function_calling'] is False, e.g. a legacy or custom model without tool support. This also fires for agents like ToolAvailChatAgent or function-calling workflows that always register tools.

Common situations: Running a tool-using agent (e.g. AssistantAgent with tools/workbench) against a model with an incomplete custom model_info; using small open-weights models that lack function calling; model_info dicts written before function_calling became a standard key.

Related errors


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