DEV Community

Cover image for # 🤖 Lab 07: Building Multi-Agent Systems with an Orchestrator | Strands Agentic AI
Jamal
Jamal

Posted on • Edited on

# 🤖 Lab 07: Building Multi-Agent Systems with an Orchestrator | Strands Agentic AI

So far in this series, we've built agents, custom tools, MCP integrations, and MCP servers.

But real-world AI applications often require multiple specialists working together.

Instead of creating one giant agent responsible for everything, we can create multiple specialized agents and use a central orchestrator to route requests to the right expert.

In this lab, we'll build:

  • A Study Assistant
  • An Expense Assistant
  • An Orchestrator Agent

The orchestrator will decide which specialist should handle the user's request.

By the end of this tutorial, you'll understand one of the most important patterns in Agentic AI: Multi-Agent Architectures.


📚 Strands Agentic AI Lab Series

⬅️ Previous: Lab 07: Build Your First MCP Server

📍 Current: Lab 08: Building Multi-Agent Systems

➡️ Next: Lab 09: Agent Collaboration & Sequential Workflows


🚀 What You'll Learn

In this lab, you'll learn:

  • What multi-agent systems are
  • Why specialized agents outperform general-purpose agents
  • How to build reusable agents
  • How to create an orchestrator agent
  • How to route requests dynamically
  • How to add logging for debugging

🤖 Why Multi-Agent Systems?

Imagine building a personal assistant that can help with:

  • Studying
  • Budgeting
  • Fitness
  • Travel
  • Career advice

You could create one massive prompt. Or you could create specialists.

User
  ↓
Orchestrator
  ↓
 ├── Study Agent
 ├── Expense Agent
 ├── Fitness Agent
 └── Travel Agent
Enter fullscreen mode Exit fullscreen mode

This approach is:

  • ✅ Easier to maintain
  • ✅ Easier to scale
  • ✅ Easier to test
  • ✅ More accurate

This architecture is commonly used in enterprise AI systems.


🛠️ Prerequisites

Before starting, make sure you have:

  • Python 3.10+
  • Strands SDK
  • AWS account
  • Amazon Bedrock access
  • AWS credentials configured
  • uv installed

🏗️ Architecture Overview

Our application looks like this:

User
  ↓
Orchestrator Agent
  ↓
 ├── study_assistant()
 │      ↓
 │   Study Agent
 │
 └── expense_assistant()
        ↓
     Expense Agent
Enter fullscreen mode Exit fullscreen mode

The orchestrator never answers directly. Its job is to decide which specialist should handle the request.


📜 The Complete Script

This lab introduces:

  • Reusable agent creation
  • Specialized agents
  • Tool-based routing
  • Agent orchestration
  • Structured logging

Let's break it down step by step.


⚙️ Step 1: Configure Logging

logging.basicConfig(
    level=logging.DEBUG,
    format="%(asctime)s | %(levelname)s | %(message)s",
)
Enter fullscreen mode Exit fullscreen mode

Logging helps us understand:

  • Which agent was selected
  • Which tool was called
  • What response was generated
  • Any errors that occurred

Example output:

INFO | User query received
INFO | study_assistant called
DEBUG | Study response generated
Enter fullscreen mode Exit fullscreen mode

This becomes incredibly useful when debugging complex multi-agent systems.


⚙️ Step 2: Configure the Bedrock Model

bedrock_model = BedrockModel(
    model_id="<YOUR_MODEL_ID>",
    region_name="eu-west-2",
    temperature=0.3,
)
Enter fullscreen mode Exit fullscreen mode

All agents in this lab share the same Bedrock model. This keeps the architecture simple. In production, different agents may use different models.


⚙️ Step 3: Create a Reusable Agent Factory

def create_agent(
    name: str,
    system_prompt: str
) -> Agent:
    ...
Enter fullscreen mode Exit fullscreen mode

This helper function creates specialized agents.

Benefits:

  • Less code duplication
  • Consistent configuration
  • Easier maintenance

Instead of repeating:

Agent(...)
Agent(...)
Agent(...)
Enter fullscreen mode Exit fullscreen mode

we centralize the logic.


⚙️ Step 4: Create Specialized Agents

Study Agent

study_agent = create_agent(
    name="study_agent",
    system_prompt="""
    You are a study assistant.
    Help users create learning plans.
    """
)
Enter fullscreen mode Exit fullscreen mode

Responsibilities:

  • Learning plans
  • Courses
  • Certifications
  • Exams
  • Technical concepts

Expense Agent

expense_agent = create_agent(
    name="expense_agent",
    system_prompt="""
    You are an expense assistant.
    Help users manage budgets.
    """
)
Enter fullscreen mode Exit fullscreen mode

Responsibilities:

  • Budgeting
  • Savings
  • Spending analysis
  • Cost reduction
  • Financial planning

