How to Build a Multi-Agent System (LangGraph & CrewAI, Step by Step)
One agent has limits. A team of them, coordinated well, can tackle problems a single agent can't. This is how orchestration actually works — the patterns, runnable LangGraph.js and CrewAI code, and the no-code canvas.
A multi-agent system is what you build when one agent stops being enough: several specialized agents, plus an orchestrator that decides who does what and when the job is done. Done well, it can research, write, and review in parallel, or tackle a problem too big for a single context window. Done badly, it's an expensive, untraceable machine for turning tokens into confusion. The difference is almost entirely in the orchestration — so that's what this guide is really about. We'll cover the patterns, then build the same system three ways: in LangGraph.js, in CrewAI, and with no code at all.
First: do you actually need more than one agent?
This question saves more projects than any framework choice. Anthropic, who ship one of the best-known multi-agent systems, are blunt about it: multi-agent pays off for tasks with genuine parallelism or that exceed a single context window — and their systems use roughly 15× the tokens of a chat to get there. If your task is mostly sequential, a single agent with good tools will be cheaper, faster, and far easier to debug. Be honest with the checklist before you build:
One agent with the right tools will be cheaper, faster, and far easier to debug. Add agents only when this changes.
How orchestration works: the five patterns
“Multi-agent” isn't one architecture — it's a handful of orchestration patterns, and picking the right one is most of the design. Almost everything you'll build is one of these five, or a combination. Tap through them:
One coordinator reads the state and routes each turn to the right specialist, then decides when the job is done. The most common — and most controllable — pattern.
The supervisor pattern is where most teams should start. A single coordinator holds the state, routes each turn to the right specialist, and decides when to stop — which keeps the whole system traceable, because there's always one place that knows what's happening. Watch a supervisor run:
The supervisor is the orchestration: it reads the state and decides who acts next — and when to stop.
Build it in LangGraph.js
LangGraph models a multi-agent system as a graph over shared state: nodes are agents, edges are the routing between them. Its langgraph-supervisor helper builds the supervisor pattern in a few lines — you define the specialist agents, then hand them to a supervisor that routes between them.
// npm i @langchain/langgraph-supervisor @langchain/langgraph @langchain/core @langchain/openai
import { createSupervisor } from "@langchain/langgraph-supervisor";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { ChatOpenAI } from "@langchain/openai";
const model = new ChatOpenAI({ model: "gpt-4o-mini" });
// Two specialists — each a small ReAct agent with its own tools.
const researcher = createReactAgent({ llm: model, tools: [webSearch], name: "researcher" });
const writer = createReactAgent({ llm: model, tools: [], name: "writer" });
// The supervisor routes each turn to a specialist, then decides when to finish.
const app = createSupervisor({
agents: [researcher, writer],
llm: model,
prompt:
"You manage a researcher and a writer. Send research questions to the researcher, " +
"writing to the writer, and finish when the brief is complete and cited.",
}).compile();
const result = await app.invoke({
messages: [{ role: "user", content: "Write a cited brief on solid-state batteries." }],
});That's the high-level path. When you need custom routing, loops, or a human-approval gate, you drop to LangGraph's lower-level StateGraph and wire the nodes and conditional edges yourself — the Multi-Agent Systems notebook track builds supervisor, plan-execute, and cyclic graphs by hand, cell by cell.
Build it in CrewAI
CrewAI takes a different philosophy: instead of a graph you steer, you brief a crew of role-playing agents and give them tasks. You describe each agent's role, goal, and backstory; define the tasks; and pick a process (sequential or hierarchical) that wires them together. It's the fastest way to get a role-based team running.
# pip install crewai crewai-tools
from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool
researcher = Agent(
role="Research Analyst",
goal="Find accurate, current facts on {topic}",
backstory="You are meticulous and cite everything.",
tools=[SerperDevTool()],
)
writer = Agent(
role="Technical Writer",
goal="Turn research into a clear, cited brief",
backstory="You write tight, structured prose.",
)
research = Task(description="Research {topic}.", expected_output="5 cited facts.", agent=researcher)
write = Task(description="Write a 4-paragraph brief.", expected_output="A cited brief.", agent=writer)
crew = Crew(
agents=[researcher, writer],
tasks=[research, write],
process=Process.sequential, # research first, then writing
)
result = crew.kickoff(inputs={"topic": "solid-state batteries"})A graph of nodes and edges over shared state
You define the state, the nodes (agents), and the routing edges. Full control over the flow.
Custom control flow, loops, human-in-the-loop, and anything you need to inspect step by step.
Same outcome, different philosophy: a graph you steer vs a team you brief.
Reach for CrewAI when you want a role-based team running fast with little orchestration code. Reach for LangGraph when you need explicit control over the flow — loops, branching, human-in-the-loop, and step-by-step inspection. Neither is “better”; they optimize for different things.
Build it with no code
You don't have to choose a framework to build and run a multi-agent system. The visual swarm canvas lets you drag agents onto a board, wire the routing between them, and run the whole thing in a sandbox — with the full execution trace so you can see exactly which agent did what. It's the fastest way to prototype an orchestration before you commit it to code, and the templates library has multi-agent swarms you can open and run in one click.
The three things that will break it
Multi-agent systems fail in specific, well-documented ways, and forewarned is forearmed. The research on why they break points at three culprits above all: context that isn't shared between agents (so they make conflicting decisions), no verification of intermediate work (so one agent's error becomes the next one's trusted input), and no clear stop condition (so the system loops or quits early). Build against all three from the start.
- Share the full trace, not just messages — the fix for conflicting decisions, and the single most important design rule for multi-agent.
- Verify at every step — assert on intermediate outputs, and put a human on anything irreversible.
- Set hard turn and cost budgets — turn a silent runaway into a caught failure.
Each of these has a whole story behind it. Why Do Multi-Agent LLM Systems Fail? breaks down the measured failure modes from 1,600+ real traces; Multi-Agent Simulation shows how to catch them in a sandbox before your users do; and Cost Control in Multi-Agent Systems keeps the 15× token bill from becoming a surprise.
The summary is short. Build one good agent first. Reach for a second only when the task has real parallelism or specialization to exploit. Start with the supervisor pattern because it stays traceable, share the full context, verify every step, and cap the budget. Do that, and a team of agents will do things one never could — without becoming the machine for turning tokens into confusion we started with.
Further reading & references
Was this useful?
Comments
Loading comments…