Annotation Interface SequenceAgent


@Retention(RUNTIME) @Target(METHOD) public @interface SequenceAgent
Marks a method as a definition of a sequence agent, used to orchestrate the agentic workflow by invoking a series of sub-agents in a predefined order.

Example:


    public interface StoryCreatorWithConfigurableStyleEditor {

        @SequenceAgent(outputKey = "styledStory",
                       subAgents = { CreativeWriter.class, AudienceEditor.class, StyleEditor.class})
        String write(@V("topic") String topic, @V("style") String style, @V("audience") String audience);
    }

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Class<?>[]
    Array of sub-agents that will be invoked in sequence.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Description of the agent.
    Name of the agent.
    Key of the output variable that will be used to store the result of the agent's invocation.
    Class<? extends TypedKey<?>>
    Strongly typed key of the output variable that will be used to store the result of the agent's 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:
      ""
    • outputKey

      String outputKey
      Key of the output variable that will be used to store the result of the agent's invocation.
      Returns:
      name of the output variable.
      Default:
      ""
    • typedOutputKey

      Class<? extends TypedKey<?>> typedOutputKey
      Strongly typed key of the output variable that will be used to store the result of the agent's invocation. It enforces type safety when retrieving the output from the agent's state and can be used in alternative to the outputKey() attribute. Note that only one of those two attributes can be used at a time.
      Returns:
      class representing the typed output variable.
      Default:
      dev.langchain4j.agentic.Agent.NoTypedKey.class
    • subAgents

      Class<?>[] subAgents
      Array of sub-agents that will be invoked in sequence.
      Returns:
      array of sub-agents.