[
][documentation]
[
][snapshots] [
][releases]
LangGraph for Java. A library for building stateful, multi-agents applications with LLMs, built for work with [langchain4j] and [Spring AI]
It is inspired by [LangGraph] solution, part of [LangChain AI project].
‼️ the repo has been updated to 1.9, the version 1.8 has been moved to the branch support/1.8.x..
Take a look to What's new in release 1.9
| Date | Release | info |
|---|---|---|
| Oct 24, 2026 | 1.9.7 |
last release |
| Release line | Java baseline | Notes |
|---|---|---|
| 1.9.x | Java 17+ | Release with new (experimental) features and improvements for preparing move to 2.0 |
1.9-SNAPSHOT development builds |
Java 17+ | Snapshot users should expect active development and pre-release changes |
1.8.x LTS release |
Java 17+ | This release will be maintained for LTS support in branch support/1.8.x. Only bugfix and/or minor improvement |
Welcome to LangGraph4j! This guide will help you understand the core concepts of LangGraph4j, install it, and build your first application.
LangGraph4j is a Java library for building stateful, multi-agent applications with Large Language Models (LLMs). It is inspired by the Python library LangGraph and is designed to work seamlessly with popular Java LLM frameworks like Langchain4j and Spring AI.
At its core, LangGraph4j allows you to define cyclical graphs where different components (agents, tools, or custom logic) can interact in a stateful manner. This is crucial for building complex applications that require memory, context, and the ability for different "agents" to collaborate or hand off tasks.
LangGraph4j offers several features and benefits:
| Pattern | Best for | Main abstraction | Start here |
|---|---|---|---|
| First graph / linear flow | Learning the core execution model | StateGraph, normal edges, shared state |
## Your First Graph - A Simple Example |
| Conditional routing | Router-style decisions and dynamic control flow | Conditional edges | ### Edges |
| Stateful checkpointed flow | Long-running or resumable workflows | CheckpointSaver, CompileConfig |
### Checkpoints (Persistence) |
| Framework-integrated agents | Using LangGraph4j with Java AI frameworks | LangChain4j / Spring AI integrations | ## BONUS: built-in integrations |
| Visual debugging and inspection | Observing and iterating on graphs interactively | Studio | ## Studio 🤩 - Running Your Graph visually |
Understanding these concepts is key to using LangGraph4j effectively:
StateGraph<S extends AgentState>The StateGraph is the primary class you'll use to define the structure of your application. It's where you add nodes and edges to create your graph. It is parameterized by an AgentState.
AgentStateThe AgentState (or a class extending it) represents the shared state of your graph. It's essentially a map (Map<String, Object>) that gets passed from node to node. Each node can read from this state and return updates to it.
Map<String, Channel.Reducer>. Each key in the map corresponds to an attribute in the state.Channel.Reducer: A reducer defines how updates to a state attribute are handled. For example, a new value might overwrite the old one, or it might be added to a list of existing values.Channel.Default<T>: Provides a default value for a state attribute if it's not already set.Channel.Appender<T> / MessageChannel.Appender<M>: A common type of reducer that appends the new value to a list associated with the state attribute. This is useful for accumulating messages, tool calls, or other sequences of data. MessageChannel.Appender is specifically designed for chat messages and can also handle message deletion by ID.NodesNodes are the building blocks of your graph that perform actions. A node is typically a function (or a class implementing NodeAction<S> or AsyncNodeAction<S>) that:
1. Receives the current AgentState as input.
2. Performs some computation (e.g., calls an LLM, executes a tool, runs custom business logic).
3. Returns a Map<String, Object> representing updates to the state. These updates are then applied to the AgentState according to the schema's reducers.
Nodes can be synchronous or asynchronous (CompletableFuture).
EdgesEdges define the flow of control between nodes.
addEdge(sourceNodeName, destinationNodeName).AgentState. After a source node completes, an EdgeAction<S> (or AsyncEdgeAction<S>) function is executed. This function receives the current state and returns the name of the next node to execute. This allows for branching logic (e.g., if an agent decided to use a tool, go to the "execute_tool" node; otherwise, go to the "respond_to_user" node). Conditional edges are defined with addConditionalEdges(...).addConditionalEntryPoint(...).CompilationOnce you've defined all your nodes and edges in a StateGraph, you compile() it into a CompiledGraph<S extends AgentState>. This compiled graph is an immutable, runnable representation of your logic. Compilation validates the graph structure (e.g., checks for orphaned nodes).
Checkpoints (Persistence)LangGraph4j allows you to save (Checkpoint) the state of your graph at any step. This is extremely useful for:
* Debugging: Inspect the state at various points to understand what happened.
* Resuming: Restore a graph to a previous state and continue execution.
* Long-running processes: Persist the state of long-running agent interactions.
You'll typically use a CheckpointSaver implementation (e.g., MemorySaver for in-memory storage, or you can implement your own for persistent storage).
Useful starting points for persistence:
langgraph4j-mysql-saver/README.md for MySQL-backed checkpointslanggraph4j-postgres-saver/README.md for PostgreSQL-backed checkpointslanggraph4j-redis-saver/README.md for Redis-backed checkpointslanggraph4j-mongodb-saver/README.md for MongoDB-backed checkpointsIf you only want to see the minimal integration point first, look for CompileConfig.builder().checkpointSaver(...) in the saver module examples before diving into the full storage details.
``` langgraph4j/ ├── langgraph4j-bom/ # LangGraph4j dependency management ├── langgraph4j-core/ # LangGraph4j core components ├── langgraph4j-opentelemetry/ # LangGraph4j Hook & OpenTelemetry integration module ├── langgraph4j-mysql-saver # LangGraph4j persistent checkpoint saver based on MySQL ├── langgraph4j-oracle-saver # LangGraph4j persistent checkpoint saver based on OracleDB ├── langgraph4j-postgres-saver # LangGraph4j persistent checkpoint saver based on PostgresSQL ├── langgraph4j-dynamodb-saver # LangGraph4j persistent checkpoint saver based on Amazon DynamoDB ├── langgraph4j-cockroachdb-saver # LangGraph4j persistent checkpoint saver based on CockroachDB ├── langgraph4j-mongodb-saver # LangGraph4j persistent checkpoint saver based on MongoDB ├── langgraph4j-redis-saver # LangGraph4j persistent checkpoint saver based on
| 日期 | 榜单 | 排名 | 周期新增 | 总 STAR |
|---|