类 ToolGroup
java.lang.Object
io.agentscope.core.tool.ToolGroup
Represents a named group of tools with activation state.
Tool groups allow organizing tools into logical categories and controlling their availability dynamically. Only tools from active groups are made available to agents.
Usage Example:
ToolGroup adminGroup = ToolGroup.builder()
.name("admin")
.description("Administrative tools")
.active(false) // Start inactive
.build();
adminGroup.addTool("delete_user");
adminGroup.addTool("modify_permissions");
adminGroup.setActive(true); // Activate when needed
-
嵌套类概要
嵌套类 -
方法概要
修饰符和类型方法说明voidAdds a tool to this group.static ToolGroup.Builderbuilder()Creates a new builder for constructing ToolGroup instances.booleancontainsTool(String toolName) Checks if this group contains a specific tool.Gets the description of this tool group.getName()Gets the name of this tool group.getTools()Gets a defensive copy of the tools in this group.booleanisActive()Checks if this tool group is currently active.voidremoveTool(String toolName) Removes a tool from this group.voidsetActive(boolean active) Sets the activation state of this tool group.
-
方法详细资料
-
getName
Gets the name of this tool group.- 返回:
- The group name (never null)
-
getDescription
Gets the description of this tool group.- 返回:
- The group description (empty string if not set)
-
isActive
public boolean isActive()Checks if this tool group is currently active.- 返回:
- true if active, false otherwise
-
setActive
public void setActive(boolean active) Sets the activation state of this tool group.- 参数:
active- true to activate, false to deactivate
-
getTools
Gets a defensive copy of the tools in this group.- 返回:
- A new set containing the tool names
-
addTool
Adds a tool to this group.- 参数:
toolName- The name of the tool to add
-
removeTool
Removes a tool from this group.- 参数:
toolName- The name of the tool to remove
-
containsTool
Checks if this group contains a specific tool.- 参数:
toolName- The tool name to check- 返回:
- true if the tool is in this group, false otherwise
-
builder
Creates a new builder for constructing ToolGroup instances.- 返回:
- A new builder instance
-