Module subagent

Module subagent 

Source
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:

  1. A new isolated thread is created
  2. The subagent runs until completion or max turns
  3. Only the final text response is returned to the parent
  4. The parent does not see the subagent’s intermediate tool calls

Structs§

SubagentConfig
Configuration for a subagent.
SubagentFactory
Factory for creating subagents with shared resources.
SubagentResult
Result from a subagent execution.
SubagentTool
Tool for spawning subagents.
ToolCallLog
Log entry for a single tool call within a subagent.