<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bartolomeo Sorrentino on Medium]]></title>
        <description><![CDATA[Stories by Bartolomeo Sorrentino on Medium]]></description>
        <link>https://medium.com/@bsorrentino?source=rss-b9c2251c0e92------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*hy9KzC6V_5PRa0yN.</url>
            <title>Stories by Bartolomeo Sorrentino on Medium</title>
            <link>https://medium.com/@bsorrentino?source=rss-b9c2251c0e92------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 01:07:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bsorrentino/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[LangGraph4j Annotations: Organize Graph Behavior with Action Catalogs]]></title>
            <link>https://blog.devgenius.io/langgraph4j-annotations-organize-graph-behavior-with-action-catalogs-88a2e2d2acbb?source=rss-b9c2251c0e92------2</link>
            <guid isPermaLink="false">https://medium.com/p/88a2e2d2acbb</guid>
            <category><![CDATA[langgraph4j]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Bartolomeo Sorrentino]]></dc:creator>
            <pubDate>Wed, 21 Oct 2026 00:00:08 GMT</pubDate>
            <atom:updated>2026-10-23T15:50:17.634Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*jNiDKwtdswJZAH_6.png" /></figure><h3>From graph lambdas to action catalogs</h3><p>When building a workflow with <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a>, I usually start with a few nodes and straightforward transitions. As the workflow grows, the graph definition can become crowded with action implementations, configuration access, and routing logic.</p><p>Moving those actions into separate classes helps. The new annotations provide a convenient way to organize them: <strong>ordinary Java methods become node actions and edge conditions</strong>, grouped into an <strong>Action Catalog</strong>.</p><p>Available from <strong>LangGraph4j 1.9.6</strong>, @NodeAction and @EdgeCondition belong to langgraph4j-core, in the org.bsc.langgraph4j.annotation package. This guide follows the <a href="https://langgraph4j.github.io/langgraph4j/1.9/core/annotations/">official annotations documentation</a>.</p><h3>What an Action Catalog contains</h3><p>An Action Catalog is a Java class implementing the ActionCatalog marker interface. Its public annotated methods describe the available behavior:</p><ul><li>@NodeAction identifies work that produces updates to graph state.</li><li>@EdgeCondition identifies a routing decision, optionally accompanied by state updates.</li></ul><p>ActionCatalogRepository.of(catalog) discovers those methods, including inherited public methods, and adapts them into actions that LangGraph4j can execute.</p><p><strong>The catalog owns behavior; the </strong><strong>StateGraph definition owns the connections.</strong> Registering a catalog does not automatically create a workflow. We still choose which actions become nodes, where execution starts, and how each routing result maps to a destination.</p><p>Both annotations support two optional attributes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fZNyAXT8cI3Zc8P9FTG1dA.png" /></figure><p>An explicit name is useful when the catalog should expose a stable action name even if its Java method is renamed. Give overloaded annotated methods distinct names. Keep names unique within the node actions and within the edge conditions; these are separate lookup maps.</p><h3>An example</h3><p>Let’s build a small document workflow: prepare some text, decide whether review is requested, and optionally mark it as reviewed. We intentionally keep it simple so no LLM or external service is needed than we can focus on how the catalog connects to the graph.</p><h3>Define the catalog</h3><p>We create a new DocumentCatalog class assuming it uses the standard AgentState, so there is no custom state class to introduce first.</p><pre>public final class DocumentCatalog implements ActionCatalog {<br>    // Trims the supplied text and records the executing graph node.<br>    @NodeAction(name = &quot;prepare&quot;, description = &quot;Prepare the document text&quot;)<br>    public Map&lt;String, Object&gt; prepareDocument(<br>            AgentState state, RunnableConfig config) {<br>        // Missing text is allowed in this example and becomes an empty document.<br>        String text = state.&lt;String&gt;value(&quot;text&quot;).orElse(&quot;&quot;);<br><br>        // Return updates for the engine to merge before it evaluates routing.<br>        return Map.of(&quot;text&quot;, text.strip(), &quot;preparedBy&quot;, config.nodeId());<br>    }<br><br>    // Selects a review route and records the decision without mutating state.<br>    @EdgeCondition(description = &quot;Review only when requested&quot;)<br>    public Command route(AgentState state) {<br>        // Omitted needsReview means this example can finish after preparation.<br>        boolean needsReview = state.&lt;Boolean&gt;value(&quot;needsReview&quot;).orElse(false);<br>        String route = needsReview ? &quot;reviewRequired&quot; : &quot;complete&quot;;<br><br>        // These are routing keys; the graph maps them to node IDs or END.<br>        return new Command(route, Map.of(&quot;reviewDecision&quot;, route));<br>    }<br><br>    // Marks the document as reviewed; this example performs no human interaction.<br>    @NodeAction<br>    public Map&lt;String, Object&gt; review(AgentState state) {<br>        return Map.of(&quot;reviewed&quot;, true);<br>    }<br>}</pre><p>There are some details to notice here.</p><ul><li>The @NodeAction annotated methods returns a <strong>partial state update</strong> as required by LangGraph4j node actions classic.</li><li>The @EdgeCondition annotated methods return a Command as required by LangGraph4j classic edge conditions.</li><li>The method prepareDocument is registered as because it has an explicit annotation name. The other methods use their Java names: route and review.</li><li>The route returns a Command that lets the condition record reviewDecision as well as select the next route.</li><li>The review action is deliberately a local marker. A real Human-in-the-Loop review would also need the appropriate interruption, persistence, and resume behavior.</li></ul><h3>Resolve the catalog and connect the graph</h3><p>Let’s build the DocumentWorkflow class alongside the catalog:</p><pre>public final class DocumentWorkflow {<br>    // Builds the workflow and prints the final state for an input requiring review.<br>     public static void main(String[] args) throws Exception {<br>        // Register before resolving names; actions execute on this catalog instance.<br>        final var repository = ActionCatalogRepository.of(new DocumentCatalog());<br><br>        // Define the topology explicitly, mapping each possible routing result.<br>        final var graph = new StateGraph&lt;&gt;(AgentState::new)<br>                .add(repository.node(&quot;prepare&quot;))<br>                .add(repository.node(&quot;review&quot;))<br>                .addEdge(START, &quot;prepare&quot;)<br>                .add(repository.edge(&quot;prepare&quot;, &quot;route&quot;,<br>                        EdgeMappings.builder()<br>                                .to( &quot;review&quot;, &quot;reviewRequired&quot; )<br>                                .toEND( &quot;complete&quot; )<br>                                .build()))<br>                .addEdge(&quot;review&quot;, END)<br>                .compile(); // Resolve action factories before executing the graph.<br><br>        // A fresh invocation requests review and supplies the text to prepare.<br>        graph.stream(<br>                    GraphInput.args(Map.of(<br>                            &quot;text&quot;, &quot;  A document to review.  &quot;,<br>                            &quot;needsReview&quot;, true)),<br>                    RunnableConfig.empty())<br>            .reduce( (a,b) -&gt; b )<br>            .thenAccept( System.out::println );<br><br>    }<br><br>}</pre><p>There are some details to notice here.</p><ul><li>repository.node(&quot;prepare&quot;) and repository.node(&quot;review&quot;) supplies a complete graph node whose ID and action lookup name are the same.</li><li>Similarly, repository.edge(...) supplies a complete conditional edge. Both work with the StateGraph.add(...) methods.</li></ul><p>This gives us a small example to make in evidence how graph definition change using annotations.</p><h3>Reuse an action under another node ID</h3><p>Sometimes, a graph reuses an action while assigning a specific name to the role it plays within a particular workflow. The repository.nodeAction(...) method is provided specifically for this purpose; it retrieves the action factory without assigning a node ID.</p><pre>// Alternative preparation node: graph identity differs from the catalog lookup name.<br>var workflow = new StateGraph&lt;&gt;(AgentState::new)<br>        .addNode(&quot;prepareIncomingDocument&quot;, repository.nodeAction(&quot;prepare&quot;))<br>        .addEdge(START, &quot;prepareIncomingDocument&quot;)<br>        .addEdge(&quot;prepareIncomingDocument&quot;, END);</pre><p>This fragment replaces the earlier definition and uses the same repository. After compilation, prepareIncomingDocument node would contain prepare action bound with prepareDocument method in action catalog.</p><p>That distinction is useful when an action appears in several workflows, or more than once within a graph. Catalog names identify reusable behavior; graph node IDs identify its position in a particular workflow.</p><p>The <a href="https://langgraph4j.github.io/langgraph4j/1.9/core/annotations/">official guide</a> also discusses a singular edgeAction(...) accessor with details on its usage</p><h3>Other supported method shapes</h3><p>The example uses synchronous methods, but catalogs also support asynchronous work and node construction during compilation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTSVAasjvNvNMrpzj3Gm8g.png" /></figure><p>Runtime methods can receive your AgentState subclass, RunnableConfig, both in either order, or neither. Include only what the method needs. A returned future must complete before its updates or routing result can be applied; returning a future does not itself schedule background work.</p><p>A <strong>compile-time</strong> node method instead takes <strong>one </strong><strong>CompileConfig argument</strong>. It runs when the graph creates its action during compilation and returns the action to execute later. This is useful when action construction depends on compilation settings. Edge conditions do not support <strong>compile-time</strong> configuration.</p><p>See the <a href="https://langgraph4j.github.io/langgraph4j/1.9/core/annotations/#node-action-signatures">signature examples</a> for the complete forms.</p><p>For a small workflow, a single catalog keeps related actions and conditions together. As the application grows, I would split catalogs by responsibility: document preparation in one, review policy in another, and delivery in a third. Each can have its own repository, with their actions connected in the same explicit graph definition.</p><p>The repository uses the <strong>catalog instance you supply</strong>. That means constructor injection works naturally: create the catalog with its service clients, repositories, or model dependencies before registering it. The annotations do not require a dependency injection framework.</p><p>Keep per-run values in graph state or execution configuration. A catalog shared across concurrent runs also shares its fields and dependencies, so mutable collaborators need suitable concurrency handling. The stateless catalog in this example avoids that concern.</p><p>Catalog methods can be called directly in ordinary Java tests.</p><h3>Common mistakes to catch early</h3><p>Use <strong>public annotated methods</strong>, with one graph annotation per method. Repository discovery will not pick up private methods. Unsupported runtime parameter types are rejected during repository creation, while unsupported results fail when the action executes; compile-time node results are checked during compilation.</p><p>Looking up an unknown action through node, nodeAction, or edge throws IllegalArgumentException. Explicit duplicate names are also rejected; make method-derived names unique rather than relying on overload discovery order.</p><p>Exceptions thrown by runtime methods, and exceptional future completions, propagate through graph execution. Annotations provide adaptation, so application error handling still belongs in the actions or the surrounding execution code. The <a href="https://langgraph4j.github.io/langgraph4j/1.9/core/annotations/#validation-and-failures">validation reference</a> covers these failure cases.</p><p>For an existing graph, a practical migration is to move a related group of actions into a catalog, register it, and replace their inline implementations with repository lookups. The edges and routing mappings can remain explicit throughout that refactoring.</p><h3>Conclusion</h3><p>The approach of organizing actions into catalogs helps maintain a clear structure as your workflow grows. It encourages modularity, reusability, and easier testing, while keeping the graph definitions explicit and manageable. In the future action catalogs could feed advanced workflow designer tools, enabling more declarative automation and orchestration capabilities. I’m interested in how this approach fits larger workflows. Try it grouping a set of related actions in <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a>, share your feedback, and… happy AI coding! 👋</p><p><em>Originally published at </em><a href="https://bsorrentino.github.io/bsorrentino/ai/2026/10/21/LangGraph4j-Annotations.html"><em>https://bsorrentino.github.io</em></a><em> on October 21, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88a2e2d2acbb" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/langgraph4j-annotations-organize-graph-behavior-with-action-catalogs-88a2e2d2acbb">LangGraph4j Annotations: Organize Graph Behavior with Action Catalogs</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LangGraph4j 1.9.0: What’s new and the roadmap]]></title>
            <link>https://blog.devgenius.io/langgraph4j-1-9-0-whats-new-and-the-roadmap-613c9a9579d2?source=rss-b9c2251c0e92------2</link>
            <guid isPermaLink="false">https://medium.com/p/613c9a9579d2</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[langgraph4j]]></category>
            <category><![CDATA[agentic-workflow]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Bartolomeo Sorrentino]]></dc:creator>
            <pubDate>Fri, 18 Sep 2026 00:00:12 GMT</pubDate>
            <atom:updated>2026-09-22T12:55:49.141Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*EQeNEGTmNRdDmHBT.png" /></figure><h3>LangGraph4j 1.9.0 is out!</h3><p><a href="https://github.com/langgraph4j/langgraph4j"><strong>LangGraph4j</strong></a><strong> 1.9.0 is out!</strong> With the 1.8.x release stream now in LTS, development moves forward on 1.9 with improvements to streaming, persistence, and the infrastructure for building agents in Java.</p><p>This release is an important step toward workflows that are easier to follow while they run and easier to inspect after they finish. A node can now report progress output before returning its result, checkpoint savers have a richer execution lifecycle, and Studio gets an UI refresh.</p><p>Let’s look at what changes for an application built on 1.8.x, with particular attention to <strong>custom output from nodes</strong> and <strong>checkpoint management</strong>. The <a href="https://langgraph4j.github.io/langgraph4j/1.9/whats-new-v1.9">official migration guide</a> provides details API reference for the changes discussed here.</p><h3>Emit custom output while a node is running</h3><p>Imagine a node that retrieves documents, processes them, and prepares a response. The caller may want to show progress throughout that work. Waiting for the final node output gives the user minimal information about what is happening in the meantime.</p><p>The mechanism is straightforward:</p><ol><li>Define a subclass of NodeOutput carrying the information you want to expose.</li><li>Obtain a dispatcher from the node’s RunnableConfig.</li><li>Dispatch custom outputs during execution.</li><li>Handle those types when consuming the graph stream.</li></ol><p>Here is a small example.</p><pre>public final class ProgressOutput extends NodeOutput&lt;AgentState&gt; {<br>    private final String message;<br><br>    public ProgressOutput(String node, AgentState state, String message) {<br>        super(node, state);<br>        this.message = message;<br>    }<br><br>    public String message() {<br>        return message;<br>    }<br>}</pre><p>Inside the node, the dispatcher publishes a message while the returned map still provides the normal state update:</p><pre>AsyncNodeActionWithConfig&lt;AgentState&gt; process = (state, config) -&gt; {<br>    var dispatcher = config.&lt;AgentState, ProgressOutput&gt;customDispatcher();<br><br>    dispatcher.dispatchAsync(<br>        new ProgressOutput(config.nodeId(), state, &quot;Processing documents&quot;));<br><br>    // Perform the node&#39;s work here.<br><br>    return completedFuture(Map.of(&quot;result&quot;, &quot;Documents processed&quot;));<br>};</pre><p>Once this action is registered in a compiled graph, the caller can recognize its progress messages:</p><pre>graph.stream(GraphInput.noArgs(), RunnableConfig.empty()).forEachAsync( output -&gt; {<br>        if (output instanceof ProgressOutput progress) {<br>            System.out.println(progress.message());<br>        } else {<br>            System.out.println(&quot;Graph step: &quot; + output.node());<br>        }<br>    });</pre><p>This gives us a useful channel for progress notifications, intermediate results, and application-specific events. <strong>Dispatching a custom output does not update graph state.</strong> If a value must influence routing, be available to later nodes, or become part of a persisted result, include it in the node’s returned state update.</p><p>Custom events are intended for graph.stream(...) consumers; they do not change the result returned by graph.invoke(...). See the <a href="https://langgraph4j.github.io/langgraph4j/1.9/core/emit-custom-output/">custom-output tutorial</a> for the complete contract and a <strong>hook-based</strong> example.</p><h3>The streaming engine behind it</h3><p>This capability comes with a refactoring of the internal streaming engine around AsyncGeneratorFlow from <a href="https://github.com/bsorrentino/java-async-generator">async-generator 5.0</a> project.</p><p><strong>Note:</strong> 👀</p><blockquote><em>This refactoring is a groundwork for Reactor Flow support in a future LangGraph4j </em><em>2.0; that support is a future direction.</em></blockquote><h3>Checkpoint Savers: A richer execution lifecycle</h3><p>Checkpoint persistence is central to long-running agents and Human-in-the-Loop workflows. In 1.9, the changes cover what happens when execution finishes, how released runs can be retrieved, how subgraph savers participate, and how interruptions and failures are recorded. These are the <a href="https://langgraph4j.github.io/langgraph4j/1.9/whats-new-v1.9">checkpoint changes</a> I would review first when upgrading an existing application.</p><h3>Completed runs release their thread by default</h3><p>With a checkpoint saver configured, <strong>a graph that completes normally now releases its active thread automatically</strong>. Depending on the saver, release archives or tags its checkpoints and removes the active checkpoint set.</p><p>This matters if your application completes a graph, updates the same active thread’s state, and executes it again. To retain the previous lifecycle, explicitly disable automatic release when compiling:</p><pre>var compileConfig = CompileConfig.builder()<br>    .checkpointSaver(saver)<br>    .releaseThread(false) // backward compatible option<br>    .build();<br><br>var graph = workflow.compile(compileConfig);</pre><p><strong>An interruption or an exception does not automatically release the thread.</strong> Interrupted runs remain available for Human-in-the-Loop continuation, and failed runs remain available for the application’s recovery strategy. graph.updateState(...) continues to work in those situations as before.</p><p>The practical upgrade check is to examine what your code does <em>after successful completion</em>. Any inspection, replay, resume, or manual-release logic that assumes an active checkpoint set needs attention.</p><h3>Experimental versioning for released runs</h3><p>Checkpoint tags gain optional version information. BaseCheckpointSaver.Tag exposes threadId(), version() as an Optional&lt;Integer&gt;, checkpoints(), and lastCheckpoint().</p><p>Two lookup methods make released runs accessible:</p><pre>Optional&lt;Tag&gt; tag(RunnableConfig config, Integer version) throws Exception;<br><br>Optional&lt;Tag&gt; lastTag(RunnableConfig config) throws Exception;</pre><p>GraphResult.asLastCheckpointStateData() now obtains its data through Tag.lastCheckpoint(), preserving its observable result. This is useful continuity for callers retrieving the final checkpoint state while the underlying release model evolves.</p><h3>Parent and Subgraph savers work together</h3><p>Subgraphs increasingly carry real agent behavior, so their persistence lifecycle must follow the parent execution.</p><p>BaseCheckpointSaver now supports putSubGraphSaver(...) to register a subgraph saver and listSubGraphSaver(...) to retrieve registrations associated with a parent configuration. SubCompiledGraphNodeAction registers its saver with the parent; AbstractCheckpointSaver.release(...) then cascades release to the registered subgraph threads.</p><p>If you implement a custom saver, AbstractCheckpointSaver provides a reference implementation of the registration mechanism. Review that lifecycle when adapting your implementation, especially if your agents contain nested compiled graphs.</p><p>The saver contract also exposes explicit lifecycle hooks:</p><pre>void registerInterruption(<br>    RunnableConfig config,<br>    InterruptionMetadata interruptionMetadata) throws Exception;<br><br>Tag releaseCheckpointsOnError(<br>    RunnableConfig config,<br>    Throwable error) throws Exception;</pre><p>These allow a saver to retain interruption information and distinguish an error release from normal completion. InterruptionMetadata now also exposes the interruption reason. That gives later analysis more context about why an execution stopped.</p><p>The error-release hook does not change the default described above: an exception leaves the thread available, and the caller chooses its recovery or release strategy.</p><p><strong>Note:</strong> 👀</p><blockquote><em>To avoid leaving lots of unfinished records in the checkpoint persistence layer, we recommend calling </em><em>saver.releaseOnError(RunnableConfig, Throwable) within exception handling logic. We are currently considering automating this in a future release by having the graph execution engine invoke the method whenever an error occurs.</em></blockquote><p>The in-memory, file-system, Redis, Postgres, Oracle, MySQL, CockroachDB, DynamoDB, and Hazelcast savers have been aligned with this contract through default implementations. The amount of information retained remains a concern of the specific saver implementation.</p><h3>SQLite and PostgreSQL V2 savers</h3><p>Both integrations add the V2 implementations align with the updated release, error, and interruption contract. The original classes remain available for their V1 schemas. Treat adoption of a V2 saver as a persistence change to review against your existing database.</p><h3>Other changes worth knowing before upgrading</h3><h3>Explicit Graph Inputs</h3><p>GraphInput becomes the preferred API for expressing whether an execution is starting or resuming:</p><pre>graph.stream(GraphInput.args(Map.of(&quot;input&quot;, &quot;Hello&quot;)), config);<br>graph.stream(GraphInput.resume(), config);<br>graph.stream(GraphInput.resume(Map.of(&quot;approval&quot;, &quot;APPROVED&quot;)), config);</pre><p>Use GraphInput.noArgs() for a new execution without arguments. The older map-based stream and invoke overloads remain available in 1.9, but are deprecated for removal. Moving away from a null map makes the intended operation explicit.</p><h3>Diagnostics and State Serialization</h3><p>State cloning remains enabled by default. RunnableConfig.builder().disableCloneState() opts out, which can help during early development with objects that are not yet serializable. Exposed state may then reflect later mutations, so consider how consumers retain or modify it.</p><p>StateSerializer.declareTransientAttributes(...) excludes named attributes from serialized data and restores them from the same serializer&#39;s in-memory transient storage. Those values do not survive a restart, a different process, or a new serializer instance. Keep anything needed for durable resume in persisted state. GsonStateSerializer is deprecated for removal; move toward Jackson-based serialization.</p><h3>Agent infrastructure</h3><p>Spring AI builds on this with SubAgent, CustomSubAgent, SkilledReactSubAgent, and SkillResource, making compiled agents reusable as tools. I covered the pattern in <a href="https://bsorrentino.github.io/bsorrentino/ai/2026/04/28/LangGraph4j-SubAgent.html">Skill-Based Sub-Agents with LangGraph4j and Spring AI</a>.</p><h3>LangGraph4j Studio gets a visual refresh</h3><h3>Studio 1.8</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cv6B5HFcDzpKugA2.gif" /></figure><h3>Studio 1.9</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bWvCtVc6Nlqh68I-.gif" /></figure><p>In the new Studio the active node receives a blue highlight and a loading indicator, making execution easier to follow at a glance.</p><h3>LangGraph4j DSL</h3><p>The release also adds langgraph4j-dsl, whose JsonDslGenerator exports graphs, including parallel nodes and nested subgraphs, as JSON:</p><pre>String json = compiledGraph.reduce(new JsonDslGenerator&lt;&gt;());</pre><p>This representation has been used for the Studio refactoring toward <a href="https://reactflow.dev/">React Flow</a> library.</p><h3>What’s Next for LangGraph4j</h3><p>The next phase of development will focus on three areas. These are roadmap priorities, with scope and delivery to evolve as implementation progresses.</p><h3>Persist more of the execution context</h3><p>I want to improve graph execution-context persistence so that it supports monitoring and post-processing analysis more effectively. The checkpoint lifecycle work in 1.9 is a step in that direction: understanding completed, interrupted, and failed runs is essential when agentic workflows move into production.</p><p>The aim is to make retained execution information more useful for understanding behavior and for subsequent analysis and processing.</p><h3>Redesign parallel node execution</h3><p>Another priority is to redesign the parallel-node implementation, removing current limitations and improving efficiency. As workflows grow, parallel branches need to become easier to compose and manage.</p><p>This is upcoming work. Applications using 1.9 should continue to account for the currently documented parallel-execution limitations.</p><h3>Improve built-in Agents for Spring AI and LangChain4j</h3><p>Finally, I want to enhance the built-in agent infrastructure for both <strong>Spring AI</strong> and <strong>LangChain4j</strong>. The skills and sub-agent work demonstrates how much can be built on top of graph execution; the goal is to make those building blocks more useful and easier to compose across both integrations.</p><h3>Try the Release</h3><p>Update the LangGraph4j BOM to 1.9.0 to keep module versions aligned:</p><pre>&lt;dependencyManagement&gt;<br>  &lt;dependencies&gt;<br>    &lt;dependency&gt;<br>      &lt;groupId&gt;org.bsc.langgraph4j&lt;/groupId&gt;<br>      &lt;artifactId&gt;langgraph4j-bom&lt;/artifactId&gt;<br>      &lt;version&gt;1.9.0&lt;/version&gt;<br>      &lt;type&gt;pom&lt;/type&gt;<br>      &lt;scope&gt;import&lt;/scope&gt;<br>    &lt;/dependency&gt;<br>  &lt;/dependencies&gt;<br>&lt;/dependencyManagement&gt;</pre><h3>Conclusions</h3><p>For an existing 1.8.x application, start with the <a href="https://langgraph4j.github.io/langgraph4j/1.9/whats-new-v1.9">migration guide</a>, review thread release and stored checkpoint compatibility, then exercise interruption, resume, and completion paths with your chosen saver.</p><p>I’m interested in feedback from real workflows, especially around custom progress output and checkpoint management. Check out <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a>, try the release, and let me know what would help your next agentic application. If you find the project useful, leave a star ⭐️ and… happy AI coding! 👋</p><p><em>Originally published at </em><a href="https://bsorrentino.github.io/bsorrentino/ai/2026/09/18/LangGraph4j-Whats-new-in-1.9.0.html"><em>https://bsorrentino.github.io</em></a><em> on September 18, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=613c9a9579d2" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/langgraph4j-1-9-0-whats-new-and-the-roadmap-613c9a9579d2">LangGraph4j 1.9.0: What’s new and the roadmap</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Skill-Based Sub-Agents with LangGraph4j and Spring AI]]></title>
            <link>https://blog.devgenius.io/skill-based-sub-agents-with-langgraph4j-and-spring-ai-e719a46d3da1?source=rss-b9c2251c0e92------2</link>
            <guid isPermaLink="false">https://medium.com/p/e719a46d3da1</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[spring-ai]]></category>
            <category><![CDATA[langgraph4j]]></category>
            <dc:creator><![CDATA[Bartolomeo Sorrentino]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 00:00:18 GMT</pubDate>
            <atom:updated>2026-05-07T12:08:31.543Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*_K_a30M9msVdLch0.png" /></figure><h3>Combine Tools &amp; Skill to create Agent</h3><p>Modern agentic systems usually expose two strong but separate abstractions:</p><ul><li><strong>Tools</strong>, which give an LLM executable capabilities</li><li><strong>Skills</strong>, which package reusable instructions for a narrow task</li></ul><p>This article shows how to combine both ideas in <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> so that a skill is not just prompt text, but a fully operational <strong>sub-agent exposed as a tool</strong>. The result is a practical pattern for building modular multi-agent systems in Java with and <a href="https://github.com/langgraph4j/langgraph4j"><strong>LangGraph4j</strong></a>, while keeping each agent focused, reusable, and low in context cost.</p><p>Starting from a standard ReACT agent, the approach implemented is quite simple.</p><ol><li>Load a SKILL.md file</li><li>Read its front matter to define the tool contract ( name and argument description)</li><li>Use the skill body as the sub-agent system prompt</li><li>Restrict the sub-agent to only the tools declared by the skill</li><li>Register the sub-agent in a parent ReAct agent as if it were a normal tool</li></ol><p>In other words, a skill becomes an <em>executable tool-backed agent</em>.</p><h3>Why This Pattern Matters</h3><p>The standard ReAct pattern already gives an LLM a strong execution model: reason, choose a tool, inspect the result, and continue until the task is complete. That model is useful because the LLM does not need to commit to a fixed plan up front. It can adapt after every tool call.</p><p>The next step is to let a tool itself be implemented by another agent.</p><p>Once that happens, the parent agent is no longer forced to know every operational detail. It only needs to know:</p><p>The specialized logic is delegated to a narrower agent with its own instructions and its own restricted toolset. This gives us a clean <strong>sub-agent architecture</strong> without inventing a new orchestration primitive. We reuse the same tool-calling semantics that ReAct agents already understand well.</p><h3>Why Reusing Tool Semantics Is Powerful</h3><p>One of the most valuable properties of LLM-based agents is their ability to build and revise a tool execution plan while reasoning over intermediate results. ReAct made this practical by combining thought, action, and observation in a loop.</p><p>When a tool call can transparently invoke another agent, we preserve that planning model instead of replacing it.</p><p>The parent agent can:</p><ul><li>decide that a specialized capability is needed</li><li>provide only the task-relevant context</li><li>wait for a result exactly as it would for a standard tool</li></ul><p>The child agent can:</p><ul><li>run its own reasoning loop</li><li>invoke its own allowed tools</li><li>return a compact outcome to the parent</li></ul><p>This gives hierarchical coordination without exposing the full inner workflow to the parent prompt.</p><h3>Minimizing Context and Token Usage</h3><p>This pattern also improves context discipline.</p><p>Without sub-agents, a single generalist agent often needs:</p><ul><li>every tool definition</li><li>all operating instructions for every domain</li><li>every procedural rule in one large system prompt</li></ul><p>That quickly becomes expensive and unreliable.</p><p>With skill-based sub-agents:</p><ul><li>the parent only sees high-level capabilities</li><li>each child sees only the instructions relevant to its task</li><li>each child receives only the tools it is allowed to use</li></ul><p>This narrower context has practical benefits:</p><ul><li>fewer tokens sent to the model</li><li>lower prompt interference between unrelated domains</li><li>clearer tool choice</li><li>better modularity as the system grows</li></ul><blockquote><em>The </em><em>allowed-tools skill property plays an important role here anabling tool filtering. It turns tool access into an explicit design decision instead of an accidental side effect of what happened to be registered globally.</em></blockquote><h3>Reference implementation</h3><p>I’ve started implementation in the new <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> release stream 1.9 currently in active development. The implementation is centered on SkilledReactSubAgent, which turns a markdown skill into both:</p><ul><li>a compiled LangGraph4j sub-graph</li><li>a Spring AI tool (i.e. ToolCallback)</li></ul><p>That means the same component can participate in the graph as an agent and present itself to the parent LLM as a callable tool.</p><p>In particular the flow is:</p><ol><li>Parse the SKILL.md</li><li>Extract name and description from front matter</li><li>Optionally filter tools using allowed-tools</li><li>Use the markdown body as the sub-agent instructions</li><li>Compile the agent</li><li>Wrap it into a function tool whose input is a single context field</li></ol><blockquote><em>The important design choice is that the </em><strong><em>tool definition is derived from the skill metadata</em></strong><em>, while the </em><strong><em>agent behavior is derived from the skill content</em></strong><em>.</em></blockquote><h3>Skill Format</h3><p>The supported skill format is</p><pre>---<br>name: &lt;agent name&gt;<br>description: |<br>        &lt;multi line description&gt;<br>allowed-tools: &lt;list of tools&gt;<br>---<br><br>&lt;skill body&gt;</pre><h3>From Skill to Tool-Backed Agent</h3><p>The conversion happens in SkilledReactSubAgent.Builder#build(...). This is the crucial bridge where:</p><ul><li>the skill metadata defines the external API</li><li>the skill body defines the internal operating behavior</li><li>the allowed tools define the sub-agent execution boundary</li></ul><p>The resulting agent is then wrapped as a Spring AI function tool.</p><blockquote><em>From the parent agent point of view, this is just another tool. Internally, it is a complete ReAct-capable agent workflow.</em></blockquote><h3>Examples</h3><h3>Purchase Assistant Agent</h3><p>This is an agent that allow to select a produdct from a reference marketplace and purchase it. Below the simplified component diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/0*Ub0fg3bSBT62IavC.png" /></figure><h3>Marketplace Skill</h3><pre>---<br>name: agent-marketplace<br>description: |<br>    marketplace agent, ask for information about products. This is agent that provides the information on the product marketplace.<br>    required data are:<br>    * product name<br>allowed-tools: searchByProduct<br>---<br><br>## Retrieve product information<br>We need all information about about the product of interest in particular is mandatory to have<br>* product name<br><br>with such information we have to invoke tool `searchByProduct` and return the result</pre><h3>Payment Skill</h3><pre>---<br>name: agent-payment<br>description: |<br>    payment agent, this is the agent that provides payment service.<br>    required data are:<br>    * Product name<br>    * Product price<br>    * Product currency<br>    * the International Bank Account Number (IBAN) - optional<br><br>allowed-tools:<br>    - submit-payment<br>    - retrieve-iban<br>---<br><br>## submit a payment for purchasing a specific product<br>We need all information about purchasing to allow the payment<br><br>* Product name<br>* Product price<br>* Product price currency<br>* International Bank Account Number (IBAN)<br><br>With such information you must invoke tool `submit-payment` and return the result of the payment transaction plus the IBAN.<br>If IBAN is not provided invoke tool `retrieve-iban` to retrieve the required IBAN.</pre><p>Observing the skills above they define three different concerns:</p><ul><li>name: the tool name exposed to the parent agent</li><li>description: the tool description shown to the model</li><li>allowed-tools: the only tools available inside the sub-agent</li></ul><p>Everything after the front matter becomes the sub-agent system prompt.</p><blockquote><em>Again, this is a strong separation of concerns. The parent agent sees a concise tool contract, while the child agent receives richer operating instructions.</em></blockquote><h3>Finally the code</h3><p>Below a representative code snippet that show how wires two skill-based sub-agents into a parent agent:</p><pre>var subAgentMarketplace = SkilledReactSubAgent.builder()<br>        .chatModel(chatModel)<br>        .tools(Marketplace.tools())<br>        .build(compileConfig,<br>                SkillSource.of(Paths.get(&quot;skills/agent-marketplace/&quot;)));<br><br>var subAgentPayment = SkilledReactSubAgent.builder()<br>        .chatModel(chatModel)<br>        .tools(Payment.tools())<br>        .build(compileConfig,<br>                SkillSource.of(Paths.get(&quot;skills/agent-payment/&quot;)));<br><br>var purchaseAssistantAgent = AgentExecutorEx.builder()<br>        .chatModel(chatModel)<br>        .tool(subAgentMarketplace)<br>        .tool(subAgentPayment)<br>        .build(compileConfig);<br><br>var input = &quot;&quot;&quot;<br>        search for product &#39;X&#39;.<br>        If found proceed to payment with IBAN US82WEST1234567890123456 <br>        to purchase it<br>        &quot;&quot;&quot;;<br><br>var result = purchaseAssistantAgent.invoke( <br>        GraphInput.args( Map.of(&quot;messages&quot;, new UserMessage(input) )), runnableConfig); <br><br></pre><p>This composition is interesting because the purchase agent (the parent) does not need detailed knowledge of:</p><ul><li>how product lookup works</li><li>how payment submission works</li><li>when IBAN retrieval is required</li></ul><p>Those rules are delegated to the sub agents themselves.</p><p>That is a simple but good example of behavioral encapsulation. The parent agent only decides to involve marketplace agent to retrieve product and after that to involve payment agent to purchase.</p><p>This is a very basic but representative example, it is useful because it shows the intended layering:</p><ul><li>the user gives a single business request</li><li>the parent agent decomposes the work</li><li>specialized sub-agents execute their own logic</li><li>the final answer comes back through the normal tool-response path</li></ul><blockquote><em>Interesting note that each sub agent, potentially, can relies on different LLM chat model so we can further optimize overall agent execution process</em></blockquote><p>Below a more detailed componet diagram generated by <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C2KCiXXPTC9X5qi_.png" /></figure><p>From this diagram it is quite clear that the sub agents are nothing but sub-graphs</p><h3>Design Advantages</h3><p>This approach has several practical advantages.</p><ol><li><strong>Reuse Existing Agent Patterns<br></strong>There is no need to invent a separate orchestration protocol for sub-agents. A sub-agent is exposed as a tool, so the parent agent can use standard ReAct behavior without extra prompting complexity.</li><li><strong>Better Modularity<br></strong>Each skill owns:<br>- its tool-facing identity<br>- its internal instructions<br>- its allowed tool boundary<br>That makes the system easier to evolve than a single monolithic agent prompt.</li><li><strong>Smaller and Cleaner Context<br></strong>The child agent receives only what it needs. This reduces token usage and lowers the risk that unrelated instructions distort tool choice or task execution.</li><li><strong>Safer Capability Scoping<br></strong>By filtering tools from allowed-tools, the framework prevents a child agent from accidentally seeing tools outside its intended domain.</li><li><strong>Better Reusability<br></strong>A skill can be packaged, versioned, and reused across different parent agents. The same marketplace or payment skill can participate in many workflows as long as the tool contract remains stable.</li></ol><h3>Tradeoffs and Implementation Considerations</h3><p>This pattern is strong, but it is not free of tradeoffs.</p><ol><li><strong>The Parent Must Summarize Well<br></strong>Because the child receives a single context field, the parent agent needs to pass the relevant facts clearly. If critical information is omitted, the child may need extra recovery steps or may fail to act.</li><li><strong>Tool Descriptions Matter More<br></strong>Since the parent sees the child as a tool, the name and description fields in the skill front matter become part of the routing surface for the LLM. Weak metadata will reduce invocation quality.</li><li><strong>Prompt Boundaries Need Discipline<br></strong>The skill body is effectively the child system prompt. If it is vague, contradictory, or overloaded, the benefits of modularity disappear. Skills need to stay focused.</li><li><strong>Observability Is Important<br></strong>Nested agents can make execution harder to inspect if tracing is weak. LangGraph4j’s graph structure and step streaming help here, but production systems should still invest in logging and traceability.</li></ol><h3>Why LangGraph4j Fits This Well</h3><p><a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> is a good fit for this pattern because it already models agent workflows as explicit graphs and integrates naturally with Spring AI tool abstractions.</p><p>That matters for two reasons:</p><ul><li>the sub-agent is not just prompt composition; it is a compiled graph with state and execution hooks</li><li>the parent integration remains ergonomic because Spring AI already treats capabilities as tools</li><li><a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> support interruptions in subgraph enabling <strong>Human In The Loop</strong> also when involving sub agents</li></ul><p>So the implementation is not forcing two incompatible ideas together. It is aligning:</p><ul><li>LangGraph4j graph execution</li><li>Spring AI tool calling</li><li>markdown-defined skills</li></ul><p>into a single reusable agent-building pattern.</p><h3>Conclusion</h3><p>Turning a skill into a sub-agent is a small change with a large impact.</p><p>It lets us:</p><ul><li>preserve the strengths of the ReAct loop</li><li>delegate specialized behavior cleanly</li><li>reduce context size</li><li>constrain tool access per domain</li><li>build multi-agent systems out of reusable skill modules</li></ul><p>The idea is implemented in a compact and pragmatic way: a SKILL.md file becomes the source of both the sub-agent prompt and the tool contract exposed to the parent agent.</p><p>For Java teams building agentic applications with Spring AI and LangGraph4j, this is a practical pattern for moving from a single large agent toward a modular multi-agent design without abandoning the tool semantics that current LLMs already handle well.</p><p>The implementation is in progress on release 1.9-SNAPSHOT in develop branch of <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> repository but the first result are very promising.</p><p>Hope this could help and encourage usage of <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> for your next Agentic Workflow. Checkout project, try it and let me know your feedback and… happy AI coding! 👋</p><p><em>Originally published at </em><a href="https://bsorrentino.github.io/bsorrentino/ai/2026/04/28/LangGraph4j-SubAgent.html"><em>https://bsorrentino.github.io</em></a><em> on April 28, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e719a46d3da1" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/skill-based-sub-agents-with-langgraph4j-and-spring-ai-e719a46d3da1">Skill-Based Sub-Agents with LangGraph4j and Spring AI</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ LangGraph4j Hooks and OpenTelemetry]]></title>
            <link>https://blog.devgenius.io/langgraph4j-hooks-and-opentelemetry-3bd8de02f9d1?source=rss-b9c2251c0e92------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bd8de02f9d1</guid>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[opentelemetry]]></category>
            <category><![CDATA[langgraph4j]]></category>
            <dc:creator><![CDATA[Bartolomeo Sorrentino]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 00:00:58 GMT</pubDate>
            <atom:updated>2026-02-06T10:56:07.404Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*0hRWdTIgDaEd9nqA.png" /></figure><h3>Why Observability Matters</h3><p>Agentic workflows are dynamic: nodes may run conditionally, in parallel, or be skipped entirely. When something fails, a simple stack trace is rarely enough. <strong>Observability</strong> gives you a unified view of <strong>what</strong> happened, <strong>where</strong> it happened, and <strong>why</strong>.</p><p>In practice, observability helps you:</p><ul><li>Understand end-to-end execution flow.</li><li>Detect performance bottlenecks early.</li><li>Correlate errors with specific nodes, edges, and state transitions.</li></ul><h3>Why Telemetry Matters</h3><p>Observability is only possible if you collect high‑quality telemetry. Telemetry is the raw signal: <strong>traces</strong>, <strong>logs</strong>, and <strong>metrics</strong>. Without it, probably, you are debugging your system partially.</p><p>In agent graphs, telemetry becomes even more important because state and control flow are distributed across steps. The same workflow can behave differently depending on state, configuration, or external tool results.</p><h3>The LangGraph4j hooks</h3><p><a href="https://langgraph4j.github.io/langgraph4j/core/hooks/">LangGraph4j hooks</a> are small, composable interceptors that sit around <strong>nodes</strong> and <strong>conditional edges</strong>. They let you run custom logic <strong>before</strong>, <strong>after</strong>, or <strong>wrapping</strong> the core action, without modifying the node itself. Hooks can be registered globally (applies to all nodes/edges) or by ID (targeted to a specific node/edge), and their execution order is <strong>LIFO</strong>(Last In First Out) for BeforeCall/ AfterCall, <strong>FIFO</strong>(First In First Out) for WrapCall. This makes them a precise, low‑friction mechanism for cross‑cutting concerns like tracing, metrics, logging, or state inspection.</p><h3>How Hooks Enable Observability</h3><p><a href="https://langgraph4j.github.io/langgraph4j/core/hooks/">Hooks</a> provide lifecycle interception points around node and edge execution. This is the ideal place to add logging, metrics, or traces without contaminating business logic.</p><p>In <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> you can intercept execution <strong>before</strong>, <strong>after</strong>, or <strong>around</strong> node/edge calls. Here is a minimal example that measures node execution time and logs it:</p><pre>var graph = new StateGraph&lt;&gt;(MyState.SCHEMA, serializer)<br>    .addWrapCallNodeHook((nodeId, state, config, action) -&gt; { // add Wrap call node hook<br>        var start = System.currentTimeMillis();<br>        return action.call()<br>            .whenComplete((res, err) -&gt; {<br>                var ms = System.currentTimeMillis() - start;<br>                log.info(&quot;node &#39;{}&#39; took {}ms&quot;, nodeId, ms );<br>            });<br>    })<br>    .addNode( &quot;node1&quot;, action1 )<br>    .addNode( &quot;node2&quot;, action2 )<br>    ....<br>    .compile();</pre><p>This pattern scales: you can plug in structured logs, metrics counters, or spans with the same hook mechanism.</p><h3>OpenTelemetry in the Java Ecosystem</h3><p><a href="https://opentelemetry.io/docs/what-is-opentelemetry/">OpenTelemetry</a> is the standard for observability across modern platforms. In Java it provides:</p><p>You configure it once and export telemetry to a backend like , <strong>Grafana</strong>, or the <strong>OpenTelemetry Collector</strong>. The key benefit here is <strong>portability</strong>: you are not locked to a single vendor.</p><h3>How LangGraph4j Hooks Enable OpenTelemetry</h3><p><a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> includes a dedicated module, langgraph4j-opentelemetry, that provides hook implementations ready for tracing node and edge execution. Consider it as a reference implementation about <strong>how to integrate OpenTelemetry in LangGraph4j</strong></p><p>The module includes:</p><ul><li>OTELWrapCallTraceHook: creates spans for each node and edge call, adding config/state attributes and start/end events.</li><li>OTELWrapCallTraceSetParentHook: creates a parent span so node/edge spans are grouped inside a workflow scope.</li></ul><p>A minimal integration looks like this:</p><pre>ar otelHook = new OTELWrapCallTraceHook&lt;MyState&gt;(serializer);<br>var parentHook = OTELWrapCallTraceSetParentHook.&lt;MyState&gt;builder()<br>    .scope(&quot;MyWorkflow&quot;)<br>    .groupName(&quot;stream&quot;)<br>    .build();<br><br>var workflow = new StateGraph&lt;&gt;(MyState.SCHEMA, serializer)<br>    .addWrapCallNodeHook(otelHook)<br>    .addWrapCallEdgeHook(otelHook)<br>    .addWrapCallNodeHook(parentHook)<br>    .addWrapCallEdgeHook(parentHook)<br>    .addNode( &quot;node1&quot;, action1 )<br>    .addNode( &quot;node2&quot;, action2 )<br>    .addContitionalEdges( &quot;node2&quot;, edgeAction, <br>            EdgeMappings.builder()<br>            .to(&quot;node1&quot;)<br>            .toEnd()<br>            .build() )<br>    ...        <br>    .compile();</pre><p>This keeps node logic clean while producing rich, correlated traces for the entire workflow.</p><p>Below an example of output in <a href="https://www.jaegertracing.io/">Jaeger</a> tracing platform</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WGuXK2SGsQt0ybNX.png" /></figure><h3>Conclusion</h3><p>Hooks are the foundation for observability in <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a>: they give you structured interception points without affect your main workflow code. OpenTelemetry builds on top of this by standardizing how telemetry is collected and exported in the Java ecosystem. Combined, they deliver production-grade visibility for complex agent workflows. Checkout project, try it and let me know your feedback and … happy AI coding! 👋</p><h3>References</h3><ul><li><a href="https://opentelemetry.io/docs/what-is-opentelemetry/">OpenTelemetry</a></li></ul><p><em>Originally published at </em><a href="https://bsorrentino.github.io/bsorrentino/ai/2026/02/04/LangGraph4j-Hooks-and-OpenTelemertry.html"><em>https://bsorrentino.github.io</em></a><em> on February 4, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bd8de02f9d1" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/langgraph4j-hooks-and-opentelemetry-3bd8de02f9d1">🧭 LangGraph4j Hooks and OpenTelemetry</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Experimenting with Javelit — The Streamlit for Java]]></title>
            <link>https://blog.devgenius.io/experimenting-with-javelit-the-streamlit-for-java-fd09747d0559?source=rss-b9c2251c0e92------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd09747d0559</guid>
            <category><![CDATA[ui-ux]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[langgraph4j]]></category>
            <category><![CDATA[javelit]]></category>
            <dc:creator><![CDATA[Bartolomeo Sorrentino]]></dc:creator>
            <pubDate>Sat, 20 Dec 2025 00:00:14 GMT</pubDate>
            <atom:updated>2025-12-22T08:22:30.982Z</atom:updated>
            <content:encoded><![CDATA[<h3>Experimenting with Javelit — The Streamlit for Java</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*-NW9DFB7CH1dJwt0.png" /></figure><h3>Starting from Python development ecosystem</h3><p>At the beginning of my journey with agentic applications, I started with the Python programming language, leveraging <a href="https://docs.langchain.com/oss/python/langchain/overview">LangChain</a>/ <a href="https://docs.langchain.com/oss/python/langgraph/overview">LangGraph</a>. For testing and documentation, I relied on the simple yet powerful <a href="https://jupyter.org/">Jupyter Notebooks</a>. Simultaneously, for rapid prototyping, I adopted the amazing <a href="https://streamlit.io/">Streamlit</a> framework, which empowered me to quickly develop functional applications with an effective UI and excellent UX.</p><h3>Moving from Python ecosystem to the Java one</h3><p>When I started developing <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a>, I tried to replicate my Python development ecosystem in Java. So I’ve experimented with the Java Notebooks through the <a href="https://github.com/padreati/rapaio-jupyter-kernel">rapaio-jupyter-kernel</a> project, which allowed me to replicate the development experience I had with <a href="https://jupyter.org/">Jupyter Notebooks</a> in Python quite well. For rapid prototyping, I relied almost entirely on <a href="https://spring.io/projects/spring-boot">Spring Boot</a> framework, which is a fairly fast and enjoyable programming experience.</p><h3>Javelit come to play 🚀</h3><p>Going on my efforts on <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> and continuously monitoring the most interesting and promising Java projects on GitHub, I discovered <a href="https://javelit.io/">Javelit</a>. This project intrigued me because of its reference to <a href="https://streamlit.io/">Streamlit</a>, and after a review, I was amazed to realize that the dynamic programming model popularized by <a href="https://streamlit.io/">Streamlit</a> had been adapted for Java by this initiative, which is cool.😎 So I started to evaluate it as part of may java development ecosystem and below i’ll share with you my experience about it.</p><h3>What is Javelit 👀</h3><p><a href="https://javelit.io/">Javelit</a> is a tool to quickly build interactive app frontends in Java, particularly for data apps, but it’s not limited to them. It helps you quickly develop rapid prototypes, with a live-reload loop, so that you can quickly experiment and update the app instantly.</p><p><strong>How it works</strong></p><blockquote>Javelit’s architecture allows you to write apps the same way you write plain Java methods. Any time something must be updated on the screen, Javelit reruns your entire Java main method from top to bottom.</blockquote><p>So you have to think about it <strong>as if your entire UI code runs inside a continuous loop</strong> that refreshes whenever something needs updating on the screen.</p><p><a href="https://javelit.io/">Javelit</a> provides developers with a rich set of prebuilt <a href="https://docs.javelit.io/develop/api-reference">components</a> that make it easy to get started.</p><p>Just to provide you an idea of the <a href="https://javelit.io/">Javelit</a> approach below the inevitable “ <em>Hello World</em> “ code snippet</p><pre>/// usr/bin/env jbang &quot;$0&quot; &quot;$@&quot; ; exit $?<br>import io.javelit.core.Jt;<br><br>public class App {<br><br>    public static void main(String[] args) {<br>        Jt.title(&quot;Hello World!&quot;).use();<br>        Jt.markdown(&quot;&quot;&quot;<br>            ## My first official message<br>            Hello World!<br>            &quot;&quot;&quot;).use();<br>    }<br>}</pre><p>Then, once <a href="https://javelit.io/">Javelit</a> is <a href="https://docs.javelit.io/get-started/installation/standalone#install-javelit">installed</a>, you’d run it with the following command:</p><h3>Use Javelit with LangGraph4j</h3><p>I’ve decided to use <a href="https://javelit.io/">Javelit</a> to develop some examples of <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> usage and below, I show you how have used <a href="https://javelit.io/">Javelit</a> to implement a demo app to run the <strong>LangGraph4j powered React Agent</strong>. For simplicity I’ve reported only the meaningful code snippets, but for a complete code take a look to<a href="https://github.com/langgraph4j/langgraph4j/blob/main/spring-ai/spring-ai-agent/src/test/java/JtAgentExecutorApp.java">JtAgentExecutorApp.java</a> for <a href="https://spring.io/projects/spring-ai#overview">spring AI</a> based implementation.</p><p>As <a href="https://streamlit.io/">Streamlit</a> in <a href="https://javelit.io/">Javelit</a> entire application consist in just one main() method.</p><pre>public class JtAgentExecutorApp {<br><br>    public static void main(String[] args) {<br><br>        Jt.title(&quot;LangGraph4J React Agent&quot;).use();<br><br>        try {<br>            // create a LangGraph4j Agent<br>            var agent = AgentExecutor.builder()<br>                .chatModel(/* instantiate the preferred ChatModel */)<br>                .toolsFromObject( new MyTools() /* Custom Tools */  )<br>                .build()<br>                .compile(); <br><br>            // input: the user message<br>            var userMessage = Jt.textArea(&quot;user message:&quot;)<br>                    .placeholder(&quot;user message&quot;)<br>                    .labelVisibility(JtComponent.LabelVisibility.HIDDEN)<br>                    .use();<br><br>            // button: start agent processing <br>            var start = Jt.button(&quot;start agent&quot;)<br>                    .disabled(userMessage.isBlank())<br>                    .use();<br><br>            if (start) { // if button pressed<br><br>                var outputComponent = Jt.expander(&quot;Workflow Steps&quot;).use();<br><br>                var input = GraphInput.args(Map.of(&quot;messages&quot;, new UserMessage(userMessage)));<br><br>                var generator = agent.stream(input);<br><br>                final var startTime = Instant.now();<br><br>                for( var step : generator ) {<br>                <br>                    Jt.sessionState().remove(&quot;streaming&quot;);<br>                    Jt.info(&quot;&quot;&quot;<br>                            #### %s<br>                            %s<br>                            &quot;&quot;&quot;.formatted(s.node(),<br>                            s.state().messages().stream()<br>                                    .map(Object::toString)<br>                                    .collect(Collectors.joining(&quot;\n\n&quot;)))<br>                    ).use(outputComponent);<br>                }<br><br>                final var elapsedTime = Duration.between(startTime, Instant.now());<br><br>                Jt.success(&quot;finished in %ds%n&quot;.formatted(elapsedTime.toSeconds())).use();<br>                <br>            }<br>        } catch (Exception e) {<br>            Jt.error(e.getMessage()).use();<br>        }<br><br>    }<br><br>}</pre><p>The output of the <a href="https://javelit.io/">Javelit</a> app looks like:</p><p><strong>Chat model selection view</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2X0U0tkmqYH6phOs.png" /></figure><p><strong>Start agent view</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kOEqo56P8qxVYBiJ.png" /></figure><p><strong>Results view</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K1uh-BXiDs3XprC9.png" /></figure><h3>👉 try yourself 👀 🚀 🤯</h3><p>If you want try yourself (after installed <a href="https://javelit.io/">javelit</a>) run the command</p><pre>javelit run https://github.com/langgraph4j/langgraph4j/tree/main/spring-ai/spring-ai-agent/src/test/java</pre><h3>Conclusion</h3><p><a href="https://javelit.io/">Javelit</a> brings the power of rapid prototyping and interactive web app development to the Java ecosystem, much like <a href="https://streamlit.io/">Streamlit</a> does for Python. With its simple, loop-based programming model, developers can quickly build data-driven applications without needing extensive frontend knowledge, leveraging familiar Java syntax and the rich JVM ecosystem. The live-reload feature enables instant experimentation and iteration, making it ideal for prototyping AI agents, data visualizations, and interactive tools. By integrating seamlessly with libraries like <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> combined with both <a href="https://spring.io/projects/spring-ai#overview">Spring AI</a> and <a href="https://docs.langchain4j.dev/">LangChain4j</a>, <a href="https://javelit.io/">Javelit</a> empowers Java developers to create engaging user interfaces effortlessly, bridging the gap between backend logic and user-facing applications.</p><p>Checkout project, try it and let me know your feedback and … happy coding! 👋</p><h3>References</h3><ul><li><a href="https://glaforge.dev/posts/2025/10/24/javelit-to-create-quick-interactive-app-frontends-in-java/">Javelit to create quick interactive app frontends in Java</a></li></ul><p><em>Originally published at </em><a href="https://bsorrentino.github.io/bsorrentino/ai/2025/12/20/Experiment-Javelit-Streamlit-for-Java.html"><em>https://bsorrentino.github.io</em></a><em> on December 20, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd09747d0559" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/experimenting-with-javelit-the-streamlit-for-java-fd09747d0559">Experimenting with Javelit — The Streamlit for Java</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ LangGraph4j Deep Agents (Agents 2.0)]]></title>
            <link>https://blog.devgenius.io/langgraph4j-deep-agents-agents-2-0-e380153de21d?source=rss-b9c2251c0e92------2</link>
            <guid isPermaLink="false">https://medium.com/p/e380153de21d</guid>
            <category><![CDATA[spring-ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[langgraph4j]]></category>
            <dc:creator><![CDATA[Bartolomeo Sorrentino]]></dc:creator>
            <pubDate>Fri, 17 Oct 2025 00:00:13 GMT</pubDate>
            <atom:updated>2025-10-21T11:15:30.233Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*xkkIKsdCKRL__CDD.png" /></figure><h3>Why Deep Agents (Agent 2.0)?</h3><p>Classic agents often run a simple loop: <strong>think → call a tool → observe → repeat</strong>. That’s great for quick, transactional queries, but it breaks down on multi-hour or multi-day tasks (hallucinations, loss of goal, looping, no recovery).<br><strong>Deep Agents</strong> try fix this by <strong>changing the architecture</strong> (not just the prompt) based on the four pillars below:</p><ol><li><strong>Explicit Planning</strong> — The agent continuously maintains a plan (e.g., a TODO in Markdown) with clear statuses instead of hiding intent in a just chain-of-thought.</li><li><strong>Hierarchical Delegation (Sub-Agents)</strong> — An <strong>Orchestrator</strong> delegates to specialized agents (Researcher, Coder, Writer, …), each working in a clean context and returning synthesized results.</li><li><strong>Persistent Memory</strong> — Intermediate artifacts (notes, code, data) are written to external storage (filesystem, vector store, …) and referenced by path/query rather than stuffing everything into the context window.</li><li><strong>Extreme Context Engineering</strong> — Long, specific instructions define: when to plan vs. act, when to spawn sub-agents and the human-in-the-loop(HITL) rules.</li></ol><h3>Reference Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uWin-8RQ6b0zNVnB.png" /></figure><h3>Reference Implementation in Java using LangGraph4j</h3><p>Since the <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> is inpired by (more popular) <a href="https://github.com/langchain-ai/langgraph">LangGraph</a> python version, I’ve decided to adapt its python based <a href="https://github.com/langchain-ai/deepagents">Deep Agents reference implementation</a> to Java using <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> and <a href="https://spring.io/projects/spring-ai">Spring AI</a>.</p><p>The project is on <a href="https://github.com/langgraph4j/langgraph4j-deepagents.git">Github</a>. This repository demonstrates the four pillars of Deep Agents, it includes sample code that create a <strong>Deep Researcher Agent</strong> that use <a href="https://www.tavily.com/">Tavily</a> as web search engine and <strong>OpenAI gpt-4o-mini model</strong>.</p><p>Let’s look at a sequence diagram for a Deep Agent handling a complex request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TkHS0-rxMwv7jtgm.png" /></figure><p>Below a representative code snippet that implements the Deep Agents in the diagram</p><pre>// Create a Research Sub Agent<br>var researchSubagent = DeepAgent.SubAgent.builder()<br>    .name(&quot;research-agent&quot;)<br>    .description(&quot;&quot;&quot;<br>        Used to research more in depth questions. Only give this researcher one topic at a time.<br>        Do not pass multiple sub questions to this researcher.<br>        Instead, you should break down a large topic into the necessary components, and then call multiple research agents in parallel, one for each sub question.<br>        &quot;&quot;&quot;)<br>    .prompt(&quot;&quot;&quot;<br>        You are a dedicated researcher. Your job is to conduct research based on the users questions.<br>        Conduct thorough research and then reply to the user with a detailed answer to their question<br><br>        ........(to be continued).............. <br>        &quot;&quot;&quot;)<br>    .tools( List.of( &quot;internet_search&quot; ))<br>    .build();<br><br>// Create a Critique Sub Agent<br>var critiqueSubAgent =  DeepAgent.SubAgent.builder()<br>        .name(&quot;critique-agent&quot;)<br>        .description(&quot;Used to critique the final report. Give this agent some information about how you want it to critique the report.&quot;)<br>        .prompt(&quot;&quot;&quot;<br>            You are a dedicated editor. You are being tasked to critique a report.<br>            <br>            You can find the report at `final_report.md`.<br>            <br>            You can find the question/topic for this report at `question.txt`.<br>            <br>            ........(to be continued).............. <br>            &quot;&quot;&quot;)<br>        .build();<br>        <br>// Create a Main Agent<br>var deepAgent = DeepAgent.builder()<br>        .instructions(&quot;&quot;&quot;<br>        You are an expert researcher. Your job is to conduct thorough research, and then write a polished report.<br>        <br>        The first thing you should do is to write the original user question to `question.txt` so you have a record of it.<br>        <br>        Use the research-agent to conduct deep research. It will respond to your questions/topics with a detailed answer.<br>        <br>        When you think you enough information to write a final report, write it to `final_report.md`<br>        <br>        You can call the critique-agent to get a critique of the final report. After that (if needed) you can do more research and edit the `final_report.md`<br>        <br>        ........(to be continued).............. <br>        <br>        &quot;&quot;&quot;)<br>        .subAgents( List.of( researchSubagent, critiqueSubAgent ))<br>        .chatModel(chatModel)<br>        .tools( List.of( tools.internetSearch()) )<br>        .build()<br>        .compile( CompileConfig.builder()<br>                .recursionLimit(100)<br>                .build());<br><br>        var userMessage = &quot;&quot;&quot;<br>                        What is langgraph4j project?<br>                        &quot;&quot;&quot;;<br><br>        var runnableConfig = RunnableConfig.builder().build();<br><br>        var result = agent.stream(<br>                        Map.of(&quot;messages&quot;, new UserMessage(userMessage), <br>                        runnableConfig );<br><br>        var output = result.stream()<br>                .peek(s -&gt; System.out.println(s.node()) )<br>                .reduce((a, b) -&gt; b)<br>                .orElseThrow();<br><br>        System.out.println( &quot;&quot;&quot;<br>        ================================<br>        TODO<br>        ================================<br>        &quot;&quot;&quot;);<br>        output.state().todos().forEach((value) -&gt; System.out.printf(&quot;&quot;&quot;<br>                -----------<br>                %s<br>                -----------<br>                &quot;&quot;&quot;, value));<br>        System.out.println( &quot;&quot;&quot;<br>        ================================<br>        FILES<br>        ================================<br>        &quot;&quot;&quot;);<br>        output.state().files().forEach((key, value) -&gt; System.out.printf(&quot;&quot;&quot;<br>                file: &#39;%s&#39;<br>                -----------<br>                %s<br>                -----------<br>                &quot;&quot;&quot;, key, value));<br><br>        System.out.println( &quot;&quot;&quot;<br>        ================================<br>        FINAL RESULT<br>        ================================<br>        &quot;&quot;&quot;);<br>        System.out.printf( &quot;result: %s\n&quot;,<br>                output.state().lastMessage()<br>                        .map(AssistantMessage.class::cast)<br>                        .map(AssistantMessage::getText)<br>                        .orElseThrow());</pre><h3>Conclusions</h3><p>Deep Agents architecture is a try <strong>to move beyond one-loop “shallow” agents</strong> to explicit planning hierarchical delegation, persistent memory, and rigorous context engineering. <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> can help to experiment in Labs and deliver in production complex Agentic Workflow on top of JVM. Checkout project, try it and let me know your feedback and … happy AI coding! 👋</p><h3><strong>References</strong></h3><ul><li><a href="https://blog.langchain.com/deep-agents/">Deep Agents (LangChain Blog)</a></li><li><a href="https://github.com/hwchase17/deepagents">Langchain Deepagents (Github)</a></li><li><a href="https://www.philschmid.de/agents-2.0-deep-agents">Agents 2.0: From Shallow to Deep Agents (Phil Schmid Blog)</a></li></ul><p><em>Originally published at </em><a href="https://bsorrentino.github.io/bsorrentino/ai/2025/10/17/langgraph4j-deepagents.html"><em>https://bsorrentino.github.io</em></a><em> on October 17, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e380153de21d" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/langgraph4j-deep-agents-agents-2-0-e380153de21d">🧠🤖 LangGraph4j Deep Agents (Agents 2.0)</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LangGraph4j Meets AG-UI — Building UI/UX in the AI Agents era]]></title>
            <link>https://blog.devgenius.io/langgraph4j-meets-ag-ui-building-ui-ux-in-the-ai-agents-era-91d7e9e4d694?source=rss-b9c2251c0e92------2</link>
            <guid isPermaLink="false">https://medium.com/p/91d7e9e4d694</guid>
            <category><![CDATA[copilotkit]]></category>
            <category><![CDATA[langgraph4j]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ag-ui]]></category>
            <dc:creator><![CDATA[Bartolomeo Sorrentino]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 00:00:40 GMT</pubDate>
            <atom:updated>2025-08-23T17:48:44.876Z</atom:updated>
            <content:encoded><![CDATA[<h3>LangGraph4j Meets AG-UI — Building UI/UX in the AI Agents era</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*iDB5Z0eKNRmgCegq.png" /></figure><h3>AI Agents ecosystem evolution</h3><p>The rapid evolution of artificial intelligence has brought a new wave of innovation: the rise of AI agents. These agents-autonomous, intelligent, and capable of interacting with users and services-are changing how we build applications, automate workflows, and even communicate online. However, as this ecosystem expands, a new challenge has emerged: interoperability. How can these agents reliably talk to each other, work with external tools, and offer seamless experiences to human users?</p><p>This challenge has led to the development of new standards-protocols that define how AI agents communicate with the world and each other. Among the most notable are:</p><ul><li><a href="https://modelcontextprotocol.io/">MCP</a> (<strong>Agent-to-Tools</strong>) <br>Standardizing Agent to Tools/Services Communication</li><li><a href="https://a2aprotocol.ai/">A2A</a> (<strong>Agent-to-Agent Protocol</strong>)<br>Standardizing Agent to Agent Communication</li><li><a href="https://ag-ui.com/">AG-UI</a> (<strong>Agent-to-User</strong>)<br>Standardizing Agent to User Communication</li></ul><blockquote><strong>In this article we will focus on </strong><a href="https://ag-ui.com/"><strong>AG-UI</strong></a><strong> protocol an how it helps us to develop an effective User eXperience in using AI Agents</strong></blockquote><h3>What is AG-UI protocol ?</h3><p><a href="https://ag-ui.com/">AG-UI</a> bridges the gap between AI agents and their human users, ensuring that interactions are intuitive, consistent, and user-friendly. It defines the structure for how agents present information, take user input, and handle conversations-regardless of the underlying platform or application.</p><h3>Why AG-UI Compliance Matters</h3><p>By aligning with AG-UI, LangGraph4j agents can present rich, interactive interfaces to user, whether embedded in web apps, desktop tools, or chatbots. This standardization means that developers can focus on building great agent logic, while relying on AG-UI to handle the complexities of user interaction.</p><h3>LangGraph4j and AG-UI</h3><p><a href="https://github.com/langgraph4j/langgraph4j"><strong>LangGraph4j</strong></a> is a Java-based framework designed for building and orchestrating AI agent workflows. It is already capable to use <a href="https://modelcontextprotocol.io/"><strong>MCP</strong></a> servers inside workflow steps and has also experimented integration with <a href="https://a2aprotocol.ai/"><strong>A2A</strong></a> (see <a href="https://github.com/langgraph4j/langgraph4j-examples/blob/main/spring-ai/a2a-server-implby-a2a4j">here</a>).</p><h3>Copilotkit integration</h3><p>With its latest project, <a href="https://github.com/langgraph4j/langgraph4j-copilotkit">langgraph4j-copilotkit</a>, we have evaluated how to make <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> compliant with the <a href="https://ag-ui.com/">AG-UI</a> protocol, integrating <a href="https://www.copilotkit.ai/">CopilotKit</a> that is its reference implementation for help and enhance developer experience in building better either User Interfaces (UI) and User eXperience (UX).</p><h3>Architecture</h3><p>The architecture of the <a href="https://github.com/langgraph4j/langgraph4j-copilotkit">langgraph4j-copilotkit</a> integration is designed to enable seamless communication between a user-facing frontend and the <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> backend. Here’s a breakdown of the key components and their interactions:</p><p>The following diagram illustrates a diagram that shows the sequence of messages exchanged between main actors of the architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ag2E5P4HngWwsJH5.png" /></figure><p><strong>Explanation of the diagram:</strong></p><ol><li><strong>User &amp; Frontend (CopilotKit):</strong> The user interacts with a web application that has the <a href="https://www.copilotkit.ai/">CopilotKit</a> SDK integrated. CopilotKit handles the UI rendering and state management, translating user actions into requests compliant with the <a href="https://ag-ui.com/">AG-UI</a> protocol.</li><li><strong>Backend (langgraph4j-copilotkit):</strong> A backend server, built with a framework like Spring Boot, includes the <a href="https://github.com/langgraph4j/langgraph4j-copilotkit">langgraph4j-copilotkit</a> library. This library exposes an endpoint that listens for <a href="https://ag-ui.com/">AG-UI</a>requests from the frontend. It acts as a bridge, translating incoming requests into executable commands for the <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> agent, and in turn translates the agent’s responses into compatible <a href="https://ag-ui.com/">AG-UI</a> events.</li></ol><p>The communication is typically asynchronous and streaming. As the <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> agent produces results or requires further input, <a href="https://github.com/langgraph4j/langgraph4j-copilotkit">langgraph4j-copilotkit</a> streams these events back to the frontend in the AG-UI format. CopilotKit then dynamically updates the UI, creating a responsive and interactive user experience.</p><p>This architecture decouples the frontend presentation layer from the backend agentic logic, allowing developers to build sophisticated AI agents with <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> while providing a rich, standardized user interface with CopilotKit.</p><h3>Example — Approval action (Human-in-the-Loop)</h3><p>This example demonstrates how to implement a “Human-in-the-Loop” (HITL) approval action using <a href="https://github.com/langgraph4j/langgraph4j-copilotkit">langgraph4j-copilotkit</a>. The user will be asked to approve an action ( sendEmail) before it is executed.</p><h3>Frontend</h3><p>The frontend uses @copilotkit/react-core and @copilotkit/react-ui to create the chat interface and handle the approval action. The useCopilotAction hook is used to define the sendEmail action. When the action is triggered, it renders a confirmation dialog asking the user for approval.</p><p><strong>chatApproval.tsx</strong></p><pre>&quot;use client&quot;;<br>import { useCopilotAction } from &quot;@copilotkit/react-core&quot;;<br>import { CopilotChat } from &quot;@copilotkit/react-ui&quot;;<br> <br>export function SimpleChatWithApproval() {<br>  <br>  useCopilotAction( {<br>    name: &quot;sendEmail&quot;,<br>    description: &quot;Sends an email after user approval.&quot;,<br>    parameters: [<br>      { name: &quot;address&quot;, type: &quot;string&quot; },<br>      { name: &quot;subject&quot;, type: &quot;string&quot; },<br>      { name: &quot;body&quot;, type: &quot;string&quot; },<br>    ],<br>    renderAndWaitForResponse: ({ args, status, respond }) =&gt; {<br>      console.debug( &quot;renderAndWaitForResponse&quot;, respond, status, args );<br><br>      if (status === &quot;inProgress&quot;) {<br>        return (<br>          &lt;div&gt;<br>            &lt;h2&gt;Sending Email&lt;/h2&gt;<br>            &lt;p&gt;Preparing to send email...&lt;/p&gt;<br>          &lt;/div&gt;<br>        );<br>      }<br>      if (status === &quot;executing&quot;) {<br>        return (<br>            &lt;div&gt;<br>              &lt;h2&gt;Confirm Email&lt;/h2&gt;<br>              &lt;p&gt;Send email to &lt;b&gt;{args.address}&lt;/b&gt; with subject &quot;&lt;b&gt;{args.subject}&lt;/b&gt;&quot;?&lt;/p&gt;<br>              &lt;p&gt;&lt;i&gt;{args.body}&lt;/i&gt;&lt;/p&gt;<br>              &lt;div&gt;<br>                &lt;button onClick={() =&gt; respond?.(&#39;APPROVED&#39;)}&gt;<br>                  Approve<br>                &lt;/button&gt;<br>                &lt;button onClick={() =&gt; respond?.(&#39;REJECTED&#39;)}&gt;<br>                  Cancel<br>                 &lt;/button&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          );<br>      }<br>     return &lt;&gt;&lt;/&gt;<br>  }});<br><br>  return (<br>    &lt;CopilotChat<br>      instructions={&quot;You are assisting the user as best as you can. Answer in the best way possible given the data you have.&quot;}<br>      labels={{<br>        title: &quot;Your Assistant&quot;,<br>        initial: &quot;Hi! 👋 How can I assist you today?&quot;,<br>      }}<br>      className=&quot;w-full&quot;<br>    /&gt;<br>  );<br><br>}</pre><h3>LangGraph4j Agent</h3><p>The backend is a <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> agent that defines the sendEmail tool. The AgentExecutorEx is configured to require approval for the sendEmail tool. When the tool is about to be executed, the agent will be interrupted, and an approval request will be sent to the frontend.</p><p><strong>AGUIAgentExecutor.java</strong>:</p><pre>public class AGUIAgentExecutor extends AGUILangGraphAgent {<br>    // define tools<br>    public static class Tools {<br><br>        @Tool( description = &quot;Send an email to someone&quot;)<br>        public String sendEmail(<br>                @ToolParam( description = &quot;destination address&quot;) String to,<br>                @ToolParam( description = &quot;subject of the email&quot;) String subject,<br>                @ToolParam( description = &quot;body of the email&quot;) String body<br>        ) {<br>            // This is a placeholder for the actual implementation<br>            return format(&quot;mail sent to %s with subject %s&quot;, to, subject);<br>        }<br>    }<br><br>    @Override<br>    GraphData buildStateGraph() throws GraphStateException {<br><br>        // Create agent<br>        var agent =  AgentExecutorEx.builder()<br>                .chatModel(LLM, true)<br>                .toolsFromObject(new Tools())<br>                .approvalOn( &quot;sendEmail&quot;,<br>                         (nodeId, state ) -&gt;<br>                                        InterruptionMetadata.builder( nodeId, state )<br>                                        .build()<br>                )<br>                .build();<br><br>        return new GraphData( agent ) ;<br>    }<br><br>    // invoked on interruption to provide approval information back to the client<br>    @Override<br>    &lt;State extends AgentState&gt; List&lt;Approval&gt; onInterruption(AGUIType.RunAgentInput input, InterruptionMetadata&lt;State&gt; metadata ) {<br><br>        var messages = metadata.state().value(&quot;messages&quot;);<br>                .orElseThrow( () -&gt; new IllegalStateException(&quot;messages not found into given state&quot;));<br><br>        return lastOf(messages)<br>                .flatMap(MessageUtil::asAssistantMessage)<br>                .filter(AssistantMessage::hasToolCalls)<br>                .map(AssistantMessage::getToolCalls)<br>                .map( toolCalls -&gt;<br>                    toolCalls.stream().map( toolCall -&gt; {<br>                        var id = toolCall.id().isBlank() ?<br>                                UUID.randomUUID().toString() :<br>                                toolCall.id();<br>                        return new Approval( id, toolCall.name(), toolCall.arguments() );<br>                    }).toList()<br>                )<br>                .orElseGet(List::of);<br><br>    }<br>}</pre><p>This setup allows for a seamless HITL workflow where the user has the final say on critical actions, all orchestrated through the AG-UI protocol and the <a href="https://github.com/langgraph4j/langgraph4j-copilotkit">langgraph4j-copilotkit</a> integration.</p><h3>Demo</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bXVkXRy3OBAvr8gw.gif" /></figure><h3>Conclusion</h3><p>We can state that the future of AI development will be to have a <strong>Unified AI Agent Ecosystem</strong>. The convergence of these standards like <a href="https://modelcontextprotocol.io/">MCP</a>, <a href="https://a2aprotocol.ai/">A2A</a>, and <a href="https://ag-ui.com/">AG-UI</a> is a step toward this vision.</p><p>We consider crucial keep working to improve support of them in <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> to provide a complete infrastructure for AI Agents to communicate with tools, collaborate with each other, and engage users in a standardized and interoperable manner.</p><p>As more frameworks and tools adopt these protocols, we can expect to see a new generation of AI-powered applications that are more flexible, extensible and, with <a href="https://ag-ui.com/">AG-UI</a>, more user-centric than ever before.</p><p>Hope this could help your AI Java developing journey, in the meanwhile happy AI coding! 👋</p><p><em>Originally published at </em><a href="https://bsorrentino.github.io/bsorrentino/ai/2025/08/21/LangGraph4j-meets-AG-UI.html"><em>https://bsorrentino.github.io</em></a><em> on August 21, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91d7e9e4d694" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/langgraph4j-meets-ag-ui-building-ui-ux-in-the-ai-agents-era-91d7e9e4d694">LangGraph4j Meets AG-UI — Building UI/UX in the AI Agents era</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pause and Resume in Agentic Flows with LangGraph-Swift]]></title>
            <link>https://blog.devgenius.io/implementing-pause-and-resume-in-agentic-flows-with-langgraph-swift-4e481ca1bab4?source=rss-b9c2251c0e92------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e481ca1bab4</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[langgraph]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Bartolomeo Sorrentino]]></dc:creator>
            <pubDate>Fri, 25 Jul 2025 00:00:56 GMT</pubDate>
            <atom:updated>2025-07-28T18:24:11.666Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*wwVikzGdqod4QQUn.png" /></figure><h3>Introduction</h3><p>After the <a href="https://medium.com/dev-genius/ai-agent-on-ios-with-langgraph-for-swift-30411589852d">AI Agent on iOS with LangGraph for Swift article</a> , in this article I’ll present you the new release of <a href="https://github.com/bsorrentino/LangGraph-Swift">LangGraph-Swift</a> project supporting the <strong>Human-In-The-Loop (HITL)</strong> use cases. This is part of my effort to port the Agentic Workflow framework inspired to <a href="https://github.com/langchain-ai/langgraph">LangGraph</a> on the iOS platform.</p><h3>Human-In-The-Loop</h3><p>Agentic workflows often require human intervention for tasks like approval, verification, or handling exceptions. <a href="https://github.com/bsorrentino/LangGraph-Swift">LangGraph-Swift</a>, a library for building stateful, multi-agent applications, provides a powerful mechanism to pause and resume these workflows, enabling seamless <strong>Human-in-the-Loop</strong> (HITL) scenarios.</p><p>This article explores how to implement this functionality using the library’s capabilities.</p><h3>Key Concepts</h3><p>The core of <a href="https://github.com/bsorrentino/LangGraph-Swift">LangGraph-Swift</a>&#39;s pause and resume capability are the following key components:</p><ul><li><strong>CheckpointSaver</strong>:<br>This protocol defines the interface for saving and retrieving Checkpoints that hold workflow states. The library provides an in-memory implementation, MemoryCheckpointSaver, which is perfect for getting started.</li><li><strong>CompileConfig</strong>:<br>This struct allows you to configure the compilation of your StateGraph, including specifying a CheckpointSaver and defining interruption points.</li><li><strong>RunnableConfig</strong>:<br>This struct provides a way to pass configuration information to a running graph, such as a thread ID (aka Session)or a Checkpoint ID to resume from.</li><li><strong>GraphInput</strong>:<br>This enum represents the input to a graph, which can be either initial arguments (.args) or a resume signal (.resume).</li></ul><h3>Enabling Workflow Interruptions</h3><p>To enable interruptions, you need to configure your StateGraph with a CheckpointSaver and specify the nodes before which the workflow should pause. This is done using the CompileConfig struct when you compile the graph.</p><p>Let’s look at an example.</p><blockquote><em>The following code snippet is based on the </em><em>testRunningWithInterruption method in </em><a href="https://github.com/bsorrentino/LangGraph-Swift/blob/main/Tests/LangGraphTests/LangGraphTests.swift#L591"><em>LangGraphTests.swift</em></a><em>.</em></blockquote><p>First, we define a simple StateGraph with three nodes: agent_1, agent_2, and sum. agent_1 and agent_2 provide numbers, and sum calculates their sum.</p><pre>@Test<br>func testRunningWithInterruption() async throws {<br>    <br>    // Build the workflow with an initial state<br>    let workflow = try StateGraph { BinaryOpState($0) }<br>    <br>    // Add node &quot;agent_1&quot; that returns &quot;add1&quot;: 37<br>    .addNode(&quot;agent_1&quot;) { state in<br>        return [&quot;add1&quot;: 37]<br>    }<br>    // Add node &quot;agent_2&quot; that returns &quot;add2&quot;: 10<br>    .addNode(&quot;agent_2&quot;) { state in<br>        return [&quot;add2&quot;: 10]<br>    }<br>    // Add node &quot;sum&quot; that sums add1 and add2<br>    .addNode(&quot;sum&quot;) { state in<br>        return [&quot;result&quot;: state.add1 + state.add2 ]<br>    }<br>    // Define the edges between nodes<br>    .addEdge(sourceId: &quot;agent_1&quot;, targetId: &quot;agent_2&quot;)<br>    .addEdge(sourceId: &quot;agent_2&quot;, targetId: &quot;sum&quot;)<br>    .addEdge( sourceId: START, targetId: &quot;agent_1&quot;)<br>    .addEdge(sourceId: &quot;sum&quot;, targetId: END )</pre><p>Now, we compile the graph with a CompileConfig that specifies our MemoryCheckpointSaver and tells the graph to interrupt before the sum node.</p><pre>// Create a memory-based checkpoint saver<br>let saver = MemoryCheckpointSaver()<br><br>// Compile the workflow, instructing it to interrupt before executing &quot;sum&quot;<br>let app = try workflow.compile( config: .init(checkpointSaver: saver, interruptionsBefore: [&quot;sum&quot;]) )</pre><p>When we run the graph, it will execute up to the point of the interruption and then pause.</p><pre>let runnableConfig = RunnableConfig()<br>    <br>let initValue:( lastState:BinaryOpState?, nodes:[String]) = ( nil, [] )<br>    <br>// Start workflow execution — it will stop before running &quot;sum&quot;<br>let result = try await app.stream( .args([:]), config: runnableConfig )<br>                                .reduce( initValue, { partialResult, output in<br>                                    return ( output.state,  partialResult.1 + [output.node ] )<br>                                })<br>    <br>// Verify that &quot;add1&quot; and &quot;add2&quot; are present but not &quot;result&quot;<br>#expect( dictionaryOfAnyEqual( [&quot;add1&quot;: 37, &quot;add2&quot;: 10], result.lastState!.data ) )</pre><p>At this point, the workflow is paused. The MemoryCheckpointSaver contains the state of the workflow, and we can inspect it to see that the sum node has not yet been executed.</p><h3>Resuming the Workflow</h3><p>To resume the workflow, we need to get the last checkpoint from the CheckpointSaver and pass it to the graph&#39;s stream method with a .resume input.</p><pre>// Retrieve last checkpoint and verify its position<br>let lastCheckpoint = try #require( saver.last(config: runnableConfig) )<br>#expect( lastCheckpoint.nodeId == &quot;agent_2&quot; )<br>#expect( lastCheckpoint.nextNodeId == &quot;sum&quot; )<br><br>// Resume from last checkpoint and complete execution<br>let runnableConfigToResume = runnableConfig.with { $0.checkpointId = lastCheckpoint.id }<br><br>let initValue:( lastState:BinaryOpState?, nodes:[String]) = ( nil, [] )<br><br>let result = try await app.stream( .resume, config: runnableConfigToResume )<br>                            .reduce( initValue, { partialResult, output in<br>                                return ( output.state,  partialResult.1 + [output.node ] )<br>                            })<br><br>// Verify that &quot;result&quot; has now been computed<br>#expect( dictionaryOfAnyEqual(  [&quot;add1&quot;: 37, &quot;add2&quot;: 10, &quot;result&quot;:  47 ],<br>                                    result.lastState!.data) )</pre><p>The workflow will now resume from where it left off and execute the sum node, producing the final result.</p><h3>Updating State During an Interruption</h3><p><a href="https://github.com/bsorrentino/LangGraph-Swift">LangGraph-Swift</a> also allows you to update the state of the workflow while it is paused. This is useful for scenarios where a human needs to provide additional information or modify the existing state before the workflow continues.</p><p>The updateState method on the compiled graph allows you to do this.</p><pre>// Resume the third run with updated state: change add2 from 10 to 13<br>let lastCheckpoint = try #require( saver.last(config: runnableConfig) )<br><br>var runnableConfigToResume = try await app.updateState(<br>                            config: runnableConfig.with { $0.checkpointId = lastCheckpoint4.id }, <br>                            values: [&quot;add2&quot;: 13] )<br>    <br>// Resume and complete execution with updated value<br>let initValue:( lastState:BinaryOpState?, nodes:[String]) = ( nil, [] )<br><br>let result = try await app.stream( .resume, config: runnableConfigToResume )<br>                                .reduce( initValue, { partialResult, output in<br>                                    return ( output.state,  partialResult.1 + [output.node ] )<br>                                })<br>    <br>// Verify that &quot;result&quot; now reflects the updated input<br>#expect( dictionaryOfAnyEqual(  [&quot;add1&quot;: 37, &quot;add2&quot;: 13, &quot;result&quot;: 50 ],<br>                                    result.lastState!.data) )</pre><p>In this example, we update the value of add2 to 13 before resuming the workflow. After resuming the final result will then be 50, reflecting the updated state 👍🏻.</p><h3>Conclusion</h3><p><a href="https://github.com/bsorrentino/LangGraph-Swift">LangGraph-Swift</a>&#39;s pause and resume functionality is a powerful tool for building sophisticated agentic workflows that require human interaction. By using CheckpointSaver, CompileConfig, and RunnableConfig, you can easily implement HITL scenarios, such as approval flows, and give users the ability to interact with and control your agents. We encourage Swift developers to explore this project and contribute to its growth and development. In the meanwhile, enjoy coding! 👋</p><p><em>Originally published at </em><a href="https://bsorrentino.github.io/bsorrentino/ai/2025/07/25/Langgraph-Swift-HITL.html"><em>https://bsorrentino.github.io</em></a><em> on July 25, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e481ca1bab4" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/implementing-pause-and-resume-in-agentic-flows-with-langgraph-swift-4e481ca1bab4">Pause and Resume in Agentic Flows with LangGraph-Swift</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LangGraph4j — Implementing Human-in-the-Loop at ease]]></title>
            <link>https://blog.devgenius.io/langgraph4j-implementing-human-in-the-loop-at-ease-0ca77d366d8c?source=rss-b9c2251c0e92------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ca77d366d8c</guid>
            <category><![CDATA[spring-ai]]></category>
            <category><![CDATA[langchain4j]]></category>
            <category><![CDATA[agentic-workflow]]></category>
            <category><![CDATA[human-in-the-loop]]></category>
            <category><![CDATA[langgraph4j]]></category>
            <dc:creator><![CDATA[Bartolomeo Sorrentino]]></dc:creator>
            <pubDate>Sun, 13 Jul 2025 00:00:06 GMT</pubDate>
            <atom:updated>2025-07-18T13:08:28.594Z</atom:updated>
            <content:encoded><![CDATA[<h3>LangGraph4j — Implementing Human-in-the-Loop at ease</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*zUIyUXHOeNrkOZ_-.png" /></figure><h3>Key takeaways</h3><p>This article will guide you through the process of evolving a classic ReAct agent to support a human approval workflow using the <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> library. We&#39;ll see how the <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> architecture makes it straightforward to implement such control flows. In particular we focus on:</p><ul><li>How to evolve the classical Agent Executor implementation (refer to <strong>Diagram 1</strong>) to support a human approval flow.</li><li>Move from the standard agent loop to an extended agent loop supporting an action dispatcher and a node for each action (see <strong>Diagram 2</strong>).</li><li>Wrap an action with an approval node (see <strong>Diagram 3</strong>).</li><li>A detailed implementation example using <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> integrated with <a href="https://github.com/langchain4j/langchain4j">LangChain4j</a> .</li></ul><h3>Introduction</h3><p>In the world of AI agents, especially those performing actions with real-world consequences, ensuring control and oversight is crucial. The “Human-in-the-Loop” (HITL) pattern is a critical design choice that introduces a step for human approval before an agent executes an action with potentially impacting consequences. This not only enhances safety but also builds trust in the system that is exactly what we want our customers feels when we deliver in production AI powered workflows.</p><h3>From the standard agent to agent with approval</h3><h3>The standard ReAct Agent</h3><p>The standard ReAct (Reasoning and Acting) agent operates in a simple loop. The agent (or model) reasons about a problem, decides on an action (a tool to use), executes it, observes the result, and repeats the cycle until the task is complete.</p><p>This flow can be visualized as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/0*vuvvGHq9tnqwsiZH.png" /><figcaption><strong><em>Diagram 1</em></strong><em>: A simple, cyclical agent that alternates between reasoning (agent) and execution (action).</em></figcaption></figure><p>While effective for many tasks, this simple loop lacks a clear entry point for external intervention. How can we pause the agent and ask for permission before it calls a specific tool?</p><h3>Evolving the Agent: The Action Dispatcher</h3><p>To introduce more control, we first need to make the agent’s action-taking process more modular. Instead of a single “action” step, we can introduce an “action dispatcher.” This node is responsible for routing the agent’s intent to the correct tool-specific node.</p><p>This architectural shift gives us a more granular and flexible graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/0*6RpLgddoEO_90n1Y.png" /><figcaption><strong><em>Diagram 2</em></strong><em>: The dispatcher model. The model decides which action to take, and the dispatcher routes the execution to the appropriate action node.</em></figcaption></figure><p>Now, each tool ( action1, action2, etc.) is a distinct node in our graph. This separation is the key to enabling fine-grained control.</p><h3>Introducing the Human Approval Workflow</h3><p>With our modular dispatcher in place, we can now insert an approval node before any action that requires oversight. Let’s say we want to require human approval before executing action2.</p><p>We can introduce a new node, approval_action2, that intercepts the request from the dispatcher. This node&#39;s job is to pause the execution and wait for external input.</p><p>The workflow is as follows:</p><ol><li>The model decides to run action2.</li><li>The action_dispatcher routes the request to the approval_action2 node.</li><li>The approval_action2 node waits for a human to either <strong>APPROVE</strong> or <strong>REJECT</strong> the action.</li><li>If <strong>APPROVED</strong>, the graph transitions to the actual execTest (action2) node to execute the tool.</li><li>If <strong>REJECTED</strong>, the graph transitions back to the model, informing it that the action was denied. The model can then use this information to reconsider its plan.</li></ol><p>This creates a robust and safe execution flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/0*6qJ59ZaCR2zPILSu.png" /><figcaption><strong><em>Diagram 3</em></strong><em>: The complete HITL workflow. The </em><em>approval_action2 node acts as a gatekeeper for </em><em>action2.</em></figcaption></figure><p>A Practical Example</p><h3>LangGraph4j implementation notes</h3><p><a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> provides a standard <a href="https://langgraph4j.github.io/langgraph4j/apidocs/org/bsc/langgraph4j/agentexecutor/AgentExecutor.html">AgentExecutor</a> (aka ReACT Agent) implementation and an extended one, <a href="https://langgraph4j.github.io/langgraph4j/apidocs/org/bsc/langgraph4j/agentexecutor/AgentExecutorEx.html">AgentExecutorEx</a>, which supports a human approval workflow. These implementations are available with both <a href="https://github.com/langchain4j/langchain4j">LangChain4j</a> and <a href="https://spring.io/projects/spring-ai">Spring AI</a> integrations.</p><blockquote><em>In this article, we will focus on the integration with </em><a href="https://github.com/langchain4j/langchain4j">LangChain4j</a><em> (see the implementation in </em><a href="https://github.com/langgraph4j/langgraph4j/tree/main/langchain4j/langchain4j-agent"><em>langchain4j-agent</em></a><em> module) but it is available also using </em><a href="https://spring.io/projects/spring-ai">Spring AI</a><em> (see the implementation in </em><a href="https://github.com/langgraph4j/langgraph4j/tree/main/spring-ai/spring-ai-agent"><em>spring-ai-agent</em></a><em> module).</em></blockquote><h3>Let put all together</h3><p>To see how this is implemented in code, you can look at the <a href="https://github.com/langgraph4j/langgraph4j/tree/main/langchain4j/langchain4j-agent/src/test/java/org/bsc/langgraph4j/agentexecutor/app/DemoConsoleController.java">DemoConsoleController.java</a> class within the langchain4j-agent test sources. This example demonstrates how to build and run an agent with a conditional human approval step, showcasing the power and flexibility of <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a>.</p><p>The key is to use <a href="https://langgraph4j.github.io/langgraph4j/apidocs/org/bsc/langgraph4j/agentexecutor/AgentExecutorEx.html">AgentExecutorEx</a> and its approvalOn method. This method allows you to specify a node where the graph execution should be interrupted. When the execution reaches this point, the graph pauses and returns an <a href="https://langgraph4j.github.io/langgraph4j/apidocs/org/bsc/langgraph4j/action/InterruptionMetadata.html">InterruptionMetadata</a> object, which signals that human input is required.</p><p>Here is a code snippet from the example that illustrates how to set up and handle the approval mechanism:</p><pre>// 1. Configure the agent to require approval on the &quot;action2&quot; tool<br>var agent = AgentExecutorEx.builder()<br>        .chatModel(chatModel)<br>        .toolsFromObject( new Tools() ) // add actions &#39;action1&#39;, &#39;action2&#39;<br>        .approvalOn( &quot;action2&quot;, ( nodeId, state ) -&gt;<br>                InterruptionMetadata.builder( nodeId, state )<br>                        .addMetadata( &quot;label&quot;, &quot;confirm execution of action2?&quot;)<br>                        .build()) // request approval before action2<br>        .build()<br>        .compile(compileConfig);<br><br>// ... inside the execution loop ...<br><br>while( true ) {<br>    // 2. The stream() method returns a generator that yields state updates.<br>    //    When an interruption occurs, the generator will yield all states up to<br>    //    the interruption point and then return the InterruptionMetadata.<br>    var generator = agent.stream(input, runnableConfig );<br><br>    // We can process the yielded nodes (e.g., for logging)<br>    var lastNode = generator.stream().reduce((a, b) -&gt; b).orElseThrow();<br><br>    // 3. Check if the graph has finished normally.<br>    if (lastNode.isEND()) {<br>        console.format( &quot;result: %s\n&quot;, lastNode.state().finalResponse().orElseThrow());<br>        break;<br>    }<br><br>    // 4. If the graph has not finished, it means it was interrupted.<br>    //    We get the interruption metadata, which is the return value of the generator.<br>    var interruption = (InterruptionMetadata&lt;?&gt;) AsyncGenerator.resultValue(generator).orElseThrow();<br><br>    // 5. Prompt the user for approval using information from the metadata.<br>    var answer = console.readLine(format(&quot;%s : (N\y) \t\n&quot;, interruption.metadata(&quot;label&quot;).orElse(&quot;Approve action ?&quot;)));<br><br>    // 6. Resume the execution by updating the state with the user&#39;s decision.<br>    if (Objects.equals(answer, &quot;Y&quot;) || Objects.equals(answer, &quot;y&quot;)) {<br>        runnableConfig = agent.updateState(runnableConfig, <br>                Map.of(AgentEx.APPROVAL_RESULT_PROPERTY, AgentEx.ApprovalState.APPROVED.name()));<br>    } else {<br>        runnableConfig = agent.updateState(runnableConfig, <br>                Map.of(AgentEx.APPROVAL_RESULT_PROPERTY, AgentEx.ApprovalState.REJECTED.name()));<br>    }<br>    input = null; // Clear input for the next iteration, as we are resuming.<br>}</pre><p>This code demonstrates the complete cycle:</p><ol><li><strong>Configuration</strong>: The agent is configured to interrupt before the execTest node is executed. The InterruptionMetadata is built with a custom prompt label.</li><li><strong>Execution</strong>: The agent.stream() method returns a generator. We consume the generator&#39;s yielded values to process all intermediate states.</li><li><strong>Check for End</strong>: We check the last yielded node to see if the graph has finished its execution.</li><li><strong>Handle Interruption</strong>: If the graph is not finished, we retrieve the InterruptionMetadata from the generator&#39;s return value.</li><li><strong>User Interaction</strong>: We use the metadata to prompt the user for a decision.</li><li><strong>Resumption</strong>: The agent.updateState method is used to inject the user&#39;s choice (APPROVED or REJECTED) back into the graph&#39;s state, allowing the execution to resume from where it left off.</li></ol><p>This example highlights how <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> provides a clean and powerful mechanism for implementing Human-in-the-Loop workflows.</p><h3>Conclusion</h3><p>The Human-in-the-Loop pattern is essential for creating safe and reliable AI agents. As we’ve seen, <a href="https://github.com/langgraph4j/langgraph4j">LangGraph4j</a> &#39;s is suited for implementing such complex control flows. By evolving from a simple agent loop to a modular graph with dispatcher and approval nodes, you can build sophisticated, human-supervised agents with confidence.</p><p>Hope this could help your AI Java developing journey, in the meanwhile happy AI coding! 👋</p><p><em>Originally published at </em><a href="https://bsorrentino.github.io/bsorrentino/ai/2025/07/13/LangGraph4j-Agent-with-approval.html"><em>https://bsorrentino.github.io</em></a><em> on July 13, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ca77d366d8c" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/langgraph4j-implementing-human-in-the-loop-at-ease-0ca77d366d8c">LangGraph4j — Implementing Human-in-the-Loop at ease</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LangGraph4j — Multi-Agent handoff implementation with Spring AI]]></title>
            <link>https://blog.devgenius.io/langgraph4j-multi-agent-handoff-implementation-with-spring-ai-05c18388796a?source=rss-b9c2251c0e92------2</link>
            <guid isPermaLink="false">https://medium.com/p/05c18388796a</guid>
            <category><![CDATA[langgraph4j]]></category>
            <category><![CDATA[multiagent-system]]></category>
            <category><![CDATA[spring-ai]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Bartolomeo Sorrentino]]></dc:creator>
            <pubDate>Sat, 10 May 2025 00:00:52 GMT</pubDate>
            <atom:updated>2025-05-13T15:10:03.763Z</atom:updated>
            <content:encoded><![CDATA[<h3>LangGraph4j — Multi-Agent handoff implementation with Spring AI</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Ggrcs1C6DX2FXV5I.png" /></figure><p><strong>Multi-agent architectures</strong> are the new trend in Artificial Intelligence field for realizing complex and innovative solutions. One of the architectural patterns that has garnered attention is “ <strong>Agents Handoff</strong>”. In this article we will explore an approach to developing this multi-agent architecture providing also a practical implementation using <a href="https://github.com/bsorrentino/langgraph4j">Langgraph4j</a> and <a href="https://spring.io/projects/spring-ai">Spring AI</a>.</p><h3>Understanding multi-Agent Architecture</h3><p>Multi-agent systems consist of multiple interacting agents, each designed to perform specific tasks. These agents can be homogeneous or heterogeneous, functioning independently or collaboratively to achieve common goals. The essence of multi-agent architecture lies in the coordination and communication among agents, ensuring seamless execution of complex processes.</p><h3>Defining Agents Handoff</h3><p>Agents Handoff refers to the mechanism where control and data ( <em>context</em>) are transferred from one agent to another, enabling continuous and efficient task execution. This concept is pivotal in scenarios where tasks require diverse expertise or when tasks need to be distributed among multiple agents to optimize performance.</p><h3>How to implement Agents Handoff ?</h3><p>We will examine the concept of using <a href="https://platform.openai.com/docs/guides/function-calling">function calls</a> (aka tools) as an enabler to implement the agent&#39;s handoff technique. Therefore, it is important to take a closer look at the &quot;function calling&quot; feature and its role in AI models.</p><h3>The role of Function Calls in AI Models</h3><p>Function calls in AI models serve as the backbone for agents allowing them to invoke specific functions, share data, and execute tasks collaboratively. By leveraging function calls, developers can design agents that interact dynamically, responding to changes in the environment and adapting to new information in real-time.</p><p>The diagram below presents the architecture of a <a href="https://bsorrentino.github.io/bsorrentino/ai/2025/05/10/(https://github.com/bsorrentino/langgraph4j/blob/main/spring-ai-agent/README.md)">ReAct Agent</a>, highlighting the role that function calls play within the framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VsCXBjCUtH0WlSxO.png" /><figcaption>Diagram1 — <em>ReAct Agent: Function Calling Anatomy</em></figcaption></figure><p>It is interesting to note that the LLM reasoning process formulates an <strong>actions execution plan</strong>, which supports the underlying infrastructure responsible for <strong>dispatching, executing, and gathering results</strong> of actions.</p><h3>Action as Agent 🧐</h3><p>Given that LLM creates a clear action plan based on its input, <strong>what if another agent is behind these actions?</strong> below a diagram that show it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QjVSkfm7Ib0gjOkn.png" /><figcaption><em>Diagram2</em> — <em>Action as Agent</em></figcaption></figure><p>This means that: If we <strong>describe the functionalities of an action such as the agent capabilities</strong>, we can rely on the actions execution plan to automatically achieve the agent handoff by utilizing its infrastructure for execution and result gathering.</p><p>In this scenario to adapt Action as Agent, we need to define:</p><ul><li><strong>Function description</strong>:</li></ul><blockquote>This will outline the role and capabilities of the Agent. It is essential to provide this information to the LLM so it can produce an appropriate “Actions execution plan.”</blockquote><ul><li><strong>Function parameters</strong>:</li></ul><blockquote>These are the inputs that the agent will use within its operational context. By default, there will be one parameter named ‘context.’</blockquote><h3>Multiple Actions as Agents</h3><p>Iteratively we can continue to add new actions as agents making complex multi agents scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mCOHIJVC4748fBcu.png" /><figcaption><em>Diagram3</em> — <em>Multiple Actions as Agents</em></figcaption></figure><p>A <a href="https://github.com/bsorrentino/langgraph4j/tree/main/samples/agents-handoff">reference implementation</a> has been developed in the <a href="https://github.com/bsorrentino/langgraph4j">Langgraph4j</a> project. The <a href="https://github.com/bsorrentino/langgraph4j">Langgraph4j</a> provides a <a href="https://bsorrentino.github.io/bsorrentino/ai/2025/05/10/(https://github.com/bsorrentino/langgraph4j/blob/main/spring-ai-agent/README.md)">ReACT Agent</a> (aka AgentExecutor) built-in implementation, which has been extended to support Agents&#39; handoff architecture.</p><p>The main classes include the AbstractAgentExecutor, combining an AgentExecutor with a Function, and AgentHandoff that enhances AgentExecutor by adding the capability to integrate implementations of AbstractAgentExecutor into its tool chain.</p><h3>Let’s dive in an example</h3><p>In this example we’ll create two agent, one responsible of the search product into referred marketplace and another one responsible for purchasing and payment referred to a bank account</p><h4>Let’s setup the AgentMarketplace</h4><pre>public class AgentMarketplace extends AbstractAgentExecutor&lt;AgentMarketplace.Builder&gt; {<br><br>    // define internal agent tools <br>    static class Tools {<br>        record Product(<br>                @JsonPropertyDescription(&quot;the product name&quot;) String name,<br>                @JsonPropertyDescription(&quot;the product price&quot;) double price,<br>                @JsonPropertyDescription(&quot;the product price currency&quot;) String currency) {}<br><br>        @Tool( description=&quot;search for a specific product in the marketplace&quot;)<br>        Product searchByProduct(@ToolParam( description=&quot;the product name to search&quot;) String product ) {<br>            // custom implementation, return matching product<br>        }<br>    }<br><br>    // define Agent builder<br>    public static class Builder extends AbstractAgentExecutor.Builder&lt;AgentMarketplace.Builder&gt; {<br>        // build the Agent <br>        public AgentMarketplace build() throws GraphStateException {<br>            this.name(&quot;marketplace&quot;) // set name<br>                // agent description (tool description)<br>                .description(&quot;marketplace agent, ask for information about products&quot;) <br>                // agent input description (tool parameter description)<br>                .defaultSystem( &quot;&quot;&quot;<br>                .parameterDescription(&quot;all information request about the products&quot;) <br>                    You are the agent that provides the information on the product marketplace.<br>                &quot;&quot;&quot;) // set the system prompt<br>                .toolsFromObject( new Tools() ) // load internal tools<br>            ;<br><br>            return new AgentMarketplace( this );<br>        }<br>    }<br><br>    public static Builder builder() {<br>        return new Builder();<br>    }<br><br>    protected AgentMarketplace(Builder builder) throws GraphStateException {<br>        super(builder);<br>    }   <br>}</pre><h4>Let’s setup the AgentPayment</h4><pre>public class AgentPayment extends AbstractAgentExecutor&lt;AgentPayment.Builder&gt; {<br><br>    // define internal agent tools <br>    static class Tools {<br><br>        record Transaction(<br>                @JsonPropertyDescription(&quot;the product name bought&quot;) String product,<br>                @JsonPropertyDescription(&quot;code operation&quot;) String code<br>        ) {}<br><br>        @Tool(description=&quot;submit a payment for purchasing a specific product&quot;)<br>        Transaction submitPayment(<br>                @ToolParam( description=&quot;the product name to buy&quot;) String product,<br>                @ToolParam( description=&quot;the product price&quot;) double price,<br>                @ToolParam( description=&quot;the product price currency&quot;) String currency,<br>                @ToolParam( description=&quot;International Bank Account Number (IBAN)&quot;) String iban ) {<br>            // custom implementation, purchase given product and return the transaction info<br>        }<br><br>        @Tool(description=&quot;retrieve IBAN information&quot;)<br>        String retrieveIBAN()  {<br>            // custom implementation, return the IBAN<br>        }<br><br>    }<br><br>    public static class Builder extends AbstractAgentExecutor.Builder&lt;AgentPayment.Builder&gt; {<br><br>        public AgentPayment build() throws GraphStateException {<br>            this.name(&quot;payment&quot;) // set name<br>                // agent description (tool description)<br>                .description(&quot;payment agent, request purchase and payment transactions&quot;) <br>                // agent input description (tool parameter description)<br>                .parameterDescription(&quot;all information about purchasing to allow the payment&quot;) <br>                .defaultSystem( &quot;&quot;&quot;<br>                You are the agent that provides payment service.<br>                &quot;&quot;&quot;) // set the system prompt<br>                .toolsFromObject( new Tools() ) // load internal tools<br>                ;<br><br>            return new AgentPayment( this );<br>        }<br>    }<br><br>    public static Builder builder() {<br>        return new Builder();<br>    }<br><br>    protected AgentPayment(Builder builder) throws GraphStateException {<br>        super(builder);<br>    }<br>}</pre><h4>Let’s setup the Agent handoff (Final step)</h4><pre>var model = OllamaChatModel.builder()<br>                        .ollamaApi( new OllamaApi(&quot;http://localhost:11434&quot;) )<br>                        .defaultOptions(OllamaOptions.builder()<br>                            .model(&quot;qwen2.5:7b&quot;)<br>                            .temperature(0.1)<br>                            .build())<br>                        .build();<br><br>var agentMarketPlace = AgentMarketplace.builder()<br>            .chatModel( model )<br>            .build();<br><br>var agentPayment = AgentPayment.builder()<br>        .chatModel( model )<br>        .build();<br><br>var handoffExecutor = AgentHandoff.builder()<br>        .chatModel( model )<br>        .agent( agentMarketPlace )<br>        .agent( agentPayment )<br>        .build()<br>        .compile();</pre><h4>Test it</h4><pre>var input = &quot;search for product &#39;X&#39; and purchase it&quot;;<br><br>var result = handoffExecutor.invoke( Map.of( &quot;messages&quot;, new UserMessage(input)));<br><br>var response = result.flatMap(MessagesState::lastMessage)<br>        .map(Content::getText)<br>        .orElseThrow();<br><br>System.out.println( response );</pre><p>To make a test, it is necessary to submit a request to handoffExecutor. This process will automatically engage the appropriate agents to complete the request.</p><h3>Bonus: use an <a href="https://modelcontextprotocol.io/introduction">MCP Server</a> as an Agent</h3><p>Since Agents rely on tools to perform handoffs to another Agent, it is possible to use the <a href="https://modelcontextprotocol.io/introduction">MCP Server</a>, in combination with the <a href="https://modelcontextprotocol.io/docs/concepts/sampling">sampling</a> feature, to provide Agents suitable for a handoff architecture (this is an interesting matter for another article 😎 does it?)</p><h3>Conclusions</h3><p>In this article, we’ve explored a practical approach to implementing multi-agent handoffs using <a href="https://github.com/bsorrentino/langgraph4j">Langgraph4j</a> and <a href="https://spring.io/projects/spring-ai">Spring AI</a>, leveraging the power of function calls to enable seamless transitions between specialized agents. The reference implementation demonstrates how to define agents for specific tasks and orchestrate their interactions to achieve complex goals.<br> By treating actions as agents, we can build sophisticated systems that mimic human collaboration, opening new possibilities for AI-driven solutions.</p><p>Hope this helps in some way your AI development journey, Happy AI coding! 👋</p><p><em>Originally published at </em><a href="https://bsorrentino.github.io/bsorrentino/ai/2025/05/10/Langgraph4j-agent-handoff.html"><em>https://bsorrentino.github.io</em></a><em> on May 10, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05c18388796a" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/langgraph4j-multi-agent-handoff-implementation-with-spring-ai-05c18388796a">LangGraph4j — Multi-Agent handoff implementation with Spring AI</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>