How to build a Multi-Agent System in Google ADK? Explain parent-child hierarchy and delegation with code examples.
#google-adk#multi-agent#orchestration#delegation#hierarchy
Answer
Multi-Agent Systems in Google ADK

Google ADK supports building multi-agent systems where multiple specialized agents collaborate under a parent orchestrator. The parent agent uses LLM reasoning to decide which child agent to delegate to.
Multi-Agent Architecture
Key Rules
| Rule | Description |
|---|---|
| Single Parent | An agent instance can only have one parent |
| Tree Structure | Agents form a tree, not a graph |
| Description Matters | Parent uses text |
| Shared State | All agents in a tree share session state |
| Navigation | text text |
Building a Multi-Agent System
pythonfrom google.adk.agents import Agent # Specialist agents researcher = Agent( name="researcher", model="gemini-2.5-flash", description="Researches topics using web search and academic papers", instruction="You are a research specialist. Search for information and summarize findings.", tools=[google_search], ) coder = Agent( name="coder", model="gemini-2.5-flash", description="Writes, debugs, and explains Python code", instruction="You are an expert Python programmer. Write clean, well-documented code.", tools=[code_execution], ) writer = Agent( name="writer", model="gemini-2.5-flash", description="Writes clear, engaging technical content and documentation", instruction="You are a technical writer. Create well-structured content.", ) # Orchestrator - delegates to specialists orchestrator = Agent( name="orchestrator", model="gemini-2.5-pro", instruction="""You are a project manager. Analyze the user's request and delegate to the appropriate specialist: - researcher: for information gathering and research - coder: for programming and code tasks - writer: for content creation and documentation Combine results from multiple agents when needed.""", sub_agents=[researcher, coder, writer], )
Combining Workflow + LLM Agents
pythonfrom google.adk.agents import Agent, SequentialAgent, ParallelAgent # Step 1: Gather data in parallel data_gatherer = ParallelAgent( name="data_gatherer", sub_agents=[ research_agent, # search the web database_agent, # query internal DB ] ) # Step 2: Analyze (LLM-powered) analyst = Agent( name="analyst", model="gemini-2.5-pro", instruction="Analyze the gathered data and extract key insights.", output_key="analysis", ) # Step 3: Write report (LLM-powered) report_writer = Agent( name="report_writer", model="gemini-2.5-flash", instruction="Write a report based on the analysis: {analysis}", output_key="report", ) # Full pipeline pipeline = SequentialAgent( name="research_pipeline", sub_agents=[data_gatherer, analyst, report_writer], )
State Sharing Between Agents
python# Agent A saves to state agent_a = Agent( name="agent_a", model="gemini-2.5-flash", instruction="Research the topic and save your findings.", output_key="findings", # saves output to state["findings"] ) # Agent B reads from state agent_b = Agent( name="agent_b", model="gemini-2.5-flash", instruction="Write a summary based on: {findings}", output_key="summary", ) pipeline = SequentialAgent( name="pipeline", sub_agents=[agent_a, agent_b], # agent_b reads agent_a's output )
Learn more at Multi-Agent Systems and Workflow Agents.