Skip to content

Commit cc4fdea

Browse files
authored
We should be able to use an agentic loop without explicitly specifying maxIterations (#843)
Signed-off-by: Dmitrii Tikhomirov <[email protected]>
1 parent 666cdb3 commit cc4fdea

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

experimental/fluent/agentic/src/main/java/io/serverlessworkflow/fluent/agentic/LoopAgentsBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class LoopAgentsBuilder {
3131
private final FuncTaskItemListBuilder funcDelegate;
3232
private final ForTaskFunction forTask;
3333

34+
private int maxIterations = 1024;
35+
3436
public LoopAgentsBuilder() {
3537
this.forTask = new ForTaskFunction();
3638
this.forTask.setFor(new ForTaskConfiguration());
@@ -56,7 +58,7 @@ public LoopAgentsBuilder subAgents(Object... agents) {
5658
}
5759

5860
public LoopAgentsBuilder maxIterations(int maxIterations) {
59-
this.forTask.withCollection(ignored -> IntStream.range(0, maxIterations).boxed().toList());
61+
this.maxIterations = maxIterations;
6062
return this;
6163
}
6264

@@ -67,6 +69,7 @@ public LoopAgentsBuilder exitCondition(Predicate<AgenticScope> exitCondition) {
6769

6870
public ForTaskFunction build() {
6971
this.forTask.setDo(this.funcDelegate.build());
72+
this.forTask.withCollection(ignored -> IntStream.range(0, maxIterations).boxed().toList());
7073
return this.forTask;
7174
}
7275
}

0 commit comments

Comments
 (0)