{"record":{"id":"3957ffde44288eb0","repo":"deepset-ai/haystack","slug":"the-following-tool-names-are-not-valid-invalid-t","errorCode":null,"errorMessage":"The following tool names are not valid: {invalid_tool_names}. Valid tool names are: {valid_tool_names}.","messagePattern":"The following tool names are not valid: (.+?)\\. Valid tool names are: (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/components/agents/utils.py","lineNumber":146,"sourceCode":"    requested_names = set(names)\n    items: list[Tool | Toolset] = (\n        [configured_tools] if isinstance(configured_tools, Toolset) else list(configured_tools)\n    )\n\n    # Resolve the tools each item offers for selection\n    selectable_per_item: list[tuple[Tool | Toolset, list[Tool]]] = []\n    for item in items:\n        selectable = item.get_selectable_tools() if isinstance(item, Toolset) else [item]\n        selectable_per_item.append((item, selectable))\n\n    valid_tool_names = {tool.name for _, selectable in selectable_per_item for tool in selectable}\n    # A dynamic Toolset may look empty before its catalog is resolved, so emptiness is checked here.\n    if not valid_tool_names:\n        raise ValueError(\"No tools were configured for the Agent at initialization.\")\n\n    invalid_tool_names = requested_names - valid_tool_names\n    if invalid_tool_names:\n        raise ValueError(\n            f\"The following tool names are not valid: {invalid_tool_names}. Valid tool names are: {valid_tool_names}.\"\n        )\n\n    selected: list[Tool | Toolset] = []\n    for item, selectable in selectable_per_item:\n        matched = requested_names & {tool.name for tool in selectable}\n        if not matched:\n            continue\n        run_copy = _spawn_selection_copy(item, matched)\n        if run_copy is not None:\n            selected.append(run_copy)\n        else:\n            # Select from `selectable`, the list the names were validated against: iterating a dynamic\n            # Toolset could silently miss tools.\n            selected.extend(tool for tool in selectable if tool.name in matched)\n    return selected\n\n","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/agents/utils.py#L128-L164","documentation":"Raised when names requested for tool selection are not among the names of selectable tools exposed by the Agent's configured Tool/Toolset items. The set difference `requested_names - valid_tool_names` is non-empty, so the library aborts rather than silently selecting a subset.","triggerScenarios":"Passing a `tool_names` list to Agent/_select_tools containing a typo, a tool belonging to a Toolset that was not configured, or a name from a dynamic Toolset catalog that failed to resolve.","commonSituations":"Typos in tool names; renaming a tool and forgetting to update the Agent config; referencing tools from a different Toolset than the one wired into the Agent; stale serialized pipeline YAML with old names.","solutions":["Fix the requested names to match the actual tool names exposed by the configured tools/toolsets.","Print or log the valid names: the error message includes the set of valid tool names — align to those.","Ensure the Toolset that owns the referenced tools is included in the Agent's `tools` list."],"exampleFix":"// before\nagent = Agent(gen, tools=[toolset], tool_names=[\"web_search\"])\n// after\nagent = Agent(gen, tools=[toolset], tool_names=[\"search_internet\"])  # matches toolset tool","handlingStrategy":"validation","validationCode":"def validate_tool_names(tools, requested):\n    valid = set()\n    for item in tools:\n        selectable = item.get_selectable_tools() if hasattr(item, \"get_selectable_tools\") else [item]\n        valid |= {t.name for t in selectable}\n    unknown = set(requested) - valid\n    if unknown:\n        raise AssertionError(f\"Unknown tool names {unknown}; valid: {valid}\")","typeGuard":null,"tryCatchPattern":"try:\n    agent = Agent(gen, tools=tools, tool_names=names)\nexcept ValueError as e:\n    if \"not valid\" in str(e):\n        logging.error(\"Tool name typo: %s\", e)\n    raise","preventionTips":["Derive requested names programmatically from tool objects instead of hardcoding strings.","Re-check names after renaming any tool.","Keep tool name constants in one module shared by tool definitions and Agent config."],"tags":["haystack","agents","tool-names","validation"],"backgroundTag":"invalid-tool-name","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}