Skip to content
Agent

Sub-Agents

by yologdev

AI Summary

Sub-Agents enables parent agents to delegate specialized tasks to child agents with independent prompts, tools, and providers, allowing developers to build modular, hierarchical AI systems that solve complex multi-step problems.

Install

Copy this and paste it into Claude Code, Cursor, or any AI assistant:

I want to set up the "Sub-Agents" agent in my project.

Please run this command in my terminal:
# Add AGENTS.md to your project root
curl --retry 3 --retry-delay 2 --retry-all-errors -o AGENTS.md "https://raw.githubusercontent.com/yologdev/yoagent/main/docs/concepts/sub-agents.md"

Then explain what the agent does and how to invoke it.

Description

Sub-agents let a parent agent delegate tasks to child agent loops, each with their own system prompt, tools, and provider. The parent LLM invokes them like any other tool.

Overview

` Parent Agent ├── prompt("Research X and implement Y") │ ├── calls SubAgentTool("researcher", task="Research X") │ │ └── child agent_loop() with read/search tools → returns findings │ ├── calls SubAgentTool("coder", task="Implement Y based on findings") │ │ └── child agent_loop() with edit/write tools → returns result │ └── summarizes both results ` Each sub-agent invocation starts a fresh conversation — no state leaks between calls.

Sub-Agents

Sub-agents let a parent agent delegate tasks to child agent loops, each with their own system prompt, tools, and provider. The parent LLM invokes them like any other tool.

Creating Sub-Agents

`rust use std::sync::Arc; use yoagent::sub_agent::SubAgentTool; use yoagent::provider::AnthropicProvider; use yoagent::tools; let researcher = SubAgentTool::new("researcher", Arc::new(AnthropicProvider)) .with_description("Searches and reads files to gather information.") .with_system_prompt("You are a research assistant. Be thorough and concise.") .with_model("claude-sonnet-4-20250514") .with_api_key(&api_key) .with_tools(vec![ Arc::new(tools::ReadFileTool::new()), Arc::new(tools::SearchTool::new()), ]) .with_max_turns(10); `

Registering on a Parent Agent

`rust use yoagent::agent::Agent; let mut agent = Agent::new(AnthropicProvider) .with_system_prompt("You coordinate between sub-agents.") .with_model("claude-sonnet-4-20250514") .with_api_key(api_key) .with_sub_agent(researcher) .with_sub_agent(coder); ` The parent sees sub-agents as regular tools. It decides when to delegate based on its system prompt.

Discussion

0/2000
Loading comments...

Health Signals

MaintenanceCommitted 15d ago
Active
Adoption100+ stars on GitHub
128 ★ · Growing
DocsREADME + description
Well-documented

GitHub Signals

Stars128
Forks16
Issues1
Updated15d ago
View on GitHub
MIT License

My Fox Den

Community Rating

Sign in to rate this booster

Works With

Claude Code
Claude.ai