Why LangGraph?
When you need agents that can branch, loop, checkpoint, and recover from errors — LangGraph is the right tool. It models your agent workflow as a directed graph, giving you fine-grained control over state and execution.
Core Concepts
State
Everything in LangGraph flows through a typed state object. This is your source of truth for what the agent knows at any point.
interface AgentState {
messages: BaseMessage[];
currentStep: string;
toolResults: Record<string, unknown>;
humanApprovalPending: boolean;
}Nodes
Nodes are functions that take the current state and return updates to it.
async function researchNode(state: AgentState) {
const result = await doResearch(state.messages);
return { toolResults: { ...state.toolResults, research: result } };
}Edges
Edges define flow between nodes. Conditional edges let you branch based on state.
Multi-Agent Patterns
Supervisor Pattern
One orchestrator agent delegates to specialist agents. Works well for well-defined task categories.
Parallel Execution
Run multiple agents simultaneously and merge their outputs. LangGraph handles this natively with fan-out edges.
Human-in-the-Loop
Pause execution at critical points and wait for human approval. LangGraph's checkpointing makes this resumable.
Common Pitfalls
Streaming
Users expect to see progress in real time. LangGraph supports streaming events out of the box — pipe these to your frontend with Server-Sent Events.
The mental model shift is: stop thinking about code as a call stack, start thinking about it as a state machine. Once that clicks, LangGraph becomes very natural.