Skip to main content

LangGraph: An Agent Framework from LangChain ecosystem

Full framework comparison: Guide to choosing a framework

LangGraph is an open‑source Python framework from the LangChain ecosystem designed specifically for building stateful, multi‑step AI agents and complex workflow applications. It moves beyond simple “prompt → response” chains and gives you a graph‑based execution model where state flows through nodes and edges, enabling branching, loops, human approval, tool calling, and persistent memory. If you need an agent that can pause for a human review, resume a week later, or coordinate a dozen tools over multiple steps, LangGraph is the engine for that job.

This article serves as the entry point to the LangGraph section of the AgentDevPro Handbook. It explains what LangGraph is, why it was created, its key capabilities, when to use it, and how to navigate the rest of the learning path.

What Is LangGraph

LangGraph is a stateful agent framework. It represents a workflow as a directed graph where:

  • State – a shared data structure (a TypedDict or Pydantic model) that holds the entire context.
  • Nodes – Python functions that receive the current state and return an updated state.
  • Edges – rules that determine which node executes next. Edges can be unconditional (always go to node X) or conditional (evaluate a function that returns the next node).

LangGraph’s runtime engine walks the graph, executing nodes and persisting state at every step. You can attach a checkpointer to make the graph durable: if the process crashes or you need to wait for human input, the current state is saved and can be resumed later with the same thread_id.

A minimal example – a two‑step agent that classifies intent and then calls a tool:

from typing import TypedDict, Annotated
from langgraph.graph import StateGraph, START, END
from langgraph.graph.message import add_messages

class AgentState(TypedDict):
messages: Annotated[list, add_messages]

def intent_node(state: AgentState):
# LLM call to classify intent
return {"messages": [("ai", "Intent: refund")]}

def tool_node(state: AgentState):
# Execute a tool
return {"messages": [("ai", "Tool result: ...")]}

builder = StateGraph(AgentState)
builder.add_node("intent", intent_node)
builder.add_node("tool", tool_node)
builder.add_edge(START, "intent")
builder.add_edge("intent", "tool")
builder.add_edge("tool", END)

graph = builder.compile()
result = graph.invoke({"messages": [("user", "I want a refund")]})

LangGraph doesn’t prescribe how you use LLMs; it integrates seamlessly with LangChain but works equally well with direct API calls. The framework provides the execution control; you provide the business logic.

Why LangGraph Was Created

Traditional agent implementations often relied on custom loops or rigid chains (like LangChain’s LCEL) that could handle linear flows but struggled with:

  • Complex workflows – real‑world processes have branches, loops, and dynamic routing that require explicit control flow.
  • State management – maintaining and updating a rich state across multiple LLM calls and tool invocations is error‑prone without a framework.
  • Agent coordination – orchestrating multiple tools, LLM calls, and human approvals demands a reliable scheduling mechanism.
  • Human‑in‑the‑loop – pausing execution, waiting for human input, and resuming without losing context is inherently stateful.
  • Production reliability – long‑running agents need to survive crashes, be resumable, and be fully observable.

LangGraph addresses these by providing a graph‑based execution runtime with built‑in checkpointing. It separates the “what should happen next” (edges) from “what does a step do” (nodes), making complex workflows explicit, testable, and maintainable. The checkpointer gives you durability for free—if the agent is interrupted, the state is safe and resumable.

Key Features of LangGraph

FeatureDescription
Graph‑based workflowsDefine nodes and edges to build any topology—sequential, branching, parallel, looping.
Stateful executionA typed state object flows through the graph, accumulating messages, tool results, and custom data.
CheckpointingAutomatically persists the state after every node. Resume from any thread with the same ID.
Human‑in‑the‑loopPause execution at any node using interrupt, then resume with human input.
Tool callingFirst‑class support for binding tools to LLMs and routing tool calls to dedicated execution nodes.
StreamingStream intermediate states and outputs in real time (sync or async).
PersistencePluggable checkpointer backends: in‑memory, SQLite, Postgres, or custom.
ObservabilityIntegrates with LangSmith, Langfuse, and OpenTelemetry for full tracing.
Dynamic routingNodes can return a Command to override the next step, enabling adaptive workflows.

These features combine to create a framework that handles the messy reality of agentic applications.

How LangGraph Works

The execution model is a continuous loop of state → node → edge → next node. The runtime starts at the START node and follows edges until it reaches END.

  • State is the single source of truth. Every node reads and writes it. After a node returns an update, the runtime merges it into the state.
  • Nodes are Python functions. They can call LLMs, tools, or any logic.
  • Edges define transitions. Normal edges are fixed; conditional edges call a routing function with the current state and return the next node name.
  • Checkpointer (optional) serialises the state after each step, enabling pause/resume and crash recovery.

The graph runs until it hits an END condition or a recursion limit. This deterministic loop makes the entire execution traceable and reproducible.

LangGraph Core Components

