1717package com .google .adk .agents ;
1818
1919import com .google .adk .events .Event ;
20- import com .google .common .collect .ImmutableList ;
2120import com .google .errorprone .annotations .CanIgnoreReturnValue ;
2221import io .reactivex .rxjava3 .core .Flowable ;
2322import java .util .List ;
@@ -56,37 +55,8 @@ private LoopAgent(
5655 }
5756
5857 /** Builder for {@link LoopAgent}. */
59- public static class Builder {
60- private String name ;
61- private String description ;
62- private List <? extends BaseAgent > subAgents ;
58+ public static class Builder extends BaseAgent .Builder <Builder > {
6359 private Optional <Integer > maxIterations = Optional .empty ();
64- private ImmutableList <Callbacks .BeforeAgentCallback > beforeAgentCallback ;
65- private ImmutableList <Callbacks .AfterAgentCallback > afterAgentCallback ;
66-
67- @ CanIgnoreReturnValue
68- public Builder name (String name ) {
69- this .name = name ;
70- return this ;
71- }
72-
73- @ CanIgnoreReturnValue
74- public Builder description (String description ) {
75- this .description = description ;
76- return this ;
77- }
78-
79- @ CanIgnoreReturnValue
80- public Builder subAgents (List <? extends BaseAgent > subAgents ) {
81- this .subAgents = subAgents ;
82- return this ;
83- }
84-
85- @ CanIgnoreReturnValue
86- public Builder subAgents (BaseAgent ... subAgents ) {
87- this .subAgents = ImmutableList .copyOf (subAgents );
88- return this ;
89- }
9060
9161 @ CanIgnoreReturnValue
9262 public Builder maxIterations (int maxIterations ) {
@@ -100,31 +70,7 @@ public Builder maxIterations(Optional<Integer> maxIterations) {
10070 return this ;
10171 }
10272
103- @ CanIgnoreReturnValue
104- public Builder beforeAgentCallback (Callbacks .BeforeAgentCallback beforeAgentCallback ) {
105- this .beforeAgentCallback = ImmutableList .of (beforeAgentCallback );
106- return this ;
107- }
108-
109- @ CanIgnoreReturnValue
110- public Builder beforeAgentCallback (
111- List <Callbacks .BeforeAgentCallbackBase > beforeAgentCallback ) {
112- this .beforeAgentCallback = CallbackUtil .getBeforeAgentCallbacks (beforeAgentCallback );
113- return this ;
114- }
115-
116- @ CanIgnoreReturnValue
117- public Builder afterAgentCallback (Callbacks .AfterAgentCallback afterAgentCallback ) {
118- this .afterAgentCallback = ImmutableList .of (afterAgentCallback );
119- return this ;
120- }
121-
122- @ CanIgnoreReturnValue
123- public Builder afterAgentCallback (List <Callbacks .AfterAgentCallbackBase > afterAgentCallback ) {
124- this .afterAgentCallback = CallbackUtil .getAfterAgentCallbacks (afterAgentCallback );
125- return this ;
126- }
127-
73+ @ Override
12874 public LoopAgent build () {
12975 // TODO(b/410859954): Add validation for required fields like name.
13076 return new LoopAgent (
0 commit comments