LangGraph is a library from the LangChain team for building stateful, multi-step AI agent workflows modeled as directed graphs. Unlike linear pipelines, LangGraph workflows can cycle - an agent can reason, take an action, observe the result, and decide whether to continue or loop back - enabling more sophisticated agent behavior than sequential chains allow.

Why Graphs for Agents

The fundamental limitation of sequential pipeline frameworks is that they cannot express feedback loops. An agent that searches for information, evaluates whether it found enough, and decides to search again if not - this requires a cycle in the execution graph. LangGraph makes cycles first-class.

This matters because real agent tasks are iterative: code generation requires testing and fixing, research tasks require evaluating source quality and following up on gaps, data analysis requires checking intermediate results before proceeding.

Core Concepts

State - A typed dictionary shared across all nodes in the graph. Each node reads the current state, performs work, and returns updates to the state. State is the source of truth for the execution.

Nodes - Functions (or LLM chains) that perform a specific step: call an LLM, execute a tool, evaluate a condition. Each node receives the current state and returns state updates.

Edges - Define transitions between nodes. Conditional edges use a function to determine the next node based on the current state, enabling branching and looping.

Checkpointing - LangGraph supports persisting state at each step, enabling long-running agents that can pause and resume, human-in-the-loop review at decision points, and recovery from failures without restarting from scratch.

Common Patterns

ReAct agent - The standard Reason-Act pattern: an LLM reasons about what to do, calls a tool, observes the result, and loops back to reason about the next action. This is LangGraph’s simplest production-ready pattern and covers most single-agent use cases.

Plan-and-execute - A planning node generates a multi-step plan, then an execution subgraph executes each step. The plan can be updated mid-execution if earlier steps reveal that the plan needs revision.

Human-in-the-loop - An interrupt node pauses execution and surfaces the current state to a human reviewer. Execution resumes when the reviewer approves, modifies the plan, or rejects the current path. Useful for high-stakes decisions (financial transactions, external communications) where automated approval is not appropriate.

Multi-agent supervisor - A supervisor LLM node routes tasks to specialized sub-agents and collects their outputs. LangGraph models each sub-agent as a subgraph.

Comparison with CrewAI

Both frameworks enable multi-agent AI systems, but they differ in philosophy:

  • LangGraph is more explicit - you define the graph structure in code, which nodes connect to which, and what state passes between them. More verbose but more predictable and debuggable.
  • CrewAI is more declarative - you describe agents and tasks in natural language and the framework handles coordination. Faster to prototype but less transparent about execution flow.

For production systems requiring fine-grained control over execution flow, error handling, and state management, LangGraph’s explicit model is typically preferable.

Integration

LangGraph integrates with LangChain’s tool ecosystem (hundreds of pre-built tool integrations) and all major LLM backends. LangSmith provides tracing and debugging for LangGraph executions, making it practical to trace multi-step agent behavior in production.

For AWS-deployed applications, LangGraph agents can use Bedrock as the LLM backend via LangChain’s Bedrock integration, keeping LLM calls within AWS infrastructure.