Class SequentialGraphBuildingStrategy

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

public class SequentialGraphBuildingStrategy extends AbstractFlowGraphBuildingStrategy
Strategy for building sequential execution graphs. In a sequential graph, agents are connected in a linear chain where each agent's output becomes the input for the next agent.
  • Constructor Details

    • SequentialGraphBuildingStrategy

      public SequentialGraphBuildingStrategy()
  • 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
    • connectBeforeModelHooks

      protected void connectBeforeModelHooks() throws GraphStateException
      Description copied from class: AbstractFlowGraphBuildingStrategy
      Connects beforeModel hook edges. Subclasses can override to customize behavior. Default implementation connects hooks in sequence to rootAgent.name().

      This method is called after buildCoreGraph() and before connectAfterModelHooks(). Subclasses that handle hook connections in buildCoreGraph() should override this method with an empty implementation to avoid duplicate edge connections.

      Overrides:
      connectBeforeModelHooks in class AbstractFlowGraphBuildingStrategy
      Throws:
      GraphStateException - if graph construction fails
    • connectAfterModelHooks

      protected void connectAfterModelHooks() throws GraphStateException
      Description copied from class: AbstractFlowGraphBuildingStrategy
      Connects afterModel hook edges. Subclasses can override to customize behavior. Default implementation connects hooks in sequence from rootAgent.name().

      This method is called after connectBeforeModelHooks() and before connectBeforeAgentHooks(). Subclasses that handle hook connections in buildCoreGraph() should override this method with an empty implementation to avoid duplicate edge connections.

      Overrides:
      connectAfterModelHooks in class AbstractFlowGraphBuildingStrategy
      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