Class RoutingGraphBuildingStrategy
- All Implemented Interfaces:
FlowGraphBuildingStrategy
This strategy extends AbstractFlowGraphBuildingStrategy and customizes hook handling: beforeModel/afterModel hooks wrap around the RoutingNode instead of the root agent.
-
Field Summary
Fields inherited from class com.alibaba.cloud.ai.graph.agent.flow.strategy.AbstractFlowGraphBuildingStrategy
afterAgentHooks, afterModelHooks, beforeAgentHooks, beforeModelHooks, entryNode, exitNode, graph, rootAgent -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAbstract method that subclasses must implement to build their specific graph structure.protected voidConnects afterModel hook edges.protected voidConnects beforeModel hook edges.Generates a KeyStrategyFactory based on the root agent and sub-agents.Returns the type identifier for this strategy.voidValidates that the configuration contains all required parameters for this strategy.Methods inherited from class com.alibaba.cloud.ai.graph.agent.flow.strategy.AbstractFlowGraphBuildingStrategy
addAfterAgentHookNodesToGraph, addBeforeAgentHookNodesToGraph, buildGraph, chainAfterAgentHooks, chainBeforeAgentHooks, connectAfterAgentHooks, connectAfterModelHookEdges, connectBeforeAgentHooks, connectBeforeModelHookEdges, determineEntryNode, determineExitNode, filterHooksByPosition, getRootAgentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.alibaba.cloud.ai.graph.agent.flow.strategy.FlowGraphBuildingStrategy
processAgentKeyStrategies, processOutputKey
-
Constructor Details
-
RoutingGraphBuildingStrategy
public RoutingGraphBuildingStrategy()
-
-
Method Details
-
buildCoreGraph
Description copied from class:AbstractFlowGraphBuildingStrategyAbstract 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:
buildCoreGraphin classAbstractFlowGraphBuildingStrategy- Parameters:
config- the flow graph configuration- Throws:
GraphStateException- if graph construction fails
-
connectBeforeModelHooks
Description copied from class:AbstractFlowGraphBuildingStrategyConnects 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:
connectBeforeModelHooksin classAbstractFlowGraphBuildingStrategy- Throws:
GraphStateException- if graph construction fails
-
connectAfterModelHooks
Description copied from class:AbstractFlowGraphBuildingStrategyConnects 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:
connectAfterModelHooksin classAbstractFlowGraphBuildingStrategy- Throws:
GraphStateException- if graph construction fails
-
getStrategyType
Description copied from interface:FlowGraphBuildingStrategyReturns the type identifier for this strategy. This is used for registration and lookup purposes.- Returns:
- the strategy type identifier
-
generateKeyStrategyFactory
Description copied from interface:FlowGraphBuildingStrategyGenerates a KeyStrategyFactory based on the root agent and sub-agents.- Parameters:
config- the configuration containing agents- Returns:
- the generated KeyStrategyFactory
-
validateConfig
Description copied from interface:FlowGraphBuildingStrategyValidates that the configuration contains all required parameters for this strategy.- Parameters:
config- the configuration to validate
-