Multi-Agent Systems
1. The Limits of a Single Agent
In Week 6, we built a single autonomous agent using the ReAct framework. It could reason, use tools, and observe the results. So why do we need multiple agents?
The answer lies in the limitations of LLM cognition and context windows.
The "Jack of All Trades" Problem
Imagine you want an AI to write a production-ready web application. A single agent would need:
- A massive system prompt explaining how to be a Product Manager, a Frontend Developer, a Backend Developer, and a QA Tester.
- Access to 50+ different tools (file reading, file writing, terminal execution, web searching, linting, etc.).
When you give a single LLM too many instructions and too many tools, it suffers from Prompt Dilution. Its attention is divided. It might use the web search tool when it should be writing code, or it might forget the QA instructions because the Developer instructions were too long.
The Multi-Agent Solution: Division of Labor
Just like human organizations, AI systems perform best when labor is divided among specialized roles.
Instead of one massive agent, you create a Multi-Agent System (MAS). You instantiate several distinct LLMs (or the same LLM with different system prompts):
- The Researcher: Only has web search tools. Its only job is to gather facts.
- The Coder: Only has file-writing tools. Its only job is to write code based on the Researcher's notes.
- The Reviewer: Only has linting and testing tools. Its only job is to critique the Coder's work.
This concept was famously demonstrated in the ChatDev (2023) paper, where researchers created a virtual software company entirely populated by specialized AI agents that communicated with each other to build software from scratch.
By restricting an agent's focus and toolset, you drastically increase its reliability and accuracy for that specific task.