LangGraph
ActiveDescription
LangGraph is a framework for building controllable, debuggable, long-running stateful agents, expressing agent state and control flow as a graph.
Key Features
- Graph-based orchestration — nodes, edges and conditional branches describe agent flow more flexibly than linear chains
- Persistence & time travel — built-in checkpointers enable resume and state replay
- Human-in-the-loop — interrupt primitives let agents pause for human confirmation at key steps
- Parallelism & subgraphs — parallel branches, Send and nested subgraphs for complex workflows
- LangSmith integration — deep integration with LangSmith for tracing, debugging and evaluation
- Multi-language SDKs — Python and TypeScript SDKs available
Use Cases
Categories
Quick Start
# Install dependencies
pip install langgraph langchain-openai
# Define a tool-using graph
from langgraph.graph import StateGraph, MessagesState, START, END
from langgraph.prebuilt import ToolNode
from langchain_openai import ChatOpenAI
def call_model(state: MessagesState):
model = ChatOpenAI(model='gpt-4o').bind_tools([search])
return {'messages': [model.invoke(state['messages'])]}
def should_continue(state):
return 'tools' if state['messages'][-1].tool_calls else END
graph = StateGraph(MessagesState)
graph.add_node('agent', call_model)
graph.add_node('tools', ToolNode([search]))
graph.add_edge(START, 'agent')
graph.add_conditional_edges('agent', should_continue)
graph.add_edge('tools', 'agent')
app = graph.compile()
app.invoke({'messages': [('user', 'What is LangGraph?')]})