2626import com .google .adk .annotations .Experimental ;
2727import com .google .adk .events .Event ;
2828import com .google .adk .events .EventActions ;
29- import com .google .common .collect .ImmutableList ;
3029import com .google .errorprone .annotations .CanIgnoreReturnValue ;
3130import com .google .genai .types .FinishReason ;
3231import io .reactivex .rxjava3 .core .Completable ;
@@ -68,6 +67,7 @@ interface EventSink {
6867 private final EventSink eventSink ;
6968 private final @ Nullable Context parent ;
7069 private final String runId ;
70+ private final boolean useAsOutput ;
7171 private final boolean useSubBranch ;
7272 private final @ Nullable String overrideBranch ;
7373
@@ -89,6 +89,7 @@ private NodeRunner(Builder builder) {
8989 this .node = builder .node ;
9090 this .parent = builder .parent ;
9191 this .runId = builder .runId ;
92+ this .useAsOutput = builder .useAsOutput ;
9293 this .useSubBranch = builder .useSubBranch ;
9394 this .overrideBranch = builder .overrideBranch ;
9495 }
@@ -185,6 +186,7 @@ Single<Context> run(@Nullable Object nodeInput) {
185186 .eventSink (eventSink )
186187 .parent (parent )
187188 .runId (runId )
189+ .useAsOutput (useAsOutput )
188190 .build ());
189191 return new Activation (context ).run (nodeInput ).toSingleDefault (context );
190192 });
@@ -355,8 +357,7 @@ private Event stamp(Event event) {
355357 .nodeInfo (
356358 nodeInfo .toBuilder ()
357359 .path (nodeState .nodePath ())
358- .outputFor (
359- carriesOutput ? ImmutableList .of (nodeState .nodePath ()) : nodeInfo .outputFor ())
360+ .outputFor (carriesOutput ? nodeState .outputFor () : nodeInfo .outputFor ())
360361 .build ())
361362 .build ();
362363 }
@@ -419,6 +420,7 @@ static final class Builder {
419420 private @ Nullable EventSink eventSink ;
420421 private @ Nullable Context parent ;
421422 private String runId = "1" ;
423+ private boolean useAsOutput ;
422424 private boolean useSubBranch ;
423425 private @ Nullable String overrideBranch ;
424426
@@ -459,6 +461,16 @@ Builder runId(String runId) {
459461 return this ;
460462 }
461463
464+ /**
465+ * Sets whether the node's output is also its parent's output, as when a terminal node produces
466+ * the output of its workflow.
467+ */
468+ @ CanIgnoreReturnValue
469+ Builder useAsOutput (boolean useAsOutput ) {
470+ this .useAsOutput = useAsOutput ;
471+ return this ;
472+ }
473+
462474 /**
463475 * Sets whether the node runs on a sub-branch of its base branch, as a node fanned out from its
464476 * parent does. Branches isolate one parallel branch's events from a sibling's model history.
0 commit comments