Module 5 of 10, lesson 1 of 5
Multi-agent systems
Know when several agents are worth their coordination cost, and which structures are available.
A multi-agent system brings several agents together toward a shared result. One agent called as a mere tool doesn’t qualify: the goals, memory and plans of the others must be taken into account.
Centralized or not
- Centralized: one unit holds global knowledge and coordinates. It’s consistent and simple, but if it fails, everything stops.
- Decentralized: each agent talks to its neighbors. It’s robust, but it’s hard to guarantee that local behavior serves the group.
Structures
- Hierarchy: a tree, with simple or shared authority.
- Holarchy: a main agent oversees sub-agents and appears as a single entity.
- Coalition: a temporary alliance, dissolved once the goal is reached.
- Team: close to a coalition, with agents more dependent on one another.
What justifies several agents
Specialization is the best reason: different instructions, tools and permissions per role, which keeps each context small. Parallel work on independent subtasks is another.
What it costs
- Every exchange uses tokens and adds latency.
- Agents can overwrite each other or fight over a resource.
- Built on the same model, they share the same weaknesses: one attack or outage can hit them all at once.
- Debugging becomes an investigation of interactions, not of a single trace.
Opinions differ: Anthropic describes a multi-agent system in production, while Cognition advises against the approach. Read both, then test on your own case and count the cost.
One cook is enough for breakfast.
Worked example: Passing a decision, not a transcript
When one agent hands work to another, what it passes on is a cost and a risk. Pass what the next agent needs to act.
function handoff(state) {
return {
orderId: state.orderId,
decision: state.decision,
reason: state.reason,
tokens: Math.round(JSON.stringify(state.reason).length / 4) + 20,
};
}
const triage = {
orderId: 4512,
decision: 'refund',
reason: 'Delivered broken, photo checked',
transcript: 'x'.repeat(8000),
};
handoff(triage).tokens < JSON.stringify(triage).length / 4;
true
The refund agent receives the decision and its reason. The eight thousand characters of conversation stay behind, along with any instruction a customer may have hidden in them.
Try it in the editor
async function fanOut(tasks, worker, { limit = 2 } = {}) { return Promise.all(tasks.map((task) => worker(task)));}module.exports = { fanOut };