类 ToolGroup

java.lang.Object
io.agentscope.core.tool.ToolGroup

public class ToolGroup extends Object
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
 
  • 方法详细资料

    • getName

      public String getName()
      Gets the name of this tool group.
      返回:
      The group name (never null)
    • getDescription

      public String 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

      public Set<String> getTools()
      Gets a defensive copy of the tools in this group.
      返回:
      A new set containing the tool names
    • addTool

      public void addTool(String toolName)
      Adds a tool to this group.
      参数:
      toolName - The name of the tool to add
    • removeTool

      public void removeTool(String toolName)
      Removes a tool from this group.
      参数:
      toolName - The name of the tool to remove
    • containsTool

      public boolean containsTool(String toolName)
      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

      public static ToolGroup.Builder builder()
      Creates a new builder for constructing ToolGroup instances.
      返回:
      A new builder instance