Annotation Interface ConditionalAgent


@Retention(RUNTIME) @Target(METHOD) public @interface ConditionalAgent
Marks a method as a definition of a conditional agent, generally used to route the agentic workflow toward one or more sub-agents according to the verification of their activation conditions. Each sub-agent has its own activation condition, a static method annotated with ActivationCondition that determines when it should be invoked.

Example:


    public interface ExpertsAgent {

        @ConditionalAgent(outputName = "response", subAgents = {
                @SubAgent(type = MedicalExpert.class, outputName = "response"),
                @SubAgent(type = TechnicalExpert.class, outputName = "response"),
                @SubAgent(type = LegalExpert.class, outputName = "response")
        })
        String askExpert(@V("request") String request);

        @ActivationCondition(MedicalExpert.class)
        static boolean activateMedical(@V("category") RequestCategory category) {
            return category == RequestCategory.MEDICAL;
        }

        @ActivationCondition(TechnicalExpert.class)
        static boolean activateTechnical(@V("category") RequestCategory category) {
            return category == RequestCategory.TECHNICAL;
        }

        @ActivationCondition(LegalExpert.class)
        static boolean activateLegal(AgenticScope agenticScope) {
            return agenticScope.readState("category", RequestCategory.UNKNOWN) == RequestCategory.LEGAL;
        }
    }

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Sub-agents that can be conditionally activated by this agent.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Description of the agent.
    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
      Sub-agents that can be conditionally activated by this agent.
      Returns:
      array of sub-agents.