Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 28

Multi-Agent System Patterns

Recommended resources

Hello! In our last lesson, we established why it's often better to use a team of specialized agents rather than a single, monolithic one. We saw that for complex tasks, a multi-agent approach improves modularity, specialization, and control, much like a microservices architecture in software engineering.

Today, we'll explore the common architectural patterns used to organize these agent teams. Think of these as the "design patterns" of agentic systems—reusable solutions to common orchestration problems. Understanding these patterns will give you a vocabulary for designing and discussing complex agent workflows.

By the end of this lesson, you will be able to describe common multi-agent patterns, including hierarchical, coordinator, and collaborative broadcast (or swarm) patterns, and understand the trade-offs of each.

1. The Building Blocks: Orchestration and Communication

Before diving into specific patterns, it's helpful to understand two fundamental aspects that define them:

  1. Orchestration: How is the workflow controlled? Is it a fixed, predefined sequence, or does an LLM-powered agent dynamically decide what happens next? We can categorize patterns as either deterministic (like a script) or agentic (dynamic and adaptive).
  2. Communication: How do agents share information? As we'll see, this is often handled through a shared "state" object that all agents can read from and write to, or by one agent "calling" another as if it were a tool and passing parameters.

Let's watch a brief segment that explains these communication methods.

Conceptual Guide: Multi Agent Architectures

This clip from the LangChain 'Conceptual Guide: Multi Agent Architectures' video explains the core ways agents communicate.

Watch from 05:02 to 06:17. Focus on the distinction between agents communicating via a 'shared state object' versus communicating 'solely through tool calling'.

This distinction is key. Communication via a shared state allows for richer, more flexible collaboration, while tool-calling creates a more rigid, function-like interaction. Most patterns we discuss can be implemented using either method, but the choice has implications for flexibility and control.


2. Deterministic Patterns: The Assembly Line

Deterministic patterns are best for structured, repeatable processes where the sequence of operations is known in advance. They are analogous to a traditional ETL pipeline or an assembly line—predictable, efficient, and easier to debug. Because the flow is hardcoded, they don't rely on an LLM for orchestration, which can reduce latency and cost.

The Google Cloud document "Choose a design pattern for your agentic AI system" provides excellent descriptions of these patterns.

Choose a design pattern for your agentic AI system

This guide provides clear, structured definitions for several key patterns. We'll start with the most fundamental ones.

Read the sections titled 'Sequential pattern', 'Parallel pattern', and 'Review and critique pattern'. As you read, notice how these patterns prioritize structure and reliability over dynamic flexibility.

Let's summarize these core deterministic patterns:

  • Sequential Pattern: Agents execute one after another in a linear chain. The output of Agent A becomes the input for Agent B. This is perfect for data processing pipelines, like parsing a document, then extracting entities, and finally summarizing the content.

  • Parallel Pattern (Fan-Out/Gather): Multiple agents work simultaneously on independent sub-tasks. Their outputs are then aggregated. This is great for reducing latency. For example, you could have three agents simultaneously analyze a product review for sentiment, topics, and urgency, with a final agent synthesizing their findings.

  • Loop-based Patterns (e.g., Review and Critique): A sequence of agents runs repeatedly until a condition is met. The Review and Critique (or Generator-Critic) pattern is a powerful example.

    • A Generator agent creates content (e.g., a SQL query).
    • A Critic agent evaluates it against specific criteria (e.g., "Is this valid SQL?").
    • If it fails, the feedback is sent back to the Generator for another attempt. This loop ensures a certain level of quality or correctness.

3. Agentic Patterns: The Management Team

These patterns use an LLM-powered agent to dynamically orchestrate the workflow, making decisions at runtime about which agent or tool to use next. This provides far more flexibility to handle varied inputs and unexpected situations.

The Coordinator / Supervisor Pattern

This is arguably the most common and useful agentic pattern. A central "supervisor" or "coordinator" agent acts like a project manager, analyzing a request and routing it to the appropriate specialist agent.

This architecture is elegantly explained in another Google resource.

Developer's guide to multi-agent patterns in ADK

The blog post 'Developer's guide to multi-agent patterns in ADK' uses excellent analogies that connect with software engineering concepts.

Read sections 2, 'Coordinator/Dispatcher Pattern (aka the concierge)', and 4, 'Hierarchical decomposition (aka the russian doll)'. Note how the coordinator makes decisions and how the hierarchical pattern is a natural extension of this.

Let's break down these hierarchical concepts:

  • Coordinator (or Supervisor): A single manager agent delegates tasks. It doesn't do the work itself; it directs traffic. For example, a customer service coordinator might receive a query, determine if it's a billing or technical issue, and route it to the BillingSpecialist or TechSupportSpecialist agent.