ComponentRole
StateA typed dictionary (TypedDict) or Pydantic model that holds all data passing through the graph.
NodesFunctions (state) → state_update. The business logic of your agent.
EdgesRules that determine the next node: add_edge(from, to) or add_conditional_edges(from, router, path_map).
GraphThe StateGraph class that assembles nodes and edges, then compile()s into a runnable object.
Execution EngineThe compiled graph’s runtime that manages state flow, checkpointing, and resumption.
CheckpointerA persistent store for state snapshots (MemorySaver, SqliteSaver, PostgresSaver).

Understanding these six components is enough to build any agent. The handbook’s Core Concepts article dives deep into each.

LangGraph Ecosystem

LangGraph lives inside a rich ecosystem that enhances its capabilities.

  • LangChain – Provides the LLM abstractions, chat models, and tool interfaces that nodes often use.
  • LangSmith – A platform for tracing, debugging, and evaluating LangGraph agents.
  • MCP Integration – Connect to any Model Context Protocol server to use external tools and resources.
  • Tool Ecosystem – Use pre‑built tools from LangChain and langgraph.prebuilt.ToolNode, or define your own with @tool.

You can use LangGraph with or without LangChain, but the two together form a powerful combination for rapid agent development.

When to Use LangGraph

LangGraph shines when your agent needs more than a single turn.

ScenarioWhy LangGraph
Research agentsMulti‑step web search, document retrieval, and synthesis require a loop.
Coding assistantsGenerate code → run tests → fix errors → re‑test.
Workflow automationConditional branching (if order > $1000, get manager approval).
Human review systemsPause after draft generation, wait for human edit, then proceed.
Long‑running agentsAgents that take minutes/hours and must survive restarts.
Multi‑tool coordinationInterleave LLM reasoning with API calls, database queries, and code execution.

Essentially, if your workflow has more than one step and requires control flow, LangGraph is a strong candidate.

When Not to Use LangGraph

For simpler tasks, LangGraph can be overkill.

  • Small projects – A single‑prompt script might be enough.
  • Simple chatbots – A basic LangChain chain or a single LLM call with memory may suffice.
  • Single‑step workflows – If the entire agent is one call, the graph structure adds unnecessary complexity.

For rapid prototyping of role‑based multi‑agent systems where you want to think in terms of “agents and tasks” rather than “nodes and edges”, consider CrewAI as an alternative. The framework comparison guide can help you choose.

LangGraph Learning Path

The AgentDevPro Handbook provides a structured path to mastery. Each article is implementation‑focused and builds on the previous one.

Core Concepts

Start here – understand state, nodes, edges, and graph execution. This is the foundation.

Memory

Go to Memory – learn checkpointing, state persistence, and resumption. Essential for production agents.

Tool Calling

Explore Tool Calling – integrate external functions and APIs, handle tool routing and errors.

Workflows

Design Workflows – build sequential, conditional, parallel, and looping workflows with real‑world patterns.

Human‑in‑the‑Loop

Implement HITL – pause execution, wait for human input, and resume seamlessly.

MCP Integration

Connect to MCP – use standardized tool servers to expand your agent’s capabilities.

Production

Deploy to Production – scaling, observability, reliability, cost control, and security.

Follow this path sequentially, or jump to the topic you need most. Each article is self‑contained but cross‑referenced for deeper context.

LangGraph vs Other Frameworks

FrameworkApproachFlexibilityLearning CurveProduction Readiness
LangGraphStateful graph (nodes + edges)Very high – any topology, custom logicModerate – need to understand graph modelExcellent – built‑in checkpointing, streaming, LangSmith
CrewAIRole‑based, task‑drivenMedium – sequential/hierarchical processesLow – intuitive, declarativeGood – memory, caching, human‑in‑the‑loop
AutoGenConversational multi‑agent chatHigh – dynamic conversationsModerate – event‑driven, actor modelGrowing – strong research adoption
OpenAI Agents SDKLightweight agent runnerLow‑medium – simple agent definitionsLow – OpenAI‑centricGood for simple agents, but lacks built‑in persistence
Semantic KernelEnterprise plugin architectureMedium – plugin‑basedModerate – .NET/Python, deep integrationEnterprise‑focused

LangGraph’s strength is control. When you need explicit graph topology, dynamic routing, and robust checkpointing, it’s the tool of choice. For simpler role‑based collaboration, CrewAI might be faster to build. For chat‑heavy, dynamic group conversations, AutoGen can be more natural.

For a detailed analysis, visit the framework comparison guide.

Common LangGraph Use Cases

Real‑world applications of LangGraph include:

  • Customer Support Agent – Intent classification, knowledge retrieval, conditional escalation to human, full traceability.
  • Research Agent – Multi‑source search, cross‑referencing, summarisation, and report generation in a loop.
  • Coding Assistant – Generate code, run static analysis, execute in sandbox, iterate on errors.
  • Business Workflow Automation – Ingest a document, extract data, validate against rules, trigger downstream actions.
  • Internal Enterprise Tools – HR onboarding agent that files forms, checks policies, and gets manager approval.

These are not hypothetical; teams run LangGraph agents in production across all these domains.

