langgraph4j/langgraph4j

🚀 LangGraph for Java is a library for Graph Engineering, designed to build sophisticated AI agentic architectures within the Java ecosystem. It works seamlessly with both Langchain4j and Spring AI.

What it solves

LangGraph4j provides a way to build complex, stateful, multi-agent AI applications in Java. It solves the limitation of traditional linear workflows by allowing developers to create cyclical graphs where agents, tools, and custom logic can interact, loop back for retries or clarifications, and maintain shared memory across the entire process.

How it works

The library uses a graph-based architecture where developers define a StateGraph consisting of:

  • Nodes: Functional units that perform actions (like calling an LLM or executing a tool) and return updates to a shared state.
  • Edges: Transitions between nodes. These can be "normal" (unconditional) or "conditional" (dynamic routing based on the current state).
  • AgentState: A shared map of data passed between nodes, managed by "reducers" that determine how new data is merged or appended to existing state.
  • Compilation: The graph is compiled into an immutable CompiledGraph for execution.

Who it’s for

Java developers building agentic AI workflows who want a structured way to manage state and control flow, particularly those already using frameworks like LangChain4j or Spring AI.

Highlights

  • Cyclical Workflows: Supports loops, which are essential for agentic behavior like self-correction and iterative refinement.
  • State Persistence: Includes CheckpointSaver implementations for MySQL, PostgreSQL, Redis, DynamoDB, and more, allowing graphs to be paused, resumed, or debugged.
  • Visual Tools: Features a Studio web UI for visual inspection and debugging, and supports graph visualization via PlantUML or Mermaid.
  • Framework Integration: Built-in support for LangChain4j and Spring AI.
  • Async Support: Native support for asynchronous operations and streaming results.

Related

  • Project
  • Project
  • Project
  • Project
  • Project