{"record":{"id":"811dbc9073d44726","repo":"microsoft/autogen","slug":"unsupported-tool-type-type-tool","errorCode":null,"errorMessage":"Unsupported tool type: {type(tool)}","messagePattern":"Unsupported tool type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py","lineNumber":785,"sourceCode":"        if system_message is None:\n            self._system_messages = []\n        else:\n            self._system_messages = [SystemMessage(content=system_message)]\n        self._tools: List[BaseTool[Any, Any]] = []\n        if tools is not None:\n            if model_client.model_info[\"function_calling\"] is False:\n                raise ValueError(\"The model does not support function calling.\")\n            for tool in tools:\n                if isinstance(tool, BaseTool):\n                    self._tools.append(tool)\n                elif callable(tool):\n                    if hasattr(tool, \"__doc__\") and tool.__doc__ is not None:\n                        description = tool.__doc__\n                    else:\n                        description = \"\"\n                    self._tools.append(FunctionTool(tool, description=description))\n                else:\n                    raise ValueError(f\"Unsupported tool type: {type(tool)}\")\n        # Check if tool names are unique.\n        tool_names = [tool.name for tool in self._tools]\n        if len(tool_names) != len(set(tool_names)):\n            raise ValueError(f\"Tool names must be unique: {tool_names}\")\n\n        # Handoff tools.\n        self._handoff_tools: List[BaseTool[Any, Any]] = []\n        self._handoffs: Dict[str, HandoffBase] = {}\n        if handoffs is not None:\n            if model_client.model_info[\"function_calling\"] is False:\n                raise ValueError(\"The model does not support function calling, which is needed for handoffs.\")\n            for handoff in handoffs:\n                if isinstance(handoff, str):\n                    handoff = HandoffBase(target=handoff)\n                if isinstance(handoff, HandoffBase):\n                    self._handoff_tools.append(handoff.handoff_tool)\n                    self._handoffs[handoff.name] = handoff\n                else:","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py#L767-L803","documentation":"AssistantAgent iterates over the tools argument and accepts only autogen_core.tools.BaseTool instances or plain Python callables (wrapped into FunctionTool using their docstring as description). Any other object raises ValueError with its type.","triggerScenarios":"Passing a class (not an instance), a string tool name, a dict describing a tool, a Mock in tests, or an object from an incompatible autogen version whose BaseTool base class differs (isinstance fails across mismatched package copies).","commonSituations":"Copy-pasting tool definitions from other frameworks (Langchain tools, plain specs), duplicate autogen-core installs in the environment making isinstance checks fail, or forgetting to instantiate a tool class.","solutions":["Ensure each item is a BaseTool instance or a plain function/lambda (callable).","Instantiate tool classes: MyTool() not MyTool.","Check for conflicting autogen-core installations (`pip list | grep autogen`) — tools defined against a different installed copy fail isinstance."],"exampleFix":"# before\nagent = AssistantAgent(name=\"a\", model_client=client, tools=[MyTool])\n\n# after\nagent = AssistantAgent(name=\"a\", model_client=client, tools=[MyTool()])","handlingStrategy":"type-guard","validationCode":"from autogen_core.tools import BaseTool\nfor t in tools:\n    if not (isinstance(t, BaseTool) or callable(t)):\n        raise ValueError(f\"Unsupported tool entry: {t!r} ({type(t).__name__})\")","typeGuard":"from autogen_core.tools import BaseTool\n\ndef is_valid_tool(t) -> bool:\n    return isinstance(t, BaseTool) or callable(t)","tryCatchPattern":"try:\n    agent = AssistantAgent(name=\"a\", model_client=client, tools=tools)\nexcept ValueError as e:\n    if \"Unsupported tool type\" in str(e):\n        tools = [FunctionTool(t, name=t.__name__, description=t.__doc__ or \"\") if callable(t) else t for t in tools]\n    else:\n        raise","preventionTips":["Instantiate tool classes before adding them to the list.","Check for duplicate autogen-core installs when isinstance unexpectedly fails."],"tags":["python","tools","type-validation","autogen"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}