{"record":{"id":"c407a91613fdd7f5","repo":"deepset-ai/haystack","slug":"combining-toolsets-and-tools-with-is-deprecate","errorCode":null,"errorMessage":"Combining Toolsets and Tools with '+' is deprecated and will be removed in Haystack 3.2.0. Pass them as a list wherever tools are accepted instead, e.g. Agent(tools=[toolset_a, toolset_b]).","messagePattern":"Combining Toolsets and Tools with '\\+' is deprecated and will be removed in Haystack 3\\.2\\.0\\. Pass them as a list wherever tools are accepted instead, e\\.g\\. Agent\\(tools=\\[toolset_a, toolset_b\\]\\)\\.","errorType":"console","errorClass":"FutureWarning","httpStatus":null,"severity":"warning","filePath":"haystack/tools/toolset.py","lineNumber":281,"sourceCode":"            if not issubclass(tool_class, Tool):\n                raise TypeError(f\"Class '{tool_class}' is not a subclass of Tool\")\n            tools.append(tool_class.from_dict(tool_data))\n\n        return cls(tools=tools)\n\n    def __add__(self, other: \"Tool | Toolset | list[Tool]\") -> \"Toolset\":\n        \"\"\"\n        Concatenate this Toolset with another Tool, Toolset, or list of Tools.\n\n        Deprecated: will be removed in Haystack 3.2.0. Pass tools and Toolsets as a list wherever tools\n        are accepted instead, e.g. `Agent(tools=[toolset_a, toolset_b])`.\n\n        :param other: Another Tool, Toolset, or list of Tools to concatenate\n        :returns: A new Toolset containing all tools\n        :raises TypeError: If the other parameter is not a Tool, Toolset, or list of Tools\n        :raises ValueError: If the combination would result in duplicate tool names\n        \"\"\"\n        warnings.warn(\n            \"Combining Toolsets and Tools with '+' is deprecated and will be removed in Haystack 3.2.0. \"\n            \"Pass them as a list wherever tools are accepted instead, e.g. Agent(tools=[toolset_a, toolset_b]).\",\n            FutureWarning,\n            stacklevel=2,\n        )\n        if isinstance(other, Tool):\n            return Toolset(tools=self.tools + [other])\n        if isinstance(other, Toolset):\n            return _ToolsetWrapper([self, other])\n        if isinstance(other, list) and all(isinstance(item, Tool) for item in other):\n            return Toolset(tools=self.tools + other)\n        raise TypeError(f\"Cannot add {type(other).__name__} to Toolset\")\n\n    def __len__(self) -> int:\n        \"\"\"\n        Return the number of Tools in this Toolset.\n\n        :returns: Number of Tools","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/tools/toolset.py#L263-L299","documentation":"Toolset.__add__ in haystack/tools/toolset.py unconditionally emits this FutureWarning because combining toolsets with the '+' operator is deprecated and will be removed in Haystack 3.2.0. Any use of toolset + tool, toolset + toolset, or toolset + list returns a _ToolsetWrapper but is now discouraged in favor of plain lists.","triggerScenarios":"Any expression using '+' with a Toolset on the left: toolset_a + tool_b, toolset_a + toolset_b, toolset_a + [tool1, tool2], or chained forms like toolset_a + toolset_b + tool_c. The warning fires before the type of other is even inspected.","commonSituations":"Legacy code building tool collections with + operators; migration guides or snippets written for Haystack 2.x; code that will break when the operator support is deleted in 3.2.0.","solutions":["Replace '+' expressions with a list of tools/toolsets passed where tools are accepted, e.g. Agent(tools=[toolset_a, toolset_b])","Mix tools and toolsets in one list: Agent(tools=[toolset_a, tool1, tool2])","If a single Toolset object is truly needed, construct it from a flat list of Tools instead of using +","Temporarily filter with warnings.filterwarnings('ignore', category=FutureWarning, module='haystack') until the 3.2.0 removal"],"exampleFix":"# before\ncombined = toolset_a + toolset_b\nagent = Agent(chat_generator=gen, tools=[combined])\n# after\nagent = Agent(chat_generator=gen, tools=[toolset_a, toolset_b])\n# or mixing tools:\nagent = Agent(chat_generator=gen, tools=[toolset_a, tool1, tool2])","handlingStrategy":"type-guard","validationCode":"from haystack.tools import Tool, Toolset, Toolset as TS\n\ndef normalize_tools(items) -> list:\n    \"\"\"Normalize tools/toolsets to a plain list, avoiding deprecated '+'.\"\"\"\n    if isinstance(items, Toolset):\n        return [items]\n    if isinstance(items, Tool):\n        return [items]\n    return list(items)","typeGuard":"from haystack.tools import Tool, Toolset\n\ndef can_use_plus(left, right) -> bool:\n    # '+' on Toolset always warns; refuse to use it\n    if isinstance(left, Toolset):\n        return False\n    return isinstance(left, (Tool, list))","tryCatchPattern":"import warnings\n\nwith warnings.catch_warnings(record=True) as caught:\n    warnings.simplefilter(\"always\", FutureWarning)\n    combined = toolset_a + toolset_b\n    if any(issubclass(w.category, FutureWarning) for w in caught):\n        warnings.warn(\"Replace '+' with a list: Agent(tools=[toolset_a, toolset_b])\", FutureWarning)","preventionTips":["Never use '+' to combine Toolsets; always build lists instead","Prefer plain list[Tool | Toolset] in your own APIs instead of combined Toolset objects","Run tests with -W error::FutureWarning to fail fast on deprecated operator use","Plan removal before Haystack 3.2.0 when the operator support is deleted"],"tags":["deprecation","toolset","operator-overloading","python"],"backgroundTag":"toolset-plus-operator-deprecated","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}