Each agent becomes an expert in its own domain.


⚙️ Step 5: Expose Agents as Tools

Study Tool

@tool
def study_assistant(query: str) -> str:
    ...
Enter fullscreen mode Exit fullscreen mode

This wraps the Study Agent as a tool.

Tool Call
     ↓
Study Agent
     ↓
Response
Enter fullscreen mode Exit fullscreen mode

Expense Tool

@tool
def expense_assistant(query: str) -> str:
    ...
Enter fullscreen mode Exit fullscreen mode

This wraps the Expense Agent.

Tool Call
     ↓
Expense Agent
     ↓
Response
Enter fullscreen mode Exit fullscreen mode

Now the orchestrator can invoke either specialist.


⚙️ Step 6: Create the Orchestrator Prompt

orchestrator_prompt = """
You are a router assistant.
"""
Enter fullscreen mode Exit fullscreen mode

This prompt defines routing rules.

Study topics: study, learning, courses, practice, certifications, exams

Expense topics: budget, money, savings, spending, expenses, cost

The orchestrator's job is not to answer — its job is to route. Think of it as a smart receptionist.


⚙️ Step 7: Build the Orchestrator Agent

orchestrator_agent = Agent(
    system_prompt=orchestrator_prompt,
    model=bedrock_model,
    tools=[
        study_assistant,
        expense_assistant,
    ],
)
Enter fullscreen mode Exit fullscreen mode

This is the brain of the system. It receives the user request and chooses the correct specialist.

User
 ↓
Orchestrator
 ↓
Correct Tool
 ↓
Specialized Agent
Enter fullscreen mode Exit fullscreen mode

▶️ Run the Application

python agent.py
Enter fullscreen mode Exit fullscreen mode

Or:

uv run labs/08-multi-agent-orchestrator/agent.py
Enter fullscreen mode Exit fullscreen mode

📊 Example Interaction #1

User:

Help me prepare for AWS Cloud Practitioner.
Enter fullscreen mode Exit fullscreen mode

Routing:

Orchestrator → study_assistant → Study Agent
Enter fullscreen mode Exit fullscreen mode

Response:

Here's a 4-week AWS Cloud Practitioner study plan...
Enter fullscreen mode Exit fullscreen mode

📊 Example Interaction #2

User:

How can I save ₹5000 every month?
Enter fullscreen mode Exit fullscreen mode

Routing:

Orchestrator → expense_assistant → Expense Agent
Enter fullscreen mode Exit fullscreen mode

Response:

Let's review your monthly expenses and identify savings opportunities...
Enter fullscreen mode Exit fullscreen mode

📊 Example Interaction #3

User:

I have an exam next month and need a budget for training materials.
Enter fullscreen mode Exit fullscreen mode

This query touches multiple domains. The orchestrator may:

  • Ask a clarification question
  • Choose the dominant topic
  • Route accordingly

This demonstrates why orchestration logic matters.


🔍 What Happened Behind the Scenes?

When a user submits a request:

User Query
     ↓
Orchestrator Agent
     ↓
Tool Selection
     ↓
Specialized Agent
     ↓
Response
Enter fullscreen mode Exit fullscreen mode

The orchestrator never becomes an expert — instead, it delegates expertise. This pattern is called Agent Orchestration, and it's widely used in production AI systems.


💡 Why Developers Love This Pattern

Without multi-agent systems:

  • ❌ Huge prompts
  • ❌ Mixed responsibilities
  • ❌ Difficult maintenance
  • ❌ Poor scalability

With multi-agent systems:

  • ✅ Specialized expertise
  • ✅ Easier debugging
  • ✅ Modular design
  • ✅ Independent evolution
  • ✅ Better scalability

Each agent focuses on one job and does it well.


🌍 Real-World Use Cases

This same architecture powers:

Customer Support — Billing Agent, Technical Agent, Escalation Agent

Healthcare — Symptoms Agent, Insurance Agent, Appointment Agent

Enterprise Operations — HR Agent, Finance Agent, IT Agent, Legal Agent

Personal Assistants — Study Agent, Budget Agent, Fitness Agent, Travel Agent

The possibilities are endless.


🎯 Key Takeaways

  • Multi-agent systems separate responsibilities
  • Specialized agents improve accuracy
  • Orchestrators route requests intelligently
  • Tools can act as wrappers around agents
  • Logging makes orchestration easier to debug
  • This pattern scales extremely well in production

📚 Source Code

GitHub Repository: d3vjamal/strands-agents-labs


🔗 Continue Learning

⬅️ Previous Lab: Lab 06: Build Your First MCP Server with Streamable HTTP | Strands Agentic AI

➡️ Next Lab: In the next tutorial, we'll move beyond simple routing and explore how multiple agents can collaborate together, passing information between each other to solve complex tasks that no single agent can handle alone.

Top comments (0)