Annotation Interface ExitCondition


@Retention(RUNTIME) @Target(METHOD) public @interface ExitCondition
Marks a method as an exit predicate 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",
                outputKey = "story", maxIterations = 5,
                subAgents = {
                    @SubAgent(type = StyleScorer.class, outputKey = "score"),
                    @SubAgent(type = StyleEditor.class, outputKey = "story")
            }
        )
        String write(@V("story") String story);

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

  • Optional Element Summary

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

    • testExitAtLoopEnd

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

      String description
      Description of the exit condition. It should be clear and descriptive to allow understanding the purpose of the condition.
      Returns:
      description of the exit condition.
      Default:
      "<unknown>"