Expand description
Sub-agent tool — delegates tasks to a child agent loop.
The SubAgentTool implements AgentTool and internally runs agent_loop()
with its own system prompt, tools, and provider. The parent LLM invokes it
like any other tool, passing a natural-language task string.
§Design
- Context isolation: each invocation starts a fresh conversation
- Depth limiting: sub-agents are not given other SubAgentTools (static, no runtime counter)
- Cancellation propagation: the parent’s cancel token is forwarded
- Event forwarding: sub-agent events stream to the parent via
on_update
§Example
use phi_core::agents::SubAgentTool;
use phi_core::provider::ModelConfig;
let researcher = SubAgentTool::new(
"researcher",
ModelConfig::anthropic("claude-sonnet-4-20250514", "Claude Sonnet 4", "sk-..."),
)
.with_description("Searches codebases and documents")
.with_system_prompt("You are a research assistant.");Structs§
- SubAgent
Tool - A tool that delegates work to a child agent loop.