From d3595cb41ec9f64ce9e2f2806e564a2a94ef67c3 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Sat, 31 Aug 2024 12:42:35 +0200 Subject: [PATCH] fix(CompiledGraph): when asNode is provided next node is evaluated keeping in consideration edges work on #14 --- .../src/main/java/org/bsc/langgraph4j/CompiledGraph.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core-jdk8/src/main/java/org/bsc/langgraph4j/CompiledGraph.java b/core-jdk8/src/main/java/org/bsc/langgraph4j/CompiledGraph.java index 2869d03..e76e21e 100644 --- a/core-jdk8/src/main/java/org/bsc/langgraph4j/CompiledGraph.java +++ b/core-jdk8/src/main/java/org/bsc/langgraph4j/CompiledGraph.java @@ -84,12 +84,16 @@ public RunnableConfig updateState( RunnableConfig config, Map val .map( cp -> cp.updateState(values, stateGraph.getChannels()) ) .orElseThrow( () -> (new IllegalStateException("Missing Checkpoint!")) ); + String nextNodeId = null; + if( asNode != null ) { + nextNodeId = nextNodeId( asNode, stateGraph.getStateFactory().apply(updatedCheckpoint.getState()) ); + } // update checkpoint in saver var newConfig = saver.put( config, updatedCheckpoint ); return RunnableConfig.builder(newConfig) .checkPointId( updatedCheckpoint.getId() ) - .nextNode( asNode ) + .nextNode( nextNodeId ) .build(); }