Library of the Week — LangGraph
A weekly teardown of one open-source AI/ML library: what it does, why it stands out, and when to use it.
LangGraph — stateful, graph-based orchestration for LLM agents and multi-step workflows
GitHub · Language: Python (TypeScript also supported) · License: MIT
What it does
LangGraph lets you build LLM workflows as explicit directed graphs where nodes are functions and edges encode control flow — including cycles, which most DAG-based frameworks prohibit. It’s aimed at developers who need durable, stateful agent loops rather than one-shot chains: think multi-agent systems, human-in-the-loop approval flows, or long-running task automation.
Why it stands out
- First-class cycles and branching — unlike linear pipeline tools, LangGraph’s graph structure natively supports loops (retry, reflect, re-plan), making it the honest choice for agentic patterns rather than a workaround
- Persistent, checkpointed state — built-in checkpointers (SQLite, Postgres) let an agent pause, resume, or be inspected mid-run; essential for production workflows that need fault tolerance or human review gates
- Streaming at every node — token-level and node-level streaming are both exposed, so you can pipe partial results to a UI without waiting for the full graph to complete
- LangGraph Platform (optional) adds deployment, a visual debugger, and a studio UI — useful for teams, though the core library is fully usable without it
Quick start
from langgraph.graph import StateGraph, END
from typing import TypedDict
class State(TypedDict):
messages: list[str]
count: int
def increment(state: State) -> State:
return {"count": state["count"] + 1, "messages": state["messages"]}
def should_stop(state: State) -> str:
return END if state["count"] >= 3 else "increment"
builder = StateGraph(State)
builder.add_node("increment", increment)
builder.set_entry_point("increment")
builder.add_conditional_edges("increment", should_stop)
graph = builder.compile()
result = graph.invoke({"messages": [], "count": 0})
print(result["count"]) # 3
When to use it
- You’re building an agent that needs to loop — re-plan on failure, reflect before answering, or iterate until a condition is met
- You need human-in-the-loop checkpoints where a workflow can pause and wait for approval before proceeding
- You’re coordinating multiple specialized agents and need explicit, auditable handoff logic rather than a single monolithic agent prompt
When to skip it
- For simple, linear RAG pipelines or single-shot tool-use, LangGraph’s graph setup is overhead — a plain function or a lighter framework like Mirascope is faster to ship
- The LangChain ecosystem dependency can feel heavy if you want something self-contained; frameworks like Pydantic AI or raw async Python are lower-footprint alternatives for smaller scopes
Security note
The checkpointer persistence layer highlighted above had a disclosed remote-code-execution chain in 2026: a SQL injection in the SQLite checkpointer (CVE-2025-67644) that chains with an unsafe msgpack deserialization (CVE-2026-28277) to execute arbitrary code. It affects self-hosted deployments using the SQLite or Redis checkpointer that expose get_state_history() with a user-controlled filter; LangChain’s managed Postgres (LangSmith Deployment) is not affected. It’s fixed — upgrade to langgraph 1.0.10+, langgraph-checkpoint-sqlite 3.0.1+, and langgraph-checkpoint-redis 1.0.2+, and don’t pass untrusted input into checkpoint metadata filters. (Check Point Research)
The verdict
LangGraph occupies a real gap: it’s one of the few production-ready libraries that takes cycles seriously as a first-class primitive, which is what actual agent loops require. The checkpointing story is genuinely useful once you’re running workflows that take more than a few seconds. If you’re past the prototype stage and your agents are starting to need memory, branching, and fault recovery, LangGraph is worth the learning curve.