Expand description
Subagent support for spawning child agents.
This module provides the ability to spawn subagents from within an agent. Subagents are isolated agent instances that run to completion and return only their final response to the parent agent.
§Overview
Subagents are useful for:
- Delegating complex subtasks to specialized agents
- Running parallel investigations
- Isolating context for specific operations
§Example
ⓘ
use agent_sdk::subagent::{SubagentTool, SubagentConfig};
let config = SubagentConfig::new("researcher")
.with_system_prompt("You are a research specialist...")
.with_max_turns(10);
let tool = SubagentTool::new(config, provider, tools);
registry.register(tool);§Behavior
When a subagent runs:
- A new isolated thread is created
- The subagent runs until completion or max turns
- Only the final text response is returned to the parent
- The parent does not see the subagent’s intermediate tool calls
Structs§
- Subagent
Config - Configuration for a subagent.
- Subagent
Factory - Factory for creating subagents with shared resources.
- Subagent
Result - Result from a subagent execution.
- Subagent
Tool - Tool for spawning subagents.
- Tool
Call Log - Log entry for a single tool call within a subagent.