fix: merge plugin tools into builtin toolsets

This commit is contained in:
Wysie 2026-04-22 02:24:24 +08:00 committed by Teknium
parent d9f0875591
commit 0120d8f31e
2 changed files with 23 additions and 3 deletions

View file

@ -32,6 +32,21 @@ class TestGetToolset:
assert ts is not None
assert "web_search" in ts["tools"]
def test_merges_registry_tools_into_builtin_toolset(self, monkeypatch):
reg = ToolRegistry()
reg.register(
name="web_search_plus",
toolset="web",
schema=_make_schema("web_search_plus", "Plugin web search"),
handler=_dummy_handler,
)
monkeypatch.setattr("tools.registry.registry", reg)
ts = get_toolset("web")
assert ts is not None
assert set(ts["tools"]) == {"web_search", "web_extract", "web_search_plus"}
def test_unknown_returns_none(self):
assert get_toolset("nonexistent") is None

View file

@ -521,13 +521,18 @@ def get_toolset(name: str) -> Optional[Dict[str, Any]]:
None: If toolset not found
"""
toolset = TOOLSETS.get(name)
if toolset:
return toolset
try:
from tools.registry import registry
except Exception:
return None
return toolset if toolset else None
if toolset:
merged_tools = sorted(
set(toolset.get("tools", []))
| set(registry.get_tool_names_for_toolset(name))
)
return {**toolset, "tools": merged_tools}
registry_toolset = name
description = f"Plugin toolset: {name}"