Table of Contents

LangGraph

LangGraph is a graph-based agent orchestration framework from the LangChain team that enables developers to build reliable, stateful AI agents with support for loops, branching, human oversight, and multi-agent coordination. LangGraph 1.0 reached stable release status in 2025, marking its maturation for enterprise deployments.

Unlike linear chain-based systems, LangGraph models agent workflows as directed graphs where nodes represent computation steps and edges define transitions — including conditional routing and cycles.

Core Architecture

LangGraph is built around a graph-based state machine model with three primary components:

Nodes represent discrete tasks, actions, or model calls within the workflow. Each node receives the current state, performs its computation, and returns an updated state.

Edges define transitions between nodes. Edges can be unconditional (always follow) or conditional (route based on state values), enabling complex branching and loop patterns.

State is a shared, persistent object that flows through the graph. State is typed and can include conversation history, intermediate results, tool outputs, and any custom data needed by the workflow.

Key Features

Stateful Execution: Full control over workflow state enables long-running processes, retries, and multi-step decision tracking. State persists across node executions and can be checkpointed.

Cycles and Loops: Unlike DAG-only systems, LangGraph supports cycles — essential for agent-like systems where the model reasons, decides, acts, and iterates repeatedly until a goal is met.

Persistence and Durability: Agents can pause and resume exactly where they left off on failure. The framework supports both short-term working memory for ongoing reasoning and long-term memory across sessions.

Human-in-the-Loop: Developers can insert human checkpoints into workflows, allowing people to review, modify, or approve agent actions before the graph continues execution.

Multi-Agent Orchestration: Multiple specialized agents can operate within a single connected workflow, with conditional routing between them based on task requirements.

Code Example

from langgraph.graph import StateGraph, END
from typing import TypedDict, Literal
 
class AgentState(TypedDict):
    messages: list
    next_step: str
 
def reasoning_node(state: AgentState) -> AgentState:
    # Agent reasons about the current task
    response = llm.invoke(state["messages"])
    return {"messages": state["messages"] + [response],
            "next_step": "tool" if needs_tool(response) else "respond"}
 
def tool_node(state: AgentState) -> AgentState:
    # Execute the tool call
    result = execute_tool(state["messages"][-1])
    return {"messages": state["messages"] + [result],
            "next_step": "reason"}
 
def respond_node(state: AgentState) -> AgentState:
    return {"messages": state["messages"], "next_step": "end"}
 
def router(state: AgentState) -> Literal['tool', 'respond']:
    return state["next_step"]
 
# Build the graph
graph = StateGraph(AgentState)
graph.add_node("reason", reasoning_node)
graph.add_node("tool", tool_node)
graph.add_node("respond", respond_node)
 
graph.set_entry_point("reason")
graph.add_conditional_edges("reason", router, {"tool": "tool", "respond": "respond"})
graph.add_edge("tool", "reason")  # Loop back after tool use
graph.add_edge("respond", END)
 
app = graph.compile()
result = app.invoke({"messages": [user_message], "next_step": "reason"})

Relationship to LangChain

LangGraph is an extension of the LangChain ecosystem that introduces graph-based orchestration. While LangChain excels at prompt chaining, memory management, and document integration for linear workflows, LangGraph handles complex, adaptive workflows requiring cycles, conditional branching, and persistent state.

The broader ecosystem includes:

References

See Also