类 SubAgentTool

java.lang.Object
io.agentscope.core.tool.subagent.SubAgentTool
所有已实现的接口:
AgentTool

public class SubAgentTool extends Object implements AgentTool
AgentTool implementation that wraps a sub-agent for multi-turn conversation.

This tool allows an agent to be called as a tool by other agents, supporting multi-turn conversation with session management. Each session maintains its own agent instance and state.

Thread safety is ensured by using SubAgentProvider to create a fresh agent instance for each new session.

The tool exposes two parameters:

  • session_id - Optional. Omit to start a new session, provide to continue an existing one.
  • message - Required. The message to send to the agent.
  • 构造器详细资料

    • SubAgentTool

      public SubAgentTool(SubAgentProvider<?> agentProvider, SubAgentConfig config)
      Creates a new SubAgentTool.
      参数:
      agentProvider - Provider for creating agent instances
      config - Configuration for the tool
  • 方法详细资料

    • getName

      public String getName()
      从接口复制的说明: AgentTool
      Gets the name of the tool.

      The name should be unique within a toolkit and follow snake_case convention for compatibility with various LLM providers.

      指定者:
      getName 在接口中 AgentTool
      返回:
      The tool name (never null)
    • getDescription

      public String getDescription()
      从接口复制的说明: AgentTool
      Gets the description of the tool.

      The description should clearly explain what the tool does, when it should be used, and what kind of results it returns. This helps the LLM decide when to invoke the tool.

      指定者:
      getDescription 在接口中 AgentTool
      返回:
      The tool description (never null)
    • getParameters

      public Map<String,Object> getParameters()
      从接口复制的说明: AgentTool
      Gets the parameters schema for this tool in JSON Schema format.

      The schema defines the structure of the input parameters that this tool accepts. It should include:

      • type: "object"
      • properties: Map of parameter names to their schemas
      • required: List of required parameter names
      指定者:
      getParameters 在接口中 AgentTool
      返回:
      Map representing the JSON Schema for tool parameters (never null)
    • callAsync

      public reactor.core.publisher.Mono<ToolResultBlock> callAsync(ToolCallParam param)
      从接口复制的说明: AgentTool
      Execute the tool with the given parameters (asynchronous).

      This method accepts a ToolCallParam object containing all necessary context for tool execution, including:

      • toolUseBlock: Contains tool call ID and name for tracking
      • input: Input parameters for the tool
      • agent: The calling agent (may be null), provides access to agent context
      指定者:
      callAsync 在接口中 AgentTool
      参数:
      param - The tool call parameters
      返回:
      Mono containing ToolResultBlock