diff --git a/astrbot/core/star/context.py b/astrbot/core/star/context.py index 593bad9365..56007edf05 100644 --- a/astrbot/core/star/context.py +++ b/astrbot/core/star/context.py @@ -491,15 +491,23 @@ def add_llm_tools(self, *tools: FunctionTool) -> None: for tool in tools: if not module_path: _parts = [] - module_part = tool.__module__.split(".") + module_part = tool.__module__.split(".") if tool.__module__ else [] flags = ["builtin_stars", "plugins"] + found_flag = False for i, part in enumerate(module_part): _parts.append(part) if part in flags and i + 1 < len(module_part): _parts.append(module_part[i + 1]) _parts.append("main") + found_flag = True break - tool.handler_module_path = ".".join(_parts) + if not found_flag and module_part: + # Subdirectory tool: construct path matching star_manager format + # Only apply to known plugin naming patterns (astrbot_plugin_*) + plugin_name = module_part[0] + if plugin_name.startswith("astrbot_plugin_"): + _parts = ["data", "plugins", plugin_name, "main"] + tool.handler_module_path = ".".join(_parts) if _parts else tool.__module__ or "" module_path = tool.handler_module_path else: tool.handler_module_path = module_path