▾
import { RouterWorkflow } from "@arcgis/ai-components/agent-utils/workflows/RouterWorkflow.js";- Inheritance
- RouterWorkflow→
BaseWorkflow<TState>
- Since
- ArcGIS Maps SDK for JavaScript 5.1
RouterWorkflow runs a router agent, then dispatches to exactly one downstream agent.
Use in the following scenarios:
- A model (or routing step) should choose the destination,
- Only one branch should run per request
How it works:
routerAgentalways runs first,- The workflow reads the route selected by
routerAgentfrom the state field identified byrouterOutputKey, - The agent corresponding to the selected route key is dispatched from
agentsMap.
Constructors
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| | ||
| keyof AgentGraphState | |
routerOutputKey
- Type
- keyof AgentGraphState
State key containing the selected route returned by the router agent.
Methods
| Method | Signature | Class |
|---|---|---|
| protected | buildEdges(agents: BaseAgentLike<TState>[]): GraphEdge<AgentGraphState<TState>>[] | |
| inherited protected | buildNodes(agents: BaseAgentLike<TState>[]): GraphNodes<AgentGraphState<TState>> | |
| inherited | generate(parameter0?: WorkflowGenerateOptions<TState>): WorkflowGenerateResult<TState> | |
| getAgents(): BaseAgentLike<TState>[] | | |
| protected | getEntryNode(): string | |
| protected | isTerminalAgent(_agents: BaseAgentLike<TState>[], index: number): 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 (_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
RouterWorkflowConstructProperties
- Type parameters
- <TState extends AgentData>
- Supertypes
- Pick<RouterWorkflow
‚ "agentsMap" | "routerAgent" | "routerOutputKey">