Use Sub-Agent Delegation
Use this when one agent orchestrates other agents through built-in delegation tools.
What is auto-wired
By default, AgentOs::resolve(...) wires these tools and behaviors:
- tools:
agent_run,agent_stop,agent_output - behaviors:
agent_tools,agent_recovery
No manual plugin registration is required for baseline delegation.
Steps
- Define worker agents and orchestrator.
let os = AgentOs::builder()
.with_agent_spec(AgentDefinitionSpec::local_with_id("writer", AgentDefinition::new("deepseek-chat")
.with_excluded_tools(vec!["agent_run".to_string(), "agent_stop".to_string()]),))
.with_agent_spec(AgentDefinitionSpec::local_with_id("reviewer", AgentDefinition::new("deepseek-chat")
.with_excluded_tools(vec!["agent_run".to_string(), "agent_stop".to_string()]),))
.with_agent_spec(AgentDefinitionSpec::local_with_id("orchestrator", AgentDefinition::new("deepseek-chat")
.with_allowed_agents(vec!["writer".to_string(), "reviewer".to_string()]),))
.build()?;
- In orchestrator prompt/tool flow, call delegation tools.
- start or resume:
agent_run - stop background run tree:
agent_stop - fetch output snapshot:
agent_output
- Choose foreground/background execution per
agent_runcall.
background=false: parent waits and receives child progressbackground=true: child runs asynchronously and can be resumed/stopped later
Verify
- Orchestrator can call
agent_runfor allowed child agents. - Child run status transitions are visible (
running,completed,failed,stopped). agent_outputreturns child-thread outputs for the requestedrun_id.
Common Errors
- Target agent filtered by
allowed_agents/excluded_agents. - Worker agents accidentally retain delegation tools and recurse unexpectedly.
- Background runs left running without
agent_stop/resume policy.
Related Example
- No dedicated UI starter focuses on sub-agents yet; use
crates/tirea-agentos/tests/real_multi_subagent_deepseek.rsfor the main end-to-end example
Key Files
crates/tirea-agentos/src/runtime/agent_tools/manager.rscrates/tirea-agentos/src/runtime/agent_tools/tools/crates/tirea-agentos/tests/real_multi_subagent_deepseek.rs
Related
- Sub-Agent Delegation
- Capability Matrix
crates/tirea-agentos/tests/real_multi_subagent_deepseek.rs