▾
import { ParallelWorkflow } from "@arcgis/ai-components/agent-utils/workflows/ParallelWorkflow.js";- Inheritance
- ParallelWorkflow→
BaseWorkflow<TState>
- Since
- ArcGIS Maps SDK for JavaScript 5.1
ParallelWorkflow fans out execution to multiple agents and merges branch outputs.
Use in the following scenarios:
- Branches can run independently from the same input,
- You want fan-out/fan-in behavior.
How it works:
- Fan out - every agent receives the same input snapshot,
- Each branch collects its result in a hidden state key,
- Fan in - merge outputs in declared agent order.
Merge rule:
- If two branches set the same shared key to different values, an error is thrown, as this indicates a conflict the workflow cannot resolve on its own.
Constructors
Properties
| Property | Type | Class |
|---|---|---|
| |
Methods
| Method | Signature | Class |
|---|---|---|
| protected | buildEdges(agents: BaseAgentLike<TState>[]): GraphEdge<AgentGraphState<TState>>[] | |
| protected | buildNodes(agents: BaseAgentLike<TState>[]): GraphNodes<AgentGraphState<TState>> | |
| generate(parameter0?: WorkflowGenerateOptions<TState>): WorkflowGenerateResult<TState> | | |
| getAgents(): BaseAgentLike<TState>[] | | |
| protected | getEntryNode(_agents: BaseAgentLike<TState>[]): string | |
| protected | isTerminalAgent(_agents: BaseAgentLike<TState>[], _index: number): boolean | |
| inherited protected | validateAgents(agents: BaseAgentLike<TState>[]): void |
buildEdges
- Signature
-
buildEdges (agents: BaseAgentLike<TState>[]): GraphEdge<AgentGraphState<TState>>[]
Builds the workflow-specific edges.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| agents | | |
- Returns
- GraphEdge<AgentGraphState
>[]
buildNodes
- Signature
-
buildNodes (agents: BaseAgentLike<TState>[]): GraphNodes<AgentGraphState<TState>>
Builds the workflow's graph nodes.
Node ids use the agent id plus its position (agent.id_index) instead of only the raw
agent id. That prevents collisions when the same agent instance is used multiple times.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| agents | | |
- Returns
- GraphNodes<AgentGraphState
>
generate
- Signature
-
generate (parameter0?: WorkflowGenerateOptions<TState>): WorkflowGenerateResult<TState>
Generates the workflow's graph and shared workspace based on its agents and optional boundary schemas.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| parameter0 | | |
- Returns
- WorkflowGenerateResult
getAgents
- Signature
-
getAgents (): BaseAgentLike<TState>[]
Returns the agents coordinated by this workflow.
- Returns
- BaseAgentLike
[]
getEntryNode
- Signature
-
getEntryNode (_agents: BaseAgentLike<TState>[]): string
Returns the id of the first node in the workflow graph.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| _agents | | |
- Returns
- string
isTerminalAgent
- Signature
-
isTerminalAgent (_agents: BaseAgentLike<TState>[], _index: number): boolean
Indicates whether the agent at index is terminal and should expose terminal runtime fields in workflow state.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| _agents | | | |
| _index | | |
- Returns
- boolean
validateAgents
- Signature
-
validateAgents (agents: BaseAgentLike<TState>[]): void
Throws if the workflow contains no agents. Concrete workflow classes may add validation for their requirements.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| agents | | |
- Returns
- void
Type definitions
ParallelWorkflowConstructProperties
- Type parameters
- <TState extends AgentData>
- Supertypes
- Pick<ParallelWorkflow
‚ "agents">