▾
import { ConditionalWorkflow } from "@arcgis/ai-components/agent-utils/workflows/ConditionalWorkflow.js";- Inheritance
- ConditionalWorkflow→
BaseWorkflow<TState>
- Since
- ArcGIS Maps SDK for JavaScript 5.1
ConditionalWorkflow chooses between two branch agents based on a boolean condition and routes execution through a simple true/false branch.
Use when:
- you want an if/else style decision or
- only two branches are needed.
How it works:
- evaluate
condition(state, config), - if true, run the first branch agent,
- if false, run the second branch agent.
Constructors
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| |
agents
- Type
- BaseAgentLike
[]
Must contain exactly two agents: [trueAgent, falseAgent]. The first agent is executed when
the condition is true, the second when the condition is false.
Methods
| Method | Signature | Class |
|---|---|---|
| protected | buildEdges(agents: BaseAgentLike<TState>[]): GraphEdge<AgentGraphState<TState>>[] | |
| protected | buildNodes(agents: BaseAgentLike<TState>[]): GraphNodes<AgentGraphState<TState>> | |
| inherited | generate(parameter0?: WorkflowGenerateOptions<TState>): WorkflowGenerateResult<TState> | |
| getAgents(): BaseAgentLike<TState>[] | | |
| protected | getEntryNode(): string | |
| protected | isTerminalAgent(): boolean | |
| 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 (): string
Returns the id of the first node in the workflow graph.
- Returns
- string
isTerminalAgent
- Signature
-
isTerminalAgent (): boolean
Indicates whether the agent at index is terminal and should expose terminal runtime fields in workflow state.
- 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
ConditionDecider
Condition function that routes execution to either the true branch or false branch.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| state | Current workflow graph state. | | |
| config | Optional execution configuration. | |
ConditionalWorkflowConstructProperties
- Type parameters
- <TState extends AgentData>
- Supertypes
- Pick<ConditionalWorkflow
‚ "agents" | "condition">