Annotation Interface ExitCondition


@Retention(RUNTIME) @Target(METHOD) public @interface ExitCondition
Marks a method as an exit condition for a loop in a loop-based agent. The method must be static and return a boolean indicating whether the loop should exit.

Example:


     public interface StyleReviewLoopAgentWithCounter {

        @LoopAgent(
                description = "Review the given story to ensure it aligns with the specified style",
                outputName = "story", maxIterations = 5,
                subAgents = {
                    @SubAgent(type = StyleScorer.class, outputName = "score"),
                    @SubAgent(type = StyleEditor.class, outputName = "story")
            }
        )
        String write(@V("story") String story);

        @ExitCondition(testExitAtLoopEnd = true)
        static boolean exit(@V("score") double score) {
            return score >= 0.8;
        }
    }

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    If true, the exit condition will be tested only at the end of each loop iteration.
  • Element Details

    • testExitAtLoopEnd

      boolean testExitAtLoopEnd
      If true, the exit condition will be tested only at the end of each loop iteration. If false, the exit condition will be tested after each sub-agent invocation. Default is false.
      Returns:
      whether to test the exit condition at the end of the loop iteration.
      Default:
      false