{"record":{"id":"77335074b8dfa846","repo":"microsoft/autogen","slug":"tools-cannot-be-used-with-a-workbench","errorCode":null,"errorMessage":"Tools cannot be used with a workbench.","messagePattern":"Tools cannot be used with a workbench\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py","lineNumber":829,"sourceCode":"        handoff_tool_names_set = set(handoff_tool_names)\n\n        # Check if there's any overlap between handoff tool names and tool names\n        overlap = tool_names_set.intersection(handoff_tool_names_set)\n\n        # Also check if any handoff target name matches a tool name\n        # This handles the case where a handoff is specified directly with a string that matches a tool name\n        for handoff in handoffs or []:\n            if isinstance(handoff, str) and handoff in tool_names_set:\n                raise ValueError(\"Handoff names must be unique from tool names\")\n            elif isinstance(handoff, HandoffBase) and handoff.target in tool_names_set:\n                raise ValueError(\"Handoff names must be unique from tool names\")\n\n        if overlap:\n            raise ValueError(\"Handoff names must be unique from tool names\")\n\n        if workbench is not None:\n            if self._tools:\n                raise ValueError(\"Tools cannot be used with a workbench.\")\n            if isinstance(workbench, Sequence):\n                self._workbench = workbench\n            else:\n                self._workbench = [workbench]\n        else:\n            self._workbench = [StaticStreamWorkbench(self._tools)]\n\n        if model_context is not None:\n            self._model_context = model_context\n        else:\n            self._model_context = UnboundedChatCompletionContext()\n\n        if self._output_content_type is not None and reflect_on_tool_use is None:\n            # If output_content_type is set, we need to reflect on tool use by default.\n            self._reflect_on_tool_use = True\n        elif reflect_on_tool_use is None:\n            self._reflect_on_tool_use = False\n        else:","sourceCodeStart":811,"sourceCodeEnd":847,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py#L811-L847","documentation":"AssistantAgent supports either explicit tools or a workbench, not both: when workbench is not None and any tools were registered, construction raises ValueError. Without a workbench the tools are implicitly wrapped in a StaticStreamWorkbench, so a workbench replaces the tool pathway entirely.","triggerScenarios":"AssistantAgent(tools=[my_tool], workbench=MyWorkbench()) or (tools=[...], workbench=[wb1, wb2]) — any non-empty tools list plus a workbench argument.","commonSituations":"Migrating code that passed tools and then adding a workbench for tool-use streaming support without removing the tools parameter; copy-pasting examples that mix both APIs.","solutions":["Remove the tools argument when supplying a workbench; register tools on the workbench instead (e.g. StaticStreamWorkbench(tools)).","Or drop the workbench and keep plain tools.","Check that defaults are not silently injecting tools (tools=None is fine; only non-empty lists conflict)."],"exampleFix":"# before\nagent = AssistantAgent(name=\"a\", model_client=client, tools=[my_tool], workbench=MyWorkbench())\n\n# after\nagent = AssistantAgent(name=\"a\", model_client=client, workbench=StaticStreamWorkbench([my_tool]))","handlingStrategy":"validation","validationCode":"if tools and workbench is not None:\n    raise ValueError(\"pass either tools= or workbench=, not both\")","typeGuard":null,"tryCatchPattern":"try:\n    agent = AssistantAgent(name=\"a\", model_client=client, tools=tools, workbench=workbench)\nexcept ValueError as e:\n    if \"cannot be used with a workbench\" in str(e):\n        agent = AssistantAgent(name=\"a\", model_client=client, workbench=workbench)  # tools live in the workbench\n    else:\n        raise","preventionTips":["Choose one tool-provisioning mechanism per agent and enforce it in a builder function.","When migrating to workbenches, delete the tools= argument in the same change."],"tags":["python","workbench","tools","mutually-exclusive","autogen"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}