# langgraph4j
**Repository Path**: git4chen/langgraph4j
## Basic Information
- **Project Name**: langgraph4j
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: develop
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2025-02-16
- **Last Updated**: 2025-03-07
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 🦜🕸️ LangGraph for Java
[][javadocs] [][snapshots] [][releases]
LangGraph for Java. A library for building stateful, multi-agents applications with LLMs, built for work with [langchain4j]
> It is a porting of original [LangGraph] from [LangChain AI project][langchain.ai] in Java fashion
## Features
- [x] StateGraph
- [x] Nodes
- [x] Edges
- [x] Conditional Edges
- [x] Entry Points
- [x] Conditional Entry Points
- [x] State
- [x] Schema (_a series of Channels_)
- [x] Reducer (_how apply updates to the state attributes_)
- [x] Default provider
- [x] AppenderChannel (_values accumulator_)
- [x] delete messages
- [x] Compiling graph
- [x] Async support (_throught [CompletableFuture]_)
- [x] Streaming support (_throught [java-async-generator]_)
- [x] Checkpoints (_save and replay feature_)
- [x] Graph visualization
- [x] [PlantUML]
- [x] [Mermaid]
- [x] Playground (_Embeddable Webapp that plays with LangGraph4j_)
- [x] Threads (_checkpointing of multiple different runs_)
- [x] Update state (_interact with the state directly and update it_)
- [x] Breakpoints (_pause and resume feature_)
- [x] [Studio] (_Playground Webapp_)
- [x] [Spring Boot]
- [x] [Jetty]
- [X] Streaming response from LLM results
- [X] Child Graphs
- [X] Parallel Node Execution
- _With some constraints_
## Releases
**Note: ‼️**
> From release 1.2.x the miminum supported Java version is the `Java 17` and
> the artifact `langgraph4j-core-jdk8` is replaced by `langgraph4j-core`
| Date | Release | info
|--------------|----------------| ---
| Feb 12, 2025 | `1.4.0-beta2` | official release
## Samples
| Project | Integrated With
|--------------|----------------|
[Agent Executor][springai-agentexecutor] | [SpringAI]
[Agent Executor][agent-executor] | [Langchain4j][langchain4j]
[Image To PlantUML Diagram][image-to-diagram] | [Langchain4j][langchain4j]
[Adaptive RAG][adaptive-rag] | [Langchain4j][langchain4j]
## How To(s)
* [How to add persistence ("memory") to your graph][howto-presistence]
* [How to view and update past graph state][howto-timetravel]
## Quick Start
### Adding LangGraph dependency
#### Last stable version
**Maven**
```xml
org.bsc.langgraph4j
langgraph4j-core
1.4.0-beta2
```
#### Development Version
**Maven**
```xml
org.bsc.langgraph4j
langgraph4j-core
1.4-SNAPSHOT
```
### Define the agent state
The main type of graph in `langgraph` is the `StatefulGraph`. This graph is parameterized by a state object that it passes around to each node.
Each node then returns operations to update that state. These operations can either SET specific attributes on the state (e.g. overwrite the existing values) or ADD to the existing attribute.
Whether to set or add is described in the state's schema provided to the graph. The schema is a Map of Channels, each Channel represent an attribute in the state. If an attribute is described with an `AppendeChannel` it will be a List and each element referring the attribute will be automaically added by graph during processing. The State must inherit from `AgentState` base class (that essentially is a `Map` wrapper).
```java
public class AgentState {
public AgentState( Map initData ) { ... }
public final java.util.Map data() { ... }
public final Optional value(String key) { ... }
public final T value(String key, T defaultValue ) { ... }
public final T value(String key, Supplier defaultProvider ) { ... }
}
```
### Define the nodes
We now need to define a few different nodes in our graph. In `langgraph`, a node is an async/sync function that accept an `AgentState` as argument and returns a (partial) state update. There are two main nodes we need for this:
1. **The agent**: responsible for deciding what (if any) actions to take.
1. **A function to invoke tools**: if the agent decides to take an action, this node will then execute that action.
```java
/**
* Represents an asynchronous node action that operates on an agent state and returns state update.
*
* @param the type of the agent state
*/
@FunctionalInterface
public interface AsyncNodeAction extends Function>> {
CompletableFuture