← Master Index
Vol. 15 Module 15.1 Lecture

Multi-Agent System

Agent Fundamentals

How This Lesson Fits the Module & Volume

A single agent fails when one persona cannot hold conflicting goals, huge disjoint tool sets, or parallel specialties. A multi-agent system coordinates multiple agents with roles, handoffs, and shared or partitioned memory. You previewed this in Vol. 14 with CrewAI (role crews), AutoGen (conversable agents), and LangGraph (explicit multi-actor graphs).

This lecture teaches the design those frameworks implement. Module 15.4 will cross-reference the same libraries again after you have fundamentals, memory types, and MCP.

Learning Objectives

By the end of this lesson, students should be able to:

  • Define a multi-agent system as multiple autonomous (or semi-autonomous) actors plus a coordination policy.
  • Compare supervisor, sequential crew, and conversation/swarm styles.
  • Design role prompts, handoff contracts, and shared state carefully.
  • Identify failure modes: chatter loops, cost blowups, credit assignment.
  • Place CrewAI, AutoGen, and LangGraph on the coordination map.
  • Decide when multi-agent is justified versus a single agent + workflow.
Definition

A multi-agent system (MAS) is a set of two or more agents that interact according to a coordination policy (handoffs, a supervisor, or a conversation protocol) to achieve a goal none of them owns alone. Each agent has its own prompt/tools (and often memory); the system still needs global halt rules and eval.

Coordination Styles

StyleHow work movesClosest Vol. 14 analogWatch-out
Sequential crewA → B → C tasksCrewAI Process.sequentialBrittle if A’s output is vague
Supervisor / hierarchicalRouter assigns specialistsCrewAI hierarchical; LangGraph routerSupervisor becomes a god-prompt
Conversation / swarmAgents message until terminateAutoGen group chatChatter & unclear halt
Graph of actorsExplicit edges + stateLangGraphMore design up front

Minimal Supervisor Sketch

Even without a framework, you can run two specialists behind a router. Notice the handoff contract: JSON the next agent can consume—not a novel.

import json from openai import OpenAI client = OpenAI() def complete(system: str, user: str) -> str: return client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "system", "content": system}, {"role": "user", "content": user}], ).choices[0].message.content def supervisor(goal: str) -> str: route = complete( "Return ONLY JSON {\"next\": \"researcher\"|\"writer\"|\"done\", \"brief\": str}.", goal, ) spec = json.loads(route) if spec["next"] == "done": return spec["brief"] if spec["next"] == "researcher": notes = complete( "You are a researcher. Use only plausible public-style facts. Output bullet notes, no prose essay.", spec["brief"], ) spec = {"next": "writer", "brief": notes} if spec["next"] == "writer": return complete( "You are a technical writer. Turn notes into a 120-word customer email. No invented SLAs.", spec["brief"], ) return "HALT: unknown route" print(supervisor("Draft an email explaining our refund window (5–7 days) for ORD-1042."))

Contracts, Memory, and Eval

Handoff contract

  • Schema, not free chat
  • Explicit done_when
  • Tool allowlists per role

Memory

  • Shared state vs private
  • Who may write long-term?
  • Preview Module 15.2 types

Eval

  • Score the system, not vibes
  • Trace per agent
  • Cost per successful task

Strengths

  • Specialization & parallel work
  • Separation of conflicting goals
  • Mirrors human org charts
  • Rich Vol. 14 framework support

Tradeoffs

  • Chatter and token blowups
  • Handoff lossiness
  • Harder debugging
  • More failure surfaces
Common Misconception

“More agents means more intelligence.” Extra agents multiply coordination errors. A vague researcher dumping ungrounded prose on a writer creates confident nonsense faster. Prefer fewer roles, stricter handoff schemas, and a global step/cost budget—then add HITL on the risky handoff.

Knowledge Check

  1. Short Answer: What extra ingredient turns several agents into a MAS? Answer: A coordination policy (handoffs, supervisor, or conversation protocol) plus global halt/eval.
  2. True/False: AutoGen is relatively conversation-centric compared with LangGraph’s explicit graphs. Answer: True.
  3. Multiple Choice: CrewAI emphasizes: (a) CUDA, (b) role-based crews and tasks, (c) pooling. Answer: (b).
  4. Short Answer: Why use a JSON handoff instead of free chat? Answer: Parsable contracts reduce lossy, vague transfers.
  5. True/False: Multi-agent always beats single-agent on cost. Answer: False—chatter often costs more.
  6. Multiple Choice: A supervisor risk is: (a) becoming a god-prompt, (b) better stride, (c) smaller vocabs. Answer: (a).
  7. Short Answer: Name one MAS failure mode. Answer: Chatter loops, cost blowups, vague handoffs, or credit-assignment issues (any).
  8. Short Answer: When is MAS justified? Answer: Conflicting goals, disjoint tool sets, or true parallel specialties after single-agent eval fails.
  9. Multiple Choice: Shared vs private memory matters because: (a) fonts, (b) who can write durable facts / leak PII, (c) CNNs. Answer: (b).
  10. True/False: Global halt rules still apply in multi-agent systems. Answer: True.

Key Takeaways

  • MAS = multiple agents + coordination + global budgets/eval.
  • Pick a style deliberately: crew, supervisor, conversation, or graph.
  • Handoffs need schemas; memory write rights need policy.
  • CrewAI, AutoGen, and LangGraph are implementations—not a reason to skip design.
  • Next: human-in-the-loop, the last fundamental control surface.
Trainer’s Guide

Whiteboard: Redesign a 6-agent vendor demo down to 2 roles + a workflow. Keep only handoffs that change permissions or goals.

Lab: Add a max_handoffs=3 counter to supervisor(). Force terminate with a partial answer when exceeded.

Recap: Multi-agent systems coordinate specialized actors under global halt rules. Continue with Human in the Loop.