Common Beginner Mistakes

  • Overusing graph complexity – A 20‑node graph for a simple chatbot is a maintenance nightmare. Start with the minimum.
  • Ignoring state design – Poorly structured state leads to spaghetti data. Use TypedDict or Pydantic with clear fields.
  • Poor node separation – Mixing business logic with routing decisions inside a single node makes debugging hard.
  • Missing checkpoint strategies – Using in‑memory checkpointer in production loses all state on restart.
  • Forgetting recursion limits – Loops without a clear exit condition can burn through tokens. Always set recursion_limit.

The handbook’s individual articles provide deeper guidance on avoiding these pitfalls.

Best Practices Overview

  • Keep state minimal – Only persist what downstream nodes need.
  • Build reusable nodes – Write nodes that are independent of the graph’s topology; they can be composed into different workflows.
  • Use checkpoints – Even for development, a persistent checkpointer helps you understand the state at each step.
  • Monitor execution – Integrate with LangSmith or add logging from day one. You’ll need it when things go wrong.
  • Log tool calls – Record tool name, arguments (sanitised), and results for debugging and audit.
  • Design for idempotency – Ensure tool calls can be safely re‑executed if the graph resumes from a checkpoint.
  • Start simple, then add branches – Get the linear flow working, then introduce conditionals.

FAQ

1. What is LangGraph?

LangGraph is an open‑source framework for building stateful, graph‑based AI agents and workflows. It models execution as nodes and edges, with built‑in checkpointing and resumption.

2. Is LangGraph part of LangChain?

LangGraph is developed by the same team that created LangChain, but it is a separate library. It integrates tightly with LangChain but can be used independently.

3. Is LangGraph production‑ready?

Yes. LangGraph includes persistent checkpointers (SQLite, Postgres), streaming, human‑in‑the‑loop, and integrations with LangSmith for observability—all designed for production use.

4. Does LangGraph support MCP?

Yes, through the langchain-mcp-adapters package. You can load tools from MCP servers and use them in your graph like any other tool.

5. Is LangGraph suitable for beginners?

LangGraph has a moderate learning curve because it requires understanding state graphs. However, the handbook’s Core Concepts article starts from scratch. If you’re comfortable with Python and basic LLM concepts, you can get productive quickly.

6. When should I choose LangGraph over CrewAI?

Choose LangGraph when you need fine‑grained control over execution flow (loops, dynamic routing) or must persist state for long‑running processes. Choose CrewAI when you prefer a simpler role‑based, task‑driven abstraction without writing explicit graph logic.

7. How does LangGraph handle state across multiple users?

Each user (or session) is identified by a unique thread_id. The checkpointer stores state per thread, so multiple users can be served concurrently without state mixing.

8. Can I use LangGraph without LangChain?

Yes. Nodes can use any Python code, including direct calls to OpenAI, Anthropic, or other APIs. LangChain just provides convenient wrappers.

9. What Python versions does LangGraph support?

LangGraph supports Python 3.9 and above. Always check the official documentation for the latest compatibility.

10. How do I deploy a LangGraph agent?

The most common pattern is to wrap the compiled graph in a FastAPI (or similar) endpoint inside a Docker container, with a persistent checkpointer (Postgres). The Production article covers deployment in detail.

11. Does LangGraph support async execution?

Yes. You can compile graphs with async nodes and use ainvoke and astream. The checkpointer also works asynchronously.

12. How do I debug a LangGraph graph?

Use graph.stream() to see step‑by‑step events. Enable verbose logging, and integrate with LangSmith for a full trace. The Core Concepts article includes debugging tips.

13. Can I pause a graph and resume it later?

Yes, using the interrupt function and a persistent checkpointer. This is the foundation of human‑in‑the‑loop and long‑running workflows. The HITL article explains it in detail.

14. What is the relationship between LangGraph and LangSmith?

LangSmith is a companion platform for tracing, evaluating, and monitoring LLM applications. LangGraph can send its execution traces to LangSmith, giving you a full visual timeline of every node, tool call, and state change.

15. Are there any costs associated with LangGraph?

The library itself is open‑source and free. Costs come from the LLM calls and tool usage your agent makes, plus any infrastructure (e.g., Postgres for checkpointing). LangSmith has a free tier and paid plans.

16. Where can I find examples?

The LangGraph documentation includes many examples. The AgentDevPro Handbook also contains practical, end‑to‑end examples in each article.

Conclusion

LangGraph is the framework of choice for developers who need to build reliable, complex, stateful AI agents. By modelling workflows as graphs with explicit state and edges, it gives you unparalleled control over execution flow, while built‑in checkpointing, human‑in‑the‑loop, and streaming make it production‑ready out of the box.

In this introduction you’ve learned:

  • What LangGraph is and why it was created.
  • How its graph‑based, stateful execution model works.
  • The core components: state, nodes, edges, graph, and checkpointer.
  • When to use LangGraph (and when not to).
  • How it compares to other frameworks like CrewAI and AutoGen.
  • A learning path to take you from novice to production expert.

Now, take the first step:

LangGraph Core Concepts – understand state, nodes, edges, and graph execution. This is the foundation for everything else.

From there, you can explore the entire LangGraph section of the AgentDevPro Handbook, including:

For a broader perspective, check out the framework comparison guide and our MCP Guide for tool ecosystems. If you’re ready to start building agents that think, act, and remember—LangGraph is your engine.