fix: preserve subagent handoff tools during plugin filtering (#6155)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user