langgraph-rust
A Rust implementation of LangGraph -- a framework for building stateful, multi-actor applications with LLMs.
[!TIP] Featured Project: Check out flock
— a premium multi-agent framework built on top of langgraph-rust!
Table of Contents
- Overview
- Projects Built with langgraph-rust
- Project Structure
- Quick Start
- Supported Providers
- Supported Checkpointers
- Roadmap
- Examples
- Crate Overview
- Requirements
- License
Overview
langgraph-rust brings the core LangGraph concepts into idiomatic Rust:
- StateGraph -- Directed graphs where nodes are async functions that transform state, and edges define control flow
- Pregel Engine -- Bulk Synchronous Parallel (BSP) execution: Plan -> Execute (parallel via tokio) -> Update
- Channels -- Type-erased state containers with reducers, fan-in barriers, and pub-sub semantics
- Checkpointing -- Full state persistence for pause/resume, human-in-the-loop, and time-travel debugging. Supports InMemory, Postgres, and SQLite.
- Tracing & Observability -- Real-time tracing server and UI for visualizing graph execution and LLM calls.
- ReAct Agent -- Prebuilt Reasoning + Acting agent pattern with tool execution.
- OpenAI Provider -- Integration with OpenAI-compatible APIs (GPT-4o, Ollama, vLLM, DeepSeek, etc.).
Projects Built with langgraph-rust
- flock
- A multi-agent framework built on top of langgraph-rust.
Project Structure
langgraph-rust/
├── crates/
│ ├── langgraph/ # Core engine: StateGraph, Pregel BSP, Channels, Streaming
│ ├── langgraph-derive/ # Proc macros: #[derive(StateGraph)], #[tool], #[derive(Traceable)]
│ ├── langgraph-prebuilt/ # Prebuilt components: ReAct agent, ToolNode, Messages
│ ├── langgraph-checkpoint/ # Checkpointer traits and InMemorySaver
│ ├── langgraph-checkpoint-postgres/ # Postgres persistence via sqlx
│ ├── langgraph-checkpoint-sqlite/ # SQLite persistence via sqlx
│ ├── langgraph-tracing/ # Real-time tracing server and observability
│ ├── langgraph-providers/ # LLM integrations: OpenAI, OpenAI-compatible
│ └── langgraph-prebuilt/ # Prebuilt agents and nodes
└── examples/ # 16 runnable examples covering all features
Quick Start
Installation
Add langgraph to your Cargo.toml:
[]
# Basic core package
= "0.2.0"
# Or enable optional features out-of-the-box:
# langgraph = { version = "0.2.0", features = ["prebuilt", "providers", "sqlite"] }
Cargo Features
The langgraph umbrella crate organizes the ecosystem into separate cargo features:
prebuilt: ReAct agent,ToolNode, message types, and base chat model trait.providers: Model providers integration (OpenAI, compatibility clients).tracing: Tracing server, observer, and telemetry.sqlite: SQLite checkpointer persistence.postgres: PostgreSQL checkpointer persistence.
Configure Environment
Copy .env.example to .env and fill in your specific model information:
Example .env content:
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxx
OPENAI_API_BASE=https://xxxxxxx/v1
OPENAI_MODEL=xxxxxxx
Define a ReAct Agent with Tools
use tool;
use ;
use ;
use RunnableConfig;
use Arc;
// Define tools with the #[tool] macro
async
Build a Custom StateGraph
use *;
use langgraph_state;
use append_reducer;
// Build graph: START -> process -> validate -> END
let channels = create_channels;
let mut graph = new;
graph.add_node?;
graph.add_node?;
graph.add_edge?;
graph.add_edge?;
graph.add_edge?;
let app = graph.compile?;
Human-in-the-Loop
use ;
// In a node function:
// Resume execution:
compiled_graph.update_state;
Supported Providers
| Provider | Status | Notes |
|---|---|---|
| OpenAI | Done | GPT-4o, GPT-4, GPT-3.5, etc. via async-openai |
| OpenAI-compatible | Done | Ollama, vLLM, LiteLLM, Azure OpenAI via custom base_url |
Supported Checkpointers
| Checkpointer | Status | Notes |
|---|---|---|
| InMemorySaver | Done | HashMap-based, for testing and development |
| PostgresSaver | Done | Production-ready via sqlx, with migrations |
| SqliteSaver | Done | Lightweight persistence via sqlx (SQLite) |
Roadmap
Providers
- Anthropic (Claude)
- DeepSeek
- Google Gemini
- Qwen
- Zhipu
Checkpointers
- SQLite Checkpointer
- Redis Checkpointer
Features
- Subgraph support
- More prebuilt agent patterns
Examples
| Example | Description |
|---|---|
react_agent |
ReAct agent with #[tool] macro and create_react_agent |
interactive_chat |
Interactive CLI chat with memory and history |
interactive_chat_with_tracing |
Interactive chat with real-time tracing UI |
sqlite_checkpoint |
Using SQLite for state persistence |
human_in_the_loop |
interrupt() for human approval with Command::resume |
human_in_the_loop_sqlite_checkpoint |
HITL with SQLite storage |
streaming |
Token-by-token streaming with StreamWriter |
time_travel |
get_state_history and fork from checkpoint |
manus_like |
Plan-and-act multi-node agent (planner/executor/replanner) |
graph_with_tools |
Manual graph construction with tools and streaming |
state_graph_derive |
#[derive(StateGraph)] usage |
custom_state_hitl |
HITL with custom state and complex control flow |
parallel_interrupt_hitl |
Parallel execution with interrupts and HITL |
tracing_demos |
Demonstration of tracing capabilities |
langgraph_provider_openai |
Direct usage of the OpenAI provider |
join_edge_test |
Testing graph join edges and complex routing |
Run an example:
# Set your API key
# Optional: custom base URL for Ollama/vLLM
# export OPENAI_API_BASE=http://localhost:11434/v1
Crate Overview
| Crate | crates.io Crate Name | Description |
|---|---|---|
langgraph |
langgraph |
Main Umbrella Crate (Run cargo add langgraph to install the full suite) |
langgraph-core |
langgraph-core-rs |
Core engine: StateGraph, Pregel BSP, Channels, Streaming, Runnable |
langgraph-derive |
langgraph-derive |
#[derive(StateGraph)], #[tool], and #[derive(Traceable)] macros |
langgraph-prebuilt |
langgraph-prebuilt |
ReAct agent, ToolNode, Message types, BaseChatModel trait |
langgraph-checkpoint |
langgraph-checkpoint-rs |
BaseCheckpointSaver, InMemorySaver, InMemoryStore |
langgraph-checkpoint-postgres |
langgraph-checkpoint-postgres-rs |
PostgresSaver via sqlx with migrations |
langgraph-checkpoint-sqlite |
langgraph-checkpoint-sqlite-rs |
SqliteSaver via sqlx for SQLite |
langgraph-tracing |
langgraph-tracing |
Real-time tracing server, event bus, and observers |
langgraph-providers |
langgraph-providers |
OpenAIModel, OpenAICompatModel (Ollama, vLLM, Azure, DeepSeek) |
Requirements
- Rust >= 1.75
- Tokio runtime (full features)
License
MIT