Class ParallelAgent.ParallelAgentBuilder
java.lang.Object
com.alibaba.cloud.ai.graph.agent.flow.builder.FlowAgentBuilder<ParallelAgent,ParallelAgent.ParallelAgentBuilder>
com.alibaba.cloud.ai.graph.agent.flow.agent.ParallelAgent.ParallelAgentBuilder
- Enclosing class:
- ParallelAgent
public static class ParallelAgent.ParallelAgentBuilder
extends FlowAgentBuilder<ParallelAgent,ParallelAgent.ParallelAgentBuilder>
Builder for creating ParallelAgent instances. Extends the common FlowAgentBuilder
to provide type-safe building with parallel execution capabilities.
Usage example:
ParallelAgent parallelAgent = ParallelAgent.builder()
.name("parallel_workflow")
.description("Executes multiple tasks in parallel")
.inputKey("input")
.outputKey("output")
.mergeStrategy(new ParallelAgent.ListMergeStrategy())
.maxConcurrency(5)
.subAgents(List.of(agent1, agent2, agent3))
.build();
-
Field Summary
Fields inherited from class com.alibaba.cloud.ai.graph.agent.flow.builder.FlowAgentBuilder
compileConfig, description, executor, name, saver, stateSerializer, subAgents -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoBuild()Builds the ParallelAgent instance.maxConcurrency(Integer maxConcurrency) Sets the maximum number of sub-agents that can execute concurrently.mergeOutputKey(String mergeOutputKey) mergeStrategy(ParallelAgent.MergeStrategy mergeStrategy) Sets the merge strategy for combining parallel execution results.protected ParallelAgent.ParallelAgentBuilderself()Returns the concrete builder instance for fluent interface support.Sets the list of sub-agents.protected voidvalidate()Validates the builder state before creating the agent.Methods inherited from class com.alibaba.cloud.ai.graph.agent.flow.builder.FlowAgentBuilder
build, compileConfig, description, executor, name, saver, stateSerializer
-
Constructor Details
-
ParallelAgentBuilder
public ParallelAgentBuilder()
-
-
Method Details
-
mergeStrategy
Sets the merge strategy for combining parallel execution results.- Parameters:
mergeStrategy- the strategy to use for merging results- Returns:
- this builder instance for method chaining
-
mergeOutputKey
-
subAgents
Description copied from class:FlowAgentBuilderSets the list of sub-agents.- Overrides:
subAgentsin classFlowAgentBuilder<ParallelAgent,ParallelAgent.ParallelAgentBuilder> - Parameters:
subAgents- the list of sub-agents- Returns:
- this builder instance for method chaining
-
maxConcurrency
Sets the maximum number of sub-agents that can execute concurrently.- Parameters:
maxConcurrency- the maximum concurrency limit- Returns:
- this builder instance for method chaining
-
self
Returns the concrete builder instance for fluent interface support.- Specified by:
selfin classFlowAgentBuilder<ParallelAgent,ParallelAgent.ParallelAgentBuilder> - Returns:
- this builder instance
-
validate
protected void validate()Validates the builder state before creating the agent.- Overrides:
validatein classFlowAgentBuilder<ParallelAgent,ParallelAgent.ParallelAgentBuilder> - Throws:
IllegalArgumentException- if validation fails
-
doBuild
Builds the ParallelAgent instance.- Specified by:
doBuildin classFlowAgentBuilder<ParallelAgent,ParallelAgent.ParallelAgentBuilder> - Returns:
- the built ParallelAgent instance
- Throws:
GraphStateException- if agent creation fails
-