ScriptsMar 30, 2026·2 min read

LangGraph — Build Stateful AI Agents as Graphs

LangChain framework for building resilient, stateful AI agents as graphs. Supports cycles, branching, persistence, human-in-the-loop, and streaming. 28K+ stars.

TO
TokRepo精选 · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

pip install langgraph
from langgraph.graph import StateGraph, START, END

def chatbot(state):
    return {"messages": [llm.invoke(state["messages"])]}

graph = StateGraph({"messages": list})
graph.add_node("chatbot", chatbot)
graph.add_edge(START, "chatbot")
graph.add_edge("chatbot", END)
app = graph.compile()

Intro

LangGraph is a framework by LangChain for building stateful, multi-actor AI agent applications modeled as graphs. Unlike simple chain-based workflows, LangGraph supports cycles, conditional branching, state persistence, human-in-the-loop interactions, and streaming — essential for production agents. 28,000+ GitHub stars.

Best for: Developers building complex, stateful AI agents that need persistence and human oversight Works with: OpenAI, Anthropic, Google, any LangChain-supported model


Key Concepts

State Graphs

Define agent logic as a directed graph with nodes (functions) and edges (transitions):

graph.add_node("research", research_fn)
graph.add_node("write", write_fn)
graph.add_conditional_edges("research", route_fn, {"done": "write", "more": "research"})

Persistence & Checkpoints

Save and resume agent state across sessions:

from langgraph.checkpoint.memory import MemorySaver
app = graph.compile(checkpointer=MemorySaver())

Human-in-the-Loop

Pause execution for human approval before critical actions:

graph.add_node("approve", interrupt_before=True)

Streaming

Stream intermediate results, tool calls, and token-by-token output.

LangGraph Platform

Deploy agents as scalable APIs with built-in monitoring via LangGraph Cloud.


FAQ

Q: What is LangGraph? A: A LangChain framework for building stateful AI agents as directed graphs, with support for cycles, persistence, human-in-the-loop, and streaming. 28K+ GitHub stars.

Q: Do I need LangChain to use LangGraph? A: LangGraph can work standalone, but integrates seamlessly with LangChain for model providers, tools, and retrievers.


🙏

Source & Thanks

Created by LangChain. Licensed under MIT. langchain-ai/langgraph — 28,000+ GitHub stars

Related Assets