Skip to content

sandyz1000/rust-langgraph

Repository files navigation

rust-langgraph

Rust redesign of LangGraph — stateful, multi-actor graph execution for LLM applications. Not a line-for-line port; the API is shaped around Rust's ownership model, async traits, and type system.

Quick Start

[dependencies]
langgraph-core = { path = "crates/langgraph-core" }
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
use langgraph_core::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Serialize, Deserialize)]
struct State {
    messages: Vec<String>,
}

async fn greet(state: State, _ctx: ExecutionContext) -> GraphResult<StateUpdate> {
    let mut update = StateUpdate::new();
    update.insert("messages".into(), serde_json::json!(["hello"]));
    Ok(update)
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let mut graph = StateGraph::<State>::new();
    graph.add_node("greet", greet)?;
    graph.add_edge(START, "greet")?;
    graph.add_edge("greet", END)?;

    let app = graph.compile().await?;
    let result = app.invoke(State { messages: vec![] }).await?;
    println!("{:?}", result.messages);
    Ok(())
}

Examples

cargo run --example basic_agent
cargo run --example advanced_workflow
cargo run --example streaming
cargo run --example channels_api
cargo run --example checkpoint

Architecture

See docs/architecture.md for execution model, channels, routing, and checkpointing.

Crates

Crate Purpose
langgraph-core StateGraph, Pregel engine, channels, types
langgraph-checkpoint Checkpointer trait + memory/sqlite/postgres/redis
langgraph-prebuilt ReactAgent, ToolNode, prompt helpers
langgraph-runtime High-level runtime combining core + checkpoint
langgraph-observability Metrics, tracing, web dashboard

Status

Core graph execution, checkpointing, streaming, interrupt/resume, and the channels API are working. See docs/missing-features.md for planned additions (barrier channels, delta channel, func API, store, remote graph, ToolNode/ReactAgent).

License

MIT

About

Composable, stateful, and streaming AI agent workflows in Rust.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors