Duration: 4 hours | Difficulty: Advanced | Prerequisites: Modules 08–10
Learning Objectives
By the end of this module, you will be able to:
- Design multi-agent systems with supervisor, swarm, and peer-to-peer patterns
- Build collaborative agent teams using CrewAI
- Implement conversational agent groups with AutoGen
- Handle inter-agent communication, task delegation, and conflict resolution
- Debug and monitor multi-agent workflows
1. Why Multi-Agent?
A single agent runs out of focus and context on big projects. Multi-agent setups give you roles: researcher, writer, critic, each with narrower prompts and tools.
Analogy: building a house—electrician vs plumber vs framer. Same job site, different expertise.
Single Agent: One LLM does everything (overloaded)
Multi-Agent: ┌─ Researcher ─────┐
│ ▼
Supervisor ──┼─ Writer ──────▶ Editor ──▶ Final Output
│ ▲
└─ Fact-Checker ───┘Multi-Agent Patterns
| Pattern | Structure | Best for |
|---|---|---|
| Supervisor | Coordinator delegates | Predictable workflows |
| Swarm | Emergent coordination | Brainstormy exploration |
| Peer-to-Peer | Agents talk laterally | Debate / consensus |
| Hierarchical | Layers of managers | Big org simulations |
Try This! For your next project, list three distinct responsibilities—if they argue in one prompt, they might deserve separate agents.
2. CrewAI: Task-Oriented Agent Teams
CrewAI models Agents, Tasks, and Crews (with sequential or hierarchical process). Tasks can declare context dependencies—outputs flow like a Makefile.
CrewAI with Tools
Give agents tools the same way you would in single-agent apps—web search wrappers, file readers, SQL—then let the crew orchestration handle ordering.
Key Example: Tiny three-role crew: research → write → edit. Trim verbosity in real runs.
[object Object], crewai ,[object Object], Agent, Task, Crew, Process
,[object Object], langchain_openai ,[object Object], ChatOpenAI
llm = ChatOpenAI(model=,[object Object],, temperature=,[object Object],, api_key=,[object Object],)
researcher = Agent(
role=,[object Object],,
goal=,[object Object],,
backstory=,[object Object],,
llm=llm,
)
writer = Agent(
role=,[object Object],,
goal=,[object Object],,
backstory=,[object Object],,
llm=llm,
)
editor = Agent(
role=,[object Object],,
goal=,[object Object],,
backstory=,[object Object],,
llm=llm,
)
t1 = Task(
description=,[object Object],,
expected_output=,[object Object],,
agent=researcher,
)
t2 = Task(
description=,[object Object],,
expected_output=,[object Object],,
agent=writer,
context=[t1],
)
t3 = Task(
description=,[object Object],,
expected_output=,[object Object],,
agent=editor,
context=[t2],
)
crew = Crew(agents=[researcher, writer, editor], tasks=[t1, t2, t3], process=Process.sequential)
,[object Object],(crew.kickoff())3. AutoGen: Conversational Multi-Agent
AutoGen-style frameworks let agents send messages to each other in a group chat. Good for iterative critique (“coder” vs “reviewer”) and role-play simulations.
| CrewAI vibe | AutoGen vibe |
|---|---|
| Task graph | Chat transcript |
| Great for ETL-like pipelines | Great for debate loops |
Concept: Pick the framework that matches your control flow—DAG vs conversation.
4. Supervisor Pattern with LangGraph
Implement supervisor as a node that picks the next worker using structured output or function calls. Workers return to supervisor until END. This mirrors Module 10 graphs—multi-agent is mostly orchestration.
| Tip | Why |
|---|---|
| Log decisions | Debug “why did it pick writer2?” |
| Cap handoffs | Prevent infinite ping-pong |
5. Debugging Multi-Agent Systems
| Symptom | Likely cause |
|---|---|
| Circular chatter | Missing stop condition |
| Duplicate work | Task context not wired |
| Drifting tone | Shared LLM temperature too high |
| Cost spike | Parallel agents + huge prompts |
Observability: trace each agent call (LangSmith, OpenTelemetry, or plain structured logs).
Key Takeaway
Multi-agent is distributed systems cosplay—same debugging discipline applies.
Practice Exercises
Exercise 1: Debate Agents (Beginner)
Two agents argue pros/cons; third synthesizes—cap rounds.
Exercise 2: CrewAI Content Team (Intermediate)
Add a tool stub (e.g., fake web search).
Exercise 3: Code Review Team (Intermediate)
Author + reviewer + security nitpicker.
Exercise 4: Supervisor with Dynamic Routing (Advanced)
LangGraph supervisor + conditional edges.
Exercise 5: Swarm Intelligence (Advanced)
Emergent task claiming with guardrails.
Mini-Project: AI Development Team
Simulate PM → dev → QA agents producing a mini spec, patch plan, and test checklist for a toy feature.
Key Takeaways
Key Takeaway
- Use multiple agents when roles genuinely differ—not for fashion.
- CrewAI excels at task DAGs; AutoGen at multi-turn chatter.
- Supervisor + LangGraph keeps control flow visible.
- Debug with traces, not printf in one mega-prompt.
- Cost and latency scale with agent count—budget accordingly.