Hierarchical Multi-Agent System for Appointment Booking
This diagram shows a classic Supervisor pattern. The `Supervisor Agent` acts as a coordinator, receiving a user request and delegating it to the appropriate specialized agent (`Availability`, `Booking`, or `FAQs`) to handle the sub-task.
  • Hierarchical Pattern: This is simply a multi-level coordinator pattern—a manager of managers. A top-level agent breaks a very complex goal (e.g., "write a research report on AI trends") into large sub-tasks (gather data, analyze findings, draft report). It delegates each sub-task to a mid-level coordinator, which might further decompose the task and delegate to worker agents that use specific tools (like a WebSearchAgent).

4. Collaborative Patterns: The Brainstorm Session

While hierarchical patterns impose top-down control, some problems benefit from a more flexible, bottom-up collaboration where agents can communicate freely.

The Swarm / Collaborative Broadcast Pattern

In this pattern, agents can communicate with any other agent in the group, resembling a brainstorming session or a group chat. A dispatcher might kick off the process, but there is no central manager dictating the workflow. Agents can debate, share findings, and hand off tasks to whomever is best suited for the next step.

Multi-agent systems, concepts & patterns | The Agent Factory Podcast

This segment from 'The Agent Factory Podcast' offers a great discussion on the trade-offs of the swarm pattern.

Watch from 15:15 to 17:26. Pay close attention to the contrast between 'control' (supervisor) and 'collaboration' (swarm) and the potential pros and cons of each.

Key Trade-offs of Swarm Patterns:

  • Pro: Highly flexible and resilient. If one agent gets stuck, another can jump in. This can lead to more creative and robust solutions for ambiguous, open-ended problems.
  • Con: Can be chaotic, inefficient, and costly. Without a clear supervisor, agents might loop unproductively or fail to converge on a solution. The LangChain video (LINK) wisely cautions that these "network of agents" can be unreliable in production without very careful design.

Summary of Patterns

The Google Cloud documentation provides a helpful table that summarizes when to use each pattern based on the workload.

Agent Design Patterns Table

This table from the Google Cloud architecture guide categorizes agent design patterns based on workload characteristics, such as deterministic workflows, dynamic orchestration, and iteration. This serves as a quick reference for choosing the right pattern for a given task.

Test your understanding!

You are tasked with building an AI system to automate market analysis. The system needs to perform the following steps:

  1. Gather the latest financial news from three different news APIs.
  2. Pull the latest stock price data for a list of companies from a database.
  3. Analyze the public sentiment based on the news.
  4. Synthesize all this information (news, prices, sentiment) into a single, comprehensive market brief.

Which multi-agent patterns would you combine to build this system, and in what order? Justify your choices.

Show answer

A composite approach combining several patterns would be most effective here.

  1. Parallel Pattern: The first step, gathering data, is a perfect use case for the parallel pattern. You could have three separate NewsFetcher agents, each responsible for one news API, and a StockDataFetcher agent for the database. All four could run simultaneously to minimize data collection time.

  2. Sequential Pattern: After the data is gathered, the subsequent steps form a logical sequence.

    • A SentimentAnalysis agent would process the news gathered in the previous step.
    • This flow forms an assembly line: Gather Data (Parallel) -> Analyze Sentiment (Sequential).
  3. Coordinator/Supervisor Pattern: A top-level MarketAnalyst agent would orchestrate the entire process.

    • It would first trigger the parallel data gathering.
    • Once the data is ready, it would pass it to the SentimentAnalysis agent.
    • Finally, it would take the stock data, the raw news, and the sentiment analysis report and perform the final synthesis to generate the market brief itself, or delegate this final writing task to a specialized ReportWriter agent.

This combination leverages the speed of the parallel pattern for I/O-bound tasks, the reliability of the sequential pattern for processing, and the intelligent orchestration of a coordinator to manage the overall workflow.


Conclusion

You now have a solid grasp of the fundamental design patterns for multi-agent systems. We've seen that the choice of pattern is a trade-off between control, flexibility, cost, and complexity.

Key Takeaways:

  • Deterministic Patterns (Sequential, Parallel, Loop): Best for structured, predictable workflows. They are efficient and reliable, like an assembly line.
  • Hierarchical Patterns (Coordinator, Hierarchical): Use a manager agent to dynamically route tasks. This provides flexibility and is ideal for automating complex business processes.
  • Collaborative Patterns (Swarm): Allow for free-form, all-to-all communication. They are powerful for creative and ambiguous problems but risk being chaotic and inefficient.
  • Composite Designs: Real-world systems rarely use just one pattern. The most robust solutions often combine multiple patterns to leverage the strengths of each.

In our next lesson, we will get practical again. We'll implement a simple two-agent collaboration pattern (a manager-worker duo), putting the Coordinator pattern into practice using LangGraph.