Class SupervisorGraphBuildingStrategy

java.lang.Object
com.alibaba.cloud.ai.graph.agent.flow.strategy.AbstractFlowGraphBuildingStrategy
com.alibaba.cloud.ai.graph.agent.flow.strategy.SupervisorGraphBuildingStrategy
All Implemented Interfaces:
FlowGraphBuildingStrategy

public class SupervisorGraphBuildingStrategy extends AbstractFlowGraphBuildingStrategy
Strategy for building supervisor-based routing graphs. In a supervisor graph, an LLM decides which sub-agent should handle the task, and sub-agents always return to the supervisor after completion. The supervisor can then either route to another sub-agent or mark the task as complete (END).
  • Constructor Details

    • SupervisorGraphBuildingStrategy

      public SupervisorGraphBuildingStrategy()
  • Method Details

    • buildCoreGraph

      protected void buildCoreGraph(FlowGraphBuilder.FlowGraphConfig config) throws GraphStateException
      Description copied from class: AbstractFlowGraphBuildingStrategy
      Abstract method that subclasses must implement to build their specific graph structure. All common setup (graph creation, hook filtering, node addition, etc.) is already done. Subclasses can directly access protected fields: graph, rootAgent, beforeModelHooks, afterModelHooks, entryNode, exitNode.

      Note: Subclasses should NOT call connectBeforeModelHookEdges() or connectAfterModelHookEdges() in this method. Instead, override the hook methods (connectBeforeModelHooks(), connectAfterModelHooks()) if custom hook connection logic is needed.

      Overrides:
      buildCoreGraph in class AbstractFlowGraphBuildingStrategy
      Parameters:
      config - the flow graph configuration
      Throws:
      GraphStateException - if graph construction fails
    • getStrategyType

      public String getStrategyType()
      Description copied from interface: FlowGraphBuildingStrategy
      Returns the type identifier for this strategy. This is used for registration and lookup purposes.
      Returns:
      the strategy type identifier
    • validateConfig

      public void validateConfig(FlowGraphBuilder.FlowGraphConfig config)
      Description copied from interface: FlowGraphBuildingStrategy
      Validates that the configuration contains all required parameters for this strategy.
      Parameters:
      config - the configuration to validate