Skip to main content

Advanced Multi-Agent Patterns

Welcome to the final and most advanced lesson in the AWS Strands course! Here, you’ll move beyond single agents and explore powerful patterns for building complex systems where multiple agents collaborate to achieve a goal.

Learning Objectives

Hierarchical Systems

Design agent systems with clear delegation patterns

Dynamic Swarms

Build self-organizing agent swarms for complex problems

Graph Workflows

Create structured, predictable workflows

Pattern Selection

Choose the right pattern for different use cases

Multi-Agent Patterns Overview

Strands provides high-level abstractions for orchestrating multi-agent workflows. We’ll cover four key patterns, each with distinct advantages:

1. Agent as Tools

Hierarchical Delegation

A hierarchical pattern where a “manager” agent delegates tasks to specialized “worker” agents.Best for: Clear task decomposition, centralized controlUse cases: Customer service, content creation, research workflowsAdvantages: Predictable, easy to debug, clear responsibility boundaries
Architecture:
User Query

Orchestrator Agent (Router)

┌─────────────────┬─────────────────┬─────────────────┐
│ Research Agent  │ Product Agent   │ Travel Agent    │
│ (Factual Info)  │ (Recommendations)│ (Itineraries)   │
└─────────────────┴─────────────────┴─────────────────┘

Combined Response
Example: Specialized Agents
from strands.tools import tool

@tool
def research_assistant(query: str) -> str:
    """A specialized agent for research-related queries."""
    research_agent = Agent(
        model=LLM,
        system_prompt="You are a specialized research assistant.",
        tools=[retrieve, http_request],
    )
    return str(research_agent(query))

# Orchestrator uses these agents as tools
orchestrator = Agent(
    model=model,
    tools=[research_assistant, product_assistant, travel_assistant],
    system_prompt="Route queries to the appropriate specialist."
)

2. Swarm Intelligence

Dynamic Self-Organization

A dynamic and decentralized pattern where agents can intelligently hand off tasks to each other.Best for: Open-ended problems, creative tasks, explorationUse cases: Software development, research, creative writingAdvantages: Flexible, emergent behavior, self-organizing
Architecture:
    Agent A
      ↕️
    Agent B ⇄ Agent C
      ↕️      ↕️
    Agent D ⇄ Agent E
    
(Agents dynamically hand off tasks)
Key Features:
  • Agents can transfer control to each other
  • No central orchestrator
  • Emergent problem-solving behavior
  • Flexible task routing

3. Graph-Based Workflows

Structured Execution

A structured pattern where you define a predictable, directed workflow for your agents.Best for: Production systems, repeatable processes, complianceUse cases: Data pipelines, approval workflows, quality assuranceAdvantages: Reliable, auditable, parallel execution
Architecture:
[Start] → [Agent A] → [Agent B]
              ↓          ↓
         [Agent C] → [Agent D] → [End]
Key Features:
  • Explicit workflow definition
  • Parallel execution support
  • Conditional branches
  • State management

4. Workflow Agent

Stateful Orchestration

The most advanced pattern combining stateful workflows with conditional logic.Best for: Complex business processes, adaptive systemsUse cases: Customer onboarding, dynamic content generationAdvantages: Stateful, conditional, highly flexible
Key Features:
  • State persistence across steps
  • Conditional routing
  • Error handling and retries
  • Complex business logic

Pattern Comparison

PatternComplexityControlFlexibilityBest Use Case
Agent as Tools⭐⭐CentralizedMediumCustomer service, content creation
Swarm Intelligence⭐⭐⭐DecentralizedHighSoftware development, research
Graph-Based⭐⭐⭐StructuredMediumData pipelines, compliance
Workflow Agent⭐⭐⭐⭐HybridVery HighBusiness processes, adaptive systems

Multi-Agent Patterns Overview

This lesson covers multiple patterns for orchestrating multiple agents:

Agent as Tools

Build an orchestrator agent that delegates tasks to specialized worker agentsComplexity: ⭐⭐

Swarm Intelligence

Create dynamic agent swarms that self-organize to solve problemsComplexity: ⭐⭐⭐

Graph-Based Workflows

