Class ParallelAgent
java.lang.Object
com.alibaba.cloud.ai.graph.agent.Agent
com.alibaba.cloud.ai.graph.agent.flow.agent.FlowAgent
com.alibaba.cloud.ai.graph.agent.flow.agent.ParallelAgent
ParallelAgent executes multiple sub-agents in parallel and merges their results.
This agent implements the Parallel Fan-Out/Gather pattern where:
- Fan-Out: The input is distributed to all sub-agents simultaneously
- Parallel Execution: All sub-agents execute concurrently
- Gather: Results from all sub-agents are collected and merged
The agent leverages the underlying ParallelNode infrastructure to achieve true parallel execution and provides configurable result merging strategies.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConcatenation merge strategy for string results.static classDefault merge strategy that combines all results into a map.static classList merge strategy that combines results into a list.static interfaceStrategy interface for merging parallel execution results.static classBuilder for creating ParallelAgent instances. -
Field Summary
Fields inherited from class com.alibaba.cloud.ai.graph.agent.flow.agent.FlowAgent
interruptBefore, stateSerializer, subAgentsFields inherited from class com.alibaba.cloud.ai.graph.agent.Agent
compileConfig, compiledGraph, description, executor, graph, name -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionbuilder()protected StateGraphAbstract method for subclasses to specify their graph building strategy.Gets the maximum concurrency limit for this ParallelAgent.Gets the merge strategy used by this ParallelAgent.Methods inherited from class com.alibaba.cloud.ai.graph.agent.flow.agent.FlowAgent
asStateGraph, initGraph, schedule, subAgentsMethods inherited from class com.alibaba.cloud.ai.graph.agent.Agent
applyExecutorConfig, buildMessageInput, buildNonStreamConfig, buildStreamConfig, description, doInvoke, doInvokeAndGetOutput, doStream, getAndCompileGraph, getCurrentState, getGraph, invoke, invoke, invoke, invoke, invoke, invoke, invokeAndGetOutput, invokeAndGetOutput, invokeAndGetOutput, invokeAndGetOutput, invokeAndGetOutput, invokeAndGetOutput, name, schedule, stream, stream, stream, stream, stream, stream
-
Constructor Details
-
ParallelAgent
-
-
Method Details
-
builder
-
buildSpecificGraph
protected StateGraph buildSpecificGraph(FlowGraphBuilder.FlowGraphConfig config) throws GraphStateException Description copied from class:FlowAgentAbstract method for subclasses to specify their graph building strategy. This method should be implemented by concrete FlowAgent subclasses to define how their specific graph structure should be built.- Specified by:
buildSpecificGraphin classFlowAgent- Parameters:
config- the graph configuration- Returns:
- the constructed StateGraph
- Throws:
GraphStateException- if graph construction fails
-
mergeStrategy
Gets the merge strategy used by this ParallelAgent.- Returns:
- the merge strategy
-
mergeOutputKey
-
maxConcurrency
Gets the maximum concurrency limit for this ParallelAgent.- Returns:
- the max concurrency, or null if unlimited
-