Annotation Interface LoopAgent


@Retention(RUNTIME) @Target(METHOD) public @interface LoopAgent
Marks a method as a definition of a loop agent, used to orchestrate the agentic workflow by invoking a series of sub-agents in a loop until a certain condition is met or a maximum number of iterations is reached. Each sub-agent is defined using the SubAgent annotation, which specifies the sub-agent's type and its output variable name.

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);
    }

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Array of sub-agents that will be invoked in parallel.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Description of the agent.
    int
    Maximum number of iterations the loop will execute.
    Name of the agent.
    Name of the output variable that will hold the result of the agent invocation.
  • Element Details

    • name

      String name
      Name of the agent. If not provided, method name will be used.
      Returns:
      name of the agent.
      Default:
      ""
    • description

      String description
      Description of the agent. It should be clear and descriptive to allow language model to understand the agent's purpose and its intended use.
      Returns:
      description of the agent.
      Default:
      ""
    • outputName

      String outputName
      Name of the output variable that will hold the result of the agent invocation.
      Returns:
      name of the output variable.
      Default:
      ""
    • subAgents

      SubAgent[] subAgents
      Array of sub-agents that will be invoked in parallel.
      Returns:
      array of sub-agents.
    • maxIterations

      int maxIterations
      Maximum number of iterations the loop will execute. If the exit condition is not met within this number of iterations, the loop will terminate.
      Returns:
      maximum number of iterations.
      Default:
      10