fix: add missing add_tool and merge methods to base ToolSet

The internal ToolSet (base.py) was missing add_tool() and merge()
methods that the agent code expects. When tmgr.get_full_tool_set()
returned a base.py ToolSet, calls to add_tool() and merge() failed.

Added:
- add_tool() as alias to add()
- merge() method to merge another ToolSet

This fixes runtime crash: AttributeError: 'ToolSet' object has no attribute 'add_tool'
This commit is contained in:
LIghtJUNction
2026-03-24 18:28:19 +08:00
parent 9fe4a0e3d5
commit d60a3f0d1d

View File

@@ -100,6 +100,10 @@ class ToolSet:
"""Add a tool to the set."""
self._tools[tool.name] = tool
def add_tool(self, tool: FunctionTool) -> None:
"""Add a tool to the set (alias for add())."""
self.add(tool)
def remove(self, name: str) -> FunctionTool | None:
"""Remove and return a tool by name."""
return self._tools.pop(name, None)
@@ -126,6 +130,11 @@ class ToolSet:
def __len__(self) -> int:
return len(self._tools)
def merge(self, other: "ToolSet") -> None:
"""Merge another ToolSet into this one."""
for tool in other.tools:
self.add(tool)
@property
def tools(self) -> list[FunctionTool]:
"""List all tools in this set."""