@@ -426,8 +426,11 @@ private Optional<Data<Output>> getEmbedGenerator( Map<String,Object> partialStat
426
426
.findFirst ()
427
427
.map ( e ->
428
428
Data .composeWith ( (AsyncGenerator <Output >)e .getValue (), data -> {
429
- partialState .put ( e .getKey (), data );
430
- currentState = AgentState .updateState (currentState , partialState , stateGraph .getChannels ());
429
+ if ( !(data instanceof Map ) ) {
430
+ throw new IllegalArgumentException ("Embedded generator must return a Map" );
431
+ }
432
+ currentState = AgentState .updateState (currentState , (Map <String , Object >)data , stateGraph .getChannels ());
433
+ nextNodeId = nextNodeId (currentNodeId , currentState );
431
434
})
432
435
)
433
436
;
@@ -439,7 +442,9 @@ private CompletableFuture<Data<Output>> evaluateAction(AsyncNodeAction<State> ac
439
442
try {
440
443
441
444
Optional <Data <Output >> embed = getEmbedGenerator ( partialState );
442
- if ( embed .isPresent () ) return embed .get ();
445
+ if ( embed .isPresent () ) {
446
+ return embed .get ();
447
+ }
443
448
444
449
currentState = AgentState .updateState (currentState , partialState , stateGraph .getChannels ());
445
450
nextNodeId = nextNodeId (currentNodeId , currentState );
@@ -516,9 +521,7 @@ public Data<Output> next() {
516
521
}
517
522
catch ( Exception e ) {
518
523
log .error ( e .getMessage (), e );
519
- CompletableFuture <Output > future = new CompletableFuture <>();
520
- future .completeExceptionally (e );
521
- return Data .of (future );
524
+ return Data .error (e );
522
525
}
523
526
524
527
0 commit comments