类 SubAgentConfig
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
InMemorySessionfor 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();
-
嵌套类概要
嵌套类 -
方法概要
修饰符和类型方法说明static SubAgentConfig.Builderbuilder()Creates a new builder.static SubAgentConfigdefaults()Creates a default configuration.Gets the description override.Gets the session for conversation state management.Gets the stream options for event forwarding.Gets the tool name override.booleanGets whether to forward sub-agent events to the parent agent.
-
方法详细资料
-
defaults
Creates a default configuration.Tool name and description are derived from the agent at registration time.
- 返回:
- Default configuration
-
builder
Creates a new builder.- 返回:
- New builder instance
-
getToolName
Gets the tool name override.- 返回:
- Tool name, or null to derive from agent
-
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
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
Gets the session for conversation state management.The session is used to persist and restore sub-agent state across conversation turns. By default, an
InMemorySessionis used.- 返回:
- The session instance (never null)
-