Define explicit, structured workflows for multi-agent collaborationComplexity: ⭐⭐⭐

Workflow Agent

Build complex, stateful workflows with conditional logicComplexity: ⭐⭐⭐⭐

Quick Start Guide

Each sub-lesson includes:

Complete Code

Full, working examples

Real Use Cases

Production scenarios

Best Practices

Expert guidance

Configuration

Tuning options

Troubleshooting

Common issues

Experiments

Try-it-yourself tasks

Prerequisites

Before starting this lesson, ensure you have:
1

Complete Previous Lessons

2

Understand Basic Concepts

  • Agent creation and configuration
  • Tool usage
  • System prompts
  • Session management
3

Python Knowledge

  • Familiarity with Python 3.10+
  • Understanding of async/await (for advanced patterns)
  • Basic knowledge of decorators
4

Environment Setup

  • API keys configured (Nebius, OpenAI, etc.)
  • Dependencies installed (strands, strands-tools)
  • uv package manager (optional but recommended)

When to Use Multi-Agent Patterns

✅ Tasks require multiple specialized skills✅ Problems need to be broken into subtasks✅ You need parallel processing✅ Different agents need different models/tools✅ You want to isolate concerns✅ Complex workflows require orchestration
❌ Simple, single-purpose tasks❌ Low latency is critical (overhead from multiple agents)❌ Budget constraints (multiple LLM calls)❌ Task doesn’t benefit from specialization❌ Coordination overhead exceeds benefits

Example: Quick Agent-as-Tools Demo

Here’s a quick taste of what you’ll learn:
import os
from strands import Agent
from strands.models.litellm import LiteLLMModel
from strands.tools import tool

# Define specialized worker agents as tools
@tool
def math_expert(query: str) -> str:
    """Expert in mathematical calculations and problem-solving."""
    model = LiteLLMModel(
        client_args={"api_key": os.getenv("NEBIUS_API_KEY")},
        model_id="nebius/deepseek-ai/DeepSeek-V3-0324",
    )
    agent = Agent(
        model=model,
        system_prompt="You are a math expert. Solve problems step-by-step.",
    )
    return str(agent(query))

@tool
def science_expert(query: str) -> str:
    """Expert in scientific concepts and explanations."""
    model = LiteLLMModel(
        client_args={"api_key": os.getenv("NEBIUS_API_KEY")},
        model_id="nebius/deepseek-ai/DeepSeek-V3-0324",
    )
    agent = Agent(
        model=model,
        system_prompt="You are a science expert. Explain concepts clearly.",
    )
    return str(agent(query))

# Create orchestrator that routes to specialists
orchestrator = Agent(
    model=LiteLLMModel(
        client_args={"api_key": os.getenv("NEBIUS_API_KEY")},
        model_id="nebius/deepseek-ai/DeepSeek-V3-0324",
    ),
    tools=[math_expert, science_expert],
    system_prompt="""You are a master assistant. Route queries:
    - Math problems → math_expert
    - Science questions → science_expert
    - Simple questions → answer directly
    """,
)

# Use the orchestrator
response = orchestrator("Calculate the speed of light and explain its significance")
print(response)
# The orchestrator will call both math_expert and science_expert!

Common Challenges

Multi-agent systems introduce complexity. Be aware of:
  • Latency: Multiple LLM calls increase response time
  • Cost: More agents = more API calls = higher costs
  • Coordination: Agents may misunderstand handoffs
  • Debugging: Harder to trace issues across multiple agents
  • Context Loss: Information may be lost between agent transitions

What You’ll Learn

By the end of this lesson series, you’ll be able to:
  • Design hierarchical agent systems with clear responsibilities
  • Implement dynamic swarm patterns for creative problem-solving
  • Build graph-based workflows for production systems
  • Create complex stateful workflows with conditional logic
  • Choose the right pattern for your specific use case
  • Debug and optimize multi-agent systems

Start Learning

Ready to build your first multi-agent system? Explore the patterns in the source code at course/aws_strands/06_multi_agent_pattern/ to see complete implementations.

Resources

Video Playlist

Watch all multi-agent patterns on YouTube

Strands Documentation

Read the official multi-agent docs

Build docs developers (and LLMs) love