public class LoopAgent extends FlowAgent
Loop Agent that supports multiple loop modes:
  • COUNT: Execute a fixed number of loops
  • CONDITION: Continue looping based on a condition, similar to a do-while structure, but when the condition is true, terminate the loop
  • JSON_ARRAY: Parse a JSON array and iterate over its elements
  • Other Loop Strategy: Users can implement the LoopStrategy interface according to their needs.

Note: The LoopAgent must have a subAgent, which is the agent that will be executed in each loop.

Usage example:


 LoopAgent loopAgent = LoopAgent.builder()
     .name("example-loop-agent")
     .description("Example loop agent")
     .loopStrategy(LoopMode.condition(messagePredicate))
     .subAgent(subAgent)
     .build();
 
Since:
2025/8/25
Author:
vlsmb