DEV Community

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

Posted 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.

```text id="w70n8v"
User

Orchestrator

├── Study Agent
├── Expense Agent
├── Fitness Agent
└── Travel Agent




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:



```text id="hkxgx6"
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

```python id="ej58br"
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s | %(levelname)s | %(message)s",
)




Logging helps us understand:

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

Example:



```text id="y4dkvh"
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

```python id="h3c66o"
bedrock_model = BedrockModel(
model_id="",
region_name="eu-west-2",
temperature=0.3,
)




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



```python id="o5j5dr"
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:

```python id="4mgv3u"
Agent(...)
Agent(...)
Agent(...)




we centralize the logic.

---

## ⚙️ Step 4: Create Specialized Agents

### Study Agent



```python id="m9l6bf"
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

```python id="sz9rj6"
expense_agent = create_agent(
name="expense_agent",
system_prompt="""
You are an expense assistant.
Help users manage budgets.
"""
)




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



```python id="e4qj98"
@tool
def study_assistant(
    query: str
) -> str:
Enter fullscreen mode Exit fullscreen mode

This wraps the Study Agent as a tool.

Workflow:

```text id="83lykw"
Tool Call

Study Agent

Response




---

### Expense Tool



```python id="4vr1ig"
@tool
def expense_assistant(
    query: str
) -> str:
Enter fullscreen mode Exit fullscreen mode

This wraps the Expense Agent.

Workflow:

```text id="x4wozg"
Tool Call

Expense Agent

Response




Now the orchestrator can invoke either specialist.

---

## ⚙️ Step 6: Create the Orchestrator Prompt



```python id="ys8teq"
orchestrator_prompt = """
You are a router assistant.
"""
Enter fullscreen mode Exit fullscreen mode

This prompt defines routing rules.

Study Topics

```text id="e80bvo"
study
learning
courses
practice
certifications
exams




### Expense Topics



```text id="rul44e"
budget
money
savings
spending
expenses
cost
Enter fullscreen mode Exit fullscreen mode

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

```python id="v38nbe"
orchestrator_agent = Agent(
system_prompt=orchestrator_prompt,
model=bedrock_model,
tools=[
study_assistant,
expense_assistant,
],
)




This is the brain of the system.

It receives the user request and chooses the correct specialist.

Architecture:



```text id="bx9qwf"
User
 ↓
Orchestrator
 ↓
Correct Tool
 ↓
Specialized Agent
Enter fullscreen mode Exit fullscreen mode

▶️ Run the Application

Execute:

```bash id="rxy1ii"
python agent.py




Or:



```bash id="k5d2nh"
uv run labs/08-multi-agent-orchestrator/agent.py
Enter fullscreen mode Exit fullscreen mode

📊 Example Interaction #1

User

```text id="s9zn1s"
Help me prepare for AWS Cloud Practitioner.




### Routing



```text id="m6v00u"
Orchestrator
     ↓
study_assistant
     ↓
Study Agent
Enter fullscreen mode Exit fullscreen mode

Response

```text id="yykx7m"
Here's a 4-week AWS Cloud Practitioner study plan...




---

## 📊 Example Interaction #2

### User



```text id="hk0e5q"
How can I save ₹5000 every month?
Enter fullscreen mode Exit fullscreen mode

Routing

```text id="m7hd8x"
Orchestrator

expense_assistant

Expense Agent




### Response



```text id="v9xl7r"
Let's review your monthly expenses and identify savings opportunities...
Enter fullscreen mode Exit fullscreen mode

📊 Example Interaction #3

User

```text id="3swmpx"
I have an exam next month and need a budget for training materials.




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:



```text id="vd6l7r"
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:

```text id="vvw7mt"
Agent Orchestration




and is 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



```text id="n1e0y4"
Billing Agent
Technical Agent
Escalation Agent
Enter fullscreen mode Exit fullscreen mode

Healthcare

```text id="slkj6g"
Symptoms Agent
Insurance Agent
Appointment Agent




### Enterprise Operations



```text id="px0i6z"
HR Agent
Finance Agent
IT Agent
Legal Agent
Enter fullscreen mode Exit fullscreen mode

Personal Assistants

```text id="4m98t8"
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:

https://github.com/d3vjamal/strands-agents-labs

---

## 🔗 Continue Learning

⬅️ Previous Lab

[Lab 06: Build Your First MCP Server with Streamable HTTP | Strands Agentic AI](https://dev.to/d3vjamal/-lab-06-build-your-first-mcp-server-with-streamable-http-strands-agentic-ai-1995)


---

## 🚀 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.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)