Single-prompt agents fall over once a task needs distinct skills. LangGraph models the workflow as a typed state graph: a router decides which specialist runs next, each node owns one job.
graph TD;
Q[Query] --> R{Router};
R -->|retrieve| V[Vector search];
R -->|answer| A[Answer];
V --> A;
A --> D([Done]);from langgraph.graph import StateGraph, END
graph = StateGraph(AgentState)
graph.add_node("router", route)
graph.add_node("retrieve", retrieve)
graph.add_node("answer", answer)
graph.add_conditional_edges("router", pick_next, {"retrieve": "retrieve", "answer": "answer", "done": END})
app = graph.compile()Where it breaks
Shared mutable state across agents is the usual culprit. Keep node outputs additive and validate the state shape at each edge.
Each stage is independently testable.