05. Design Patterns
Multi-Agent Collaboration and Hierarchical Patterns
Multi-agent collaboration patterns coordinate specialist agents that share a goal through handoffs, debate, or joint artifacts. Hierarchical patterns add levels of managers that assign subgoals downward and collect results upward. Both turn one overloaded agent into a team with clear roles and protocols.
What you will learn
- Define collaboration vs hierarchical multi-agent patterns
- Design roles, handoffs, and merge/vote rules
- Sketch a two-level manager β workers hierarchy
- Know when a single agent is enough
- Answer interview questions with short, solid answers
Definition
Multi-agent collaboration is a pattern where two or more agents with distinct roles (prompts, tools, memories) coordinate on one goal via messages, shared state, or artifact handoffs β sequential pipeline, parallel specialists, or debate/critique among peers.
Hierarchical multi-agent systems nest authority: a higher agent decomposes goals, assigns to mid-level or leaf agents, and integrates or escalates results. Orchestrator-Worker is the flat form; hierarchy adds depth when domains themselves need sub-teams.
Introduction
This lesson closes Module 05 (Design Patterns). It composes routing, parallelization, orchestrator-worker, and tool-use into team shapes.
Module 06 goes deeper on multi-agent systems, communication, and specialized roles. Next lesson there: What is a Multi-Agent System?
Why multi-agent patterns matter
- Isolate tools and permissions per role
- Specialize prompts without one mega-context
- Parallelize independent specialties safely
- Make ownership and escalation paths explicit
Collaboration pattern
Agree the protocol before coding: who speaks when, what artifact is handed off, how conflict is resolved.
- Roles - researcher, coder, reviewer, etc. with tool allowlists
- Shared goal - one measurable objective for the crew
- Protocol - pipeline, blackboard, or turn-taking debate
- Merge - synthesizer, vote, or designated approver
- Stop - max turns, cost budget, or approval gate
Hierarchical pattern
Keep managers thin on side-effect tools. They plan, assign, and integrate; leaves do heavy tool work.
- Manager - decomposes goal, tracks status, escalates
- Leads - own a subdomain; may spawn workers
- Workers - narrow tools and prompts; return structured results
- Report-up - schemas the parent can validate
- Escalate - unknown / policy / failure bubbles up
When to use which
- Single agent - short path, one skill set, low risk
- Collaboration - complementary peers (research + write + review)
- Flat orchestrator-worker - one planner, many leaf specialists
- Hierarchy - large domains that need mid-level ownership
- Avoid multi-agent when a chain or one tool-user would do
Communication and contracts
- Typed messages or shared artifacts beat free-form chat dumps
- Name the owner of each write to shared state
- Timeouts on waiting for peers; never deadlock silently
- Trace agent_id and message_id for debugging
Failure modes
- Chat storms - agents loop without a stop protocol
- Role blur - everyone has every tool; isolation lost
- Hierarchy theater - extra managers with no real authority/schema
- Merge fights - no judge/vote; conflicting outputs ship
- Cost blowups - N agents Γ long contexts; budget the crew
Program / implementation notes
Model crews as a graph: nodes = agents with allowlists; edges = allowed handoffs. Drive turn limits from the graph runner, not from hope.
- Reuse Orchestrator-Worker for flat teams; add levels only when needed
- Compose: hierarchical leads can run evaluator-optimizer inside a leaf
- Deep dive next: Module 06 Multi-Agent Systems
- Next: What is a Multi-Agent System?
Advantages and limitations
- Advantage: clearer specialization and safer tool scopes
- Advantage: parallel progress across roles
- Advantage: human-like org charts for complex products
- Limitation: more latency, tokens, and ops complexity
- Limitation: bad protocols create worse results than one agent
- Limitation: debugging cross-agent failures is harder
Key points
- Collaboration = peer specialists coordinating on one goal.
- Hierarchy = managers assign down and integrate reports up.
- Protocols and schemas matter more than βmore agents.β
- Keep managers thin on tools; put privileges on workers.
- Stop rules: max turns, budgets, and merge/vote rules.
- Prefer one agent or a chain when the job is small.
FAQs
Is multi-agent always better than one agent?
No. Extra agents add cost and failure modes. Use them when roles, permissions, or parallel specialties clearly help.
How is hierarchy different from Orchestrator-Worker?
Orchestrator-Worker is usually one planner plus leaf workers. Hierarchy adds mid-level managers that own subdomains and may run their own workers.
Do agents need separate processes?
Not required. Roles can be separate prompts/tool sets in one runtime. Separate processes help isolation and scale.
How do you resolve agent disagreements?
Predefine a judge, majority vote, rubric score, or human approval β do not leave endless debate open.
Interview questions
- What is multi-agent collaboration?
Answer Multiple role-specialized agents coordinate on one goal via handoffs, shared state, or debate under an explicit protocol.
- What is a hierarchical multi-agent pattern?
Answer Managers decompose and assign subgoals to lower agents; results and escalations flow back up the tree.
- When would you choose hierarchy over flat collaboration?
Answer When the problem has nested domains that need mid-level ownership, status tracking, and escalation paths.
- Name a collaboration failure mode.
Answer Unbounded chat loops without stop/merge rules β fix with turn caps, schemas, and a designated approver.
- How do tool allowlists relate to multi-agent design?
Answer Each role gets only the tools it needs; that isolation is a main reason to split agents.
- Give a compact example.
Answer Manager assigns research and delivery leads; researchers collaborate on sources; a reviewer agent must approve before release.
Related topics
Practice task
Complete each numbered practice step in a notebook or doc before opening the next lesson.
- Design a 3-agent collaboration (research, write, review) for a blog pipeline; list each agentβs tools.
- Write the handoff schema from writer β reviewer (fields the reviewer must see).
- Sketch a 2-level hierarchy for a βsupport + refundsβ product (manager, 2 leads, 4 workers).
- Define stop rules: max crew turns and how disagreements are resolved.
- Answer interview questions 1, 2, and 4 in two sentences each.