类 ToolGroup

java.lang.Object
io.agentscope.core.tool.ToolGroup
直接已知子类:
SkillToolGroup

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
 
  • 构造器详细资料

    • ToolGroup

      protected ToolGroup(String name, String description, boolean active, ToolGroupScope scope, Set<String> tools)
      Protected constructor for subclass use.
      参数:
      name - The group name (required)
      description - The group description
      active - Initial activation state
      scope - The group scope
      tools - Initial set of tool names
  • 方法详细资料

    • 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
    • getScope

      public ToolGroupScope getScope()
      Gets the scope of this tool group.
      返回:
      The group scope (ToolGroupScope.META or ToolGroupScope.EXTERNAL)
    • 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
    • copy

      public ToolGroup copy()
      Creates a deep copy of this tool group, preserving the concrete type for subclasses.
      返回:
      A new ToolGroup (or subclass) instance with the same state
    • builder

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