Menu

AI Agents course · Lesson 6 of 7

Multi-Agent Systems: When and How to Use Several Agents

What multi-agent systems are, the coordinator and specialist pattern, when several agents beat one, and the costs they add, with a runnable Python example.

  • Advanced
  • 4 min read
  • Updated Nov 2026
On this page
  1. Common patterns
  2. Coordinator and specialists in code
  3. When several agents are worth it
  4. When they are not
  5. Common mistakes
  6. Key takeaway

A multi-agent system splits work between several agents, each with its own instructions, tools and context, coordinated by code or by another agent. Instead of one agent that knows everything and can do everything, you have specialists: one for billing, one for shipping, one for research, one for writing.

Common patterns

  • Coordinator and specialists: a coordinator understands the request, sends parts to specialist agents, and combines their results. The most common pattern.
  • Pipeline: agents work in sequence, each passing its output to the next, such as research, then draft, then review.
  • Reviewer: one agent produces work, another checks it against rules and sends it back if needed.

Coordinator and specialists in code

This example sends a two-part customer question to a shipping specialist and a billing specialist. Each specialist sees only its own tools and data:

# A coordinator splits a request into parts and sends each to a specialist agent with its own tools.
# Specialists are stand-ins for model-driven agents; each sees only the tools it needs.
calls = {"model": 0}

def billing_agent(task):
    calls["model"] += 2                                   # e.g. one call to choose a tool, one to answer
    invoices = {"B-2210": {"amount": 59.0, "refund": "issued 28 Oct"}}
    inv = invoices.get(task["order_id"])
    return f"refund for {task['order_id']}: {inv['refund']}" if inv else "no invoice found"

def shipping_agent(task):
    calls["model"] += 2
    shipments = {"A-1042": "held at depot, new date 5 Nov"}
    return f"order {task['order_id']}: {shipments.get(task['order_id'], 'no shipment found')}"

SPECIALISTS = {"billing": billing_agent, "shipping": shipping_agent}

def coordinator(request):
    calls["model"] += 1                                   # one call to split the request
    parts = [{"team": "shipping", "order_id": "A-1042"},  # what a model would extract from the request
             {"team": "billing", "order_id": "B-2210"}]
    results = [SPECIALISTS[p["team"]](p) for p in parts]
    calls["model"] += 1                                   # one call to write the combined answer
    return " | ".join(results)

print(coordinator("Where is order A-1042, and did my refund for B-2210 go through?"))
print("model calls:", calls["model"])
order A-1042: held at depot, new date 5 Nov | refund for B-2210: issued 28 Oct
model calls: 6

The customer gets one combined answer. The cost is visible too: six model calls, where a single agent might need three or four. Each specialist has a smaller, focused prompt and only the permissions it needs, which is often the main benefit: the billing agent can never touch shipping systems.

When several agents are worth it

  • Clearly separate areas with different tools, data or permissions.
  • Large tasks that split into independent parts, which can run in parallel.
  • Different skills or models: a cheap model for simple lookups, a stronger one for writing or judgement.
  • Independent review: a second agent checking the first against rules.

When they are not

For most tasks, one agent, or a workflow, is simpler, cheaper and easier to test. Each extra agent adds model calls, latency, places where information can be lost between agents, and new ways to fail. Start with one agent and split only when a clear problem appears, such as a prompt becoming too large or permissions needing separation. See workflows vs agents.

Common mistakes

  1. Many agents for a simple task, multiplying cost and delay.
  2. Agents that talk without limits, passing messages back and forth forever.
  3. Lost context: the coordinator forgets to pass a detail a specialist needs.
  4. No end-to-end evaluation: each agent looks fine alone, but the combined answer is wrong.

Key takeaway

Multi-agent systems split work between specialists with their own tools and permissions, usually under a coordinator. They help with separate domains, large parallel tasks and independent review, but they cost more and fail in new ways, so start with one agent and split only for a clear reason. Next: putting it all together in an AI agent project.

By , Data Engineer and Founder of DataDank · Last reviewed Nov 2026 · Patterns apply to any framework. Examples use plain Python 3 with stand-ins in place of real model calls so they run anywhere; their output is real.

Progress is saved in this browser only. No account needed.

Search
Filter by type