{"record":{"id":"e086918da8c6e575","repo":"oraios/serena","slug":"tool-named-tool-name-not-found","errorCode":null,"errorMessage":"Tool named '{tool_name}' not found.","messagePattern":"Tool named '(.+?)' not found\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/serena/tools/tools_base.py","lineNumber":623,"sourceCode":"\n    def get_registered_tools_by_module(self) -> dict[str, list[RegisteredTool]]:\n        \"\"\"\n        :return: the registered tools grouped by their module (ordered alphabetically by module and tool name)\n        \"\"\"\n        module_dict: dict[str, list[RegisteredTool]] = {}\n        for tool in self._tool_dict.values():\n            module = tool.tool_class.__module__\n            if module not in module_dict:\n                module_dict[module] = []\n            module_dict[module].append(tool)\n        sorted_module_dict = {}\n        for module in sorted(module_dict.keys()):\n            sorted_module_dict[module] = sorted(module_dict[module], key=lambda t: t.tool_name)\n        return sorted_module_dict\n\n    def get_tool_class_by_name(self, tool_name: str) -> type[Tool]:\n        if tool_name not in self._tool_dict:\n            raise ValueError(f\"Tool named '{tool_name}' not found.\")\n        return self._tool_dict[tool_name].tool_class\n\n    def get_all_tool_classes(self) -> list[type[Tool]]:\n        return list(t.tool_class for t in self._tool_dict.values())\n\n    def get_tool_classes_default_enabled(self) -> list[type[Tool]]:\n        \"\"\"\n        :return: the list of tool classes that are enabled by default (i.e. non-optional tools).\n        \"\"\"\n        return [t.tool_class for t in self._tool_dict.values() if not t.is_optional]\n\n    def get_tool_classes_optional(self) -> list[type[Tool]]:\n        \"\"\"\n        :return: the list of tool classes that are optional (i.e. disabled by default).\n        \"\"\"\n        return [t.tool_class for t in self._tool_dict.values() if t.is_optional]\n\n    def get_tool_names_default_enabled(self) -> list[str]:","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/tools/tools_base.py#L605-L641","documentation":"ToolRegistry.get_tool_class_by_name looks up a registered tool class by its tool_name; if the name is absent from the registry's internal tool dictionary it raises ValueError. This guards callers (e.g. get_tool_by_name) against requesting tools that were never registered or were disabled/deleted.","triggerScenarios":"Calling get_tool_class_by_name or get_tool_by_name with a tool name string that is not a key in the registry's _tool_dict — e.g. a misspelled tool name, a tool from a module not registered, or a name referencing a tool removed/disabled in the active configuration.","commonSituations":"Agents or configs referencing tools by hardcoded names after a Serena version renamed tools; requesting tool classes for tools excluded by context (e.g. without_editing_tools variants); typos in tool names in YAML/config files.","solutions":["Check available names with registry.get_all_tool_names() (or list of registered tools) and correct the spelling","Verify the tool's module is actually registered with the registry instance being used","If the tool was intentionally removed, update the calling code/config to a replacement tool name","Wrap the lookup in try/except ValueError and fall back to a default tool"],"exampleFix":"// before\ntool_cls = registry.get_tool_class_by_name('read_fiel')\n// after\nnames = registry.get_all_tool_names()\nassert 'read_file' in names, names\ntool_cls = registry.get_tool_class_by_name('read_file')","handlingStrategy":"try-catch","validationCode":"if tool_name in registry.get_all_tool_names():\n    tool_cls = registry.get_tool_class_by_name(tool_name)\nelse:\n    log.warning(f\"{tool_name} not registered\")","typeGuard":"def is_registered_tool(registry, name: str) -> bool:\n    return name in registry.get_all_tool_names()","tryCatchPattern":"try:\n    tool_cls = registry.get_tool_class_by_name(tool_name)\nexcept ValueError:\n    tool_cls = None  # or fall back to a default tool","preventionTips":["List available tool names before lookups and keep configs in sync","Avoid hardcoding tool names in code; use constants validated at startup","After Serena upgrades, diff tool names used in configs against the registry"],"tags":["python","tool-registry","valueerror"],"backgroundTag":"unknown-identifier","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}