people-roofHierarchical

Agents are organized in a tree-like structure, with higher-level agents (supervisors) coordinating specialist agents.

Overview

Hierarchies shine when you need structured decision flows, explicit quality checks, and clear ownership of each step. Supervisors break work into pieces, delegate to the right specialists, and assemble the final answer.

Demo Scenario: Multi-Level Research System

This runnable example builds a hierarchical research workflow using sub-agent delegation:

  1. Coordinator agent – manages the research and compilation workflow

  2. Research agent – performs web searches using the google_serper tool

  3. Compiler agent – formats raw findings into a polished summary

The coordinator delegates tasks to research and compiler agents, reviews their outputs, and can make decisions based on their responses. This cyclic decision-making capability is why we use sub-agent delegation instead of gllm-pipeline.

Diagram

Implementation Steps

  1. Create specialist agents

  2. Create coordinator agent with sub-agents

  3. Run the coordinator

Full implementation: See hierarchical/main.py for complete code with detailed instructions.

Why sub-agents? This pattern uses sub-agent delegation (not gllm-pipeline) because the coordinator needs to make decisions based on sub-agent responses and potentially loop back if needed.

How to Run

From the gl-aip/examples/multi-agent-system-patterns directory in the GL SDK Cookbookarrow-up-right:

Ensure your .env contains:

Note: You'll need a Serper API keyarrow-up-right for the google_serper tool to work.

Output

Notes

  • This example uses sub-agent delegation (not gllm-pipeline) because the coordinator needs to make autonomous decisions based on sub-agent responses.

  • Add reviewers or domain specialists by including them in the coordinator's agents list.

  • The coordinator agent can implement feedback loops, quality checks, and conditional delegation based on sub-agent outputs.

  • For linear workflows without decision-making or loops, prefer patterns that use gllm-pipeline (Sequential, Parallel, Router, Aggregator) which leverage the AgentComponentarrow-up-right wrapper.

  • For iterative optimization with feedback loops, see the Loop patternarrow-up-right.

Last updated

Was this helpful?