Annotation Interface ActivationCondition


@Retention(RUNTIME) @Target(METHOD) public @interface ActivationCondition
Marks a static method returning a boolean as an activation condition. It has two uses.

Without a value(), it is the condition of the agent declared by the class or interface containing the method: when that agent is invoked as a subagent and the condition is false, the agent is skipped. This works for any kind of agent: AI agents, workflows, planners, non-AI agents, human-in-the-loop, A2A and MCP client agents. The condition is ignored when the agent is invoked directly, as the root of an agentic system. It can be evaluated more than once for a single invocation, so it must be cheap and free of side effects; its arguments are read from the AgenticScope without writing back the values converted to their declared types. It can also declare parameters resolved through a SupplierParameterResolver.


    public interface ContextGatherer {

        @Agent(outputKey = "codeContext")
        String gather(@V("prOverview") String prOverview, @V("prSummary") PrSummary prSummary);

        @ActivationCondition(description = "the triage needs context")
        static boolean needsContext(@V("prSummary") PrSummary prSummary) {
            return prSummary.needsContext();
        }
    }

With a value(), on a ConditionalAgent, it is the condition activating one or more of the subagents of that conditional agent. Using a value on a class that is not a ConditionalAgent is a configuration error.


    public interface ExpertsAgent {

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

        @ActivationCondition(value = MedicalExpert.class, description = "category is medical")
        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;
        }
    }

On a ConditionalAgent, every activation condition must have a value: a method without value is a configuration error.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Description of the activation condition.
    Class<?>[]
    The subagents of the ConditionalAgent that this activation condition applies to.
  • Element Details

    • value

      Class<?>[] value
      The subagents of the ConditionalAgent that this activation condition applies to. When empty, the condition applies to the agent declared by the class or interface containing the method, which must not be a ConditionalAgent.
      Returns:
      array of sub-agent classes.
      Default:
      {}
    • description

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