fix: preserve subagent handoff tools during plugin filtering (#6155)

This commit is contained in:
Frank
2026-03-14 05:55:15 -07:00
committed by GitHub
parent dd6bc1dcdb
commit 06fd2d2428
2 changed files with 27 additions and 0 deletions
+5
View File
@@ -778,9 +778,14 @@ def _plugin_tool_fix(event: AstrMessageEvent, req: ProviderRequest) -> None:
continue
mp = tool.handler_module_path
if not mp:
# 没有 plugin 归属信息的工具(如 subagent transfer_to_*
# 不应受到会话插件过滤影响。
new_tool_set.add_tool(tool)
continue
plugin = star_map.get(mp)
if not plugin:
# 无法解析插件归属时,保守保留工具,避免误过滤。
new_tool_set.add_tool(tool)
continue
if plugin.name in event.plugins_name or plugin.reserved:
new_tool_set.add_tool(tool)
+22
View File
@@ -804,6 +804,28 @@ class TestPluginToolFix:
assert "mcp_tool" in req.func_tool.names()
def test_plugin_tool_fix_preserves_tools_without_plugin_origin(self, mock_event):
"""Tools without handler_module_path should not be filtered out."""
module = ama
handoff_tool = FunctionTool(
name="transfer_to_demo_agent",
description="Delegate to demo agent",
parameters={"type": "object", "properties": {}},
handler_module_path=None,
active=True,
)
tool_set = ToolSet()
tool_set.add_tool(handoff_tool)
req = ProviderRequest(func_tool=tool_set)
mock_event.plugins_name = ["other_plugin"]
with patch("astrbot.core.astr_main_agent.star_map"):
module._plugin_tool_fix(mock_event, req)
assert "transfer_to_demo_agent" in req.func_tool.names()
class TestBuildMainAgent:
"""Tests for build_main_agent function."""