@@ -372,6 +372,7 @@ public class AsyncNodeGenerator<Output extends NodeOutput<State>> implements Asy
372
372
String nextNodeId ;
373
373
int iteration = 0 ;
374
374
RunnableConfig config ;
375
+ boolean resumedFromEmbed = false ;
375
376
376
377
protected AsyncNodeGenerator (Map <String ,Object > inputs , RunnableConfig config ) throws Exception {
377
378
final boolean isResumeRequest = (inputs == null );
@@ -431,6 +432,7 @@ private Optional<Data<Output>> getEmbedGenerator( Map<String,Object> partialStat
431
432
}
432
433
currentState = AgentState .updateState (currentState , (Map <String , Object >)data , stateGraph .getChannels ());
433
434
nextNodeId = nextNodeId (currentNodeId , currentState );
435
+ resumedFromEmbed = true ;
434
436
})
435
437
)
436
438
;
@@ -449,12 +451,7 @@ private CompletableFuture<Data<Output>> evaluateAction(AsyncNodeAction<State> ac
449
451
currentState = AgentState .updateState (currentState , partialState , stateGraph .getChannels ());
450
452
nextNodeId = nextNodeId (currentNodeId , currentState );
451
453
452
- Optional <Checkpoint > cp = addCheckpoint (config , currentNodeId , currentState , nextNodeId );
453
- CompletableFuture <Output > future = completedFuture (( cp .isPresent () && config .streamMode () == StreamMode .SNAPSHOTS ) ?
454
- buildStateSnapshot (cp .get ()) :
455
- buildNodeOutput ( currentNodeId ))
456
- ;
457
- return Data .of ( future );
454
+ return Data .of ( getNodeOutput () );
458
455
}
459
456
catch (Exception e ) {
460
457
throw new CompletionException (e );
@@ -463,6 +460,14 @@ private CompletableFuture<Data<Output>> evaluateAction(AsyncNodeAction<State> ac
463
460
});
464
461
}
465
462
463
+ private CompletableFuture <Output > getNodeOutput () throws Exception {
464
+ Optional <Checkpoint > cp = addCheckpoint (config , currentNodeId , currentState , nextNodeId );
465
+ return completedFuture (( cp .isPresent () && config .streamMode () == StreamMode .SNAPSHOTS ) ?
466
+ buildStateSnapshot (cp .get ()) :
467
+ buildNodeOutput ( currentNodeId ))
468
+ ;
469
+ }
470
+
466
471
@ Override
467
472
public Data <Output > next () {
468
473
// GUARD: CHECK MAX ITERATION REACHED
@@ -475,6 +480,12 @@ public Data<Output> next() {
475
480
if ( nextNodeId == null && currentNodeId == null ) return Data .done ();
476
481
477
482
try {
483
+ // IS IT A RESUME FROM EMBED ?
484
+ if (resumedFromEmbed ) {
485
+ final CompletableFuture <Output > future = getNodeOutput ();
486
+ resumedFromEmbed = false ;
487
+ return Data .of ( future );
488
+ }
478
489
479
490
if ( START .equals (currentNodeId ) ) {
480
491
nextNodeId = getEntryPoint ( currentState );
0 commit comments