类 SubAgentConfig

java.lang.Object
io.agentscope.core.tool.subagent.SubAgentConfig

public class SubAgentConfig extends Object
Configuration for sub-agent registration.

This class provides configuration options for how a sub-agent is exposed as a tool. It supports smart defaults that derive tool name and description from the agent itself.

Sub-agents operate in conversation mode, supporting multi-turn dialogue with session management. The tool exposes two parameters:

  • message - Required. The message to send to the agent.
  • conversation_id - Optional. Omit to start a new conversation, provide to continue an existing one.

Default Behavior:

  • Tool name: derived from agent name (e.g., "ResearchAgent" → "call_researchagent")
  • Description: uses agent's description, or generates a default
  • Session: uses InMemorySession for conversation state management
  • Event forwarding: enabled by default

Example usage:


 // Minimal configuration - uses all defaults
 SubAgentConfig config = SubAgentConfig.defaults();

 // Custom configuration with persistent session
 SubAgentConfig config = SubAgentConfig.builder()
     .toolName("ask_expert")
     .description("Ask the expert a question")
     .session(new JsonSession(Path.of("sessions")))
     .build();
 
  • 方法详细资料

    • defaults

      public static SubAgentConfig defaults()
      Creates a default configuration.

      Tool name and description are derived from the agent at registration time.

      返回:
      Default configuration
    • builder

      public static SubAgentConfig.Builder builder()
      Creates a new builder.
      返回:
      New builder instance
    • getToolName

      public String getToolName()
      Gets the tool name override.
      返回:
      Tool name, or null to derive from agent
    • getDescription

      public String getDescription()
      Gets the description override.
      返回:
      Description, or null to derive from agent
    • isForwardEvents

      public boolean isForwardEvents()
      Gets whether to forward sub-agent events to the parent agent.

      When enabled, events from the sub-agent (reasoning chunks, tool execution chunks) are forwarded via ToolEmitter to the parent agent's hooks.

      返回:
      true if events should be forwarded (default: true)
    • getStreamOptions

      public StreamOptions getStreamOptions()
      Gets the stream options for event forwarding.

      Controls which event types to forward and streaming mode (incremental vs cumulative). Only applicable when isForwardEvents() returns true.

      返回:
      Stream options, or null to use defaults
    • getSession

      public Session getSession()
      Gets the session for conversation state management.

      The session is used to persist and restore sub-agent state across conversation turns. By default, an InMemorySession is used.

      返回:
      The session instance (never null)