@@ -332,6 +332,19 @@ async fn execute_sql_node(
332332 Ok ( result)
333333}
334334
335+ fn store_named_result (
336+ ctx : & OrchestrationContext ,
337+ node : & FunctionNode ,
338+ result : & str ,
339+ results : & mut HashMap < String , String > ,
340+ node_label : & str ,
341+ ) {
342+ if let Some ( name) = & node. result_name {
343+ ctx. trace_info ( format ! ( "Storing {node_label} result as ${name}" ) ) ;
344+ results. insert ( name. clone ( ) , result. to_string ( ) ) ;
345+ }
346+ }
347+
335348async fn execute_then_node (
336349 ctx : & OrchestrationContext ,
337350 graph : & FunctionGraph ,
@@ -364,6 +377,8 @@ async fn execute_then_node(
364377 ) )
365378 . await ?;
366379
380+ store_named_result ( ctx, node, & right_result, results, "THEN" ) ;
381+
367382 Ok ( right_result)
368383}
369384
@@ -474,6 +489,7 @@ async fn execute_loop_node(
474489 ctx. trace_info ( format ! (
475490 "Loop terminated by break with value: {break_value}"
476491 ) ) ;
492+ store_named_result ( ctx, node, & break_value, results, "LOOP" ) ;
477493 return Ok ( break_value) ;
478494 }
479495
@@ -499,6 +515,7 @@ async fn execute_loop_node(
499515
500516 if !should_continue {
501517 ctx. trace_info ( "Loop condition false, exiting loop" ) ;
518+ store_named_result ( ctx, node, & body_result, results, "LOOP" ) ;
502519 return Ok ( body_result) ;
503520 }
504521 }
@@ -639,15 +656,19 @@ async fn execute_if_node(
639656 ctx. trace_info ( format ! ( "Condition evaluated to: {is_true}" ) ) ;
640657
641658 if is_true {
642- Box :: pin ( execute_function_node_with_vars (
659+ let result = Box :: pin ( execute_function_node_with_vars (
643660 ctx, graph, then_id, results, exec_ctx,
644661 ) )
645- . await
662+ . await ?;
663+ store_named_result ( ctx, node, & result, results, "IF" ) ;
664+ Ok ( result)
646665 } else {
647- Box :: pin ( execute_function_node_with_vars (
666+ let result = Box :: pin ( execute_function_node_with_vars (
648667 ctx, graph, else_id, results, exec_ctx,
649668 ) )
650- . await
669+ . await ?;
670+ store_named_result ( ctx, node, & result, results, "IF" ) ;
671+ Ok ( result)
651672 }
652673}
653674
0 commit comments