LangGraph

Active
GitHub Python MIT

Description

LangGraph is an agent workflow orchestration framework from the LangChain team, using graph structures to model agent state and transitions.

Key Features

  • Stateful agent orchestration — Define agent state, conditional branching and loops using graph structures for persistent workflows
  • Durable execution — Agents persist through failures and automatically resume from exactly where they left off
  • Human-in-the-loop — Insert human review at any node to inspect and modify agent state before continuing
  • Short and long-term memory — Working memory for current reasoning plus persistent memory across sessions
  • LangSmith debugging — Trace execution paths, capture state transitions, and get detailed runtime metrics via visualization
  • Production-ready deployment — Scalable infrastructure designed for long-running stateful workflows in production

Use Cases

💡 Multi-step research agents — Build complex workflows that plan, use subagents, and leverage file systems
💡 Customer service dialogue — Stateful multi-turn conversations with knowledge retrieval, human handoff and session persistence
💡 Data processing pipelines — Orchestrate ETL workflows with graph structures supporting branching, error handling, checkpoint recovery
💡 Code generation & verification — Agent generates code, runs tests automatically, iterates fixes until tests pass

Quick Start

pip install -U langgraph

from langgraph.graph import StateGraph, MessagesState, START, END
from langchain_openai import ChatOpenAI

model = ChatOpenAI(model='gpt-4o-mini')

def call_model(state: MessagesState):
    response = model.invoke(state['messages'])
    return {'messages': [response]}

graph = StateGraph(MessagesState)
graph.add_node('agent', call_model)
graph.add_edge(START, 'agent')
graph.add_edge('agent', END)

app = graph.compile()
result = app.invoke({'messages': [('human', 'Hello!')]})
print(result['messages'][-1].content)

Related Projects

Related Articles