ESM
import { LoopWorkflow } from "@arcgis/ai-components/agent-utils/workflows/LoopWorkflow.js";
Inheritance
LoopWorkflow→BaseWorkflow<TState>
Since
ArcGIS Maps SDK for JavaScript 5.1

LoopWorkflow repeatedly executes an inner workflow until a stop condition is met.

Use in the following scenarios:

  • You need retry/refine loops,
  • You want iterative planning and execution.

How it works:

  • Runs the inner workflow,
  • Evaluates decideContinue(state, config),
  • If true, runs again; if false (or unset), stops.

Constructors

Constructor

Constructor

Parameters

ParameterTypeDescriptionRequired
properties

Properties

decideContinue

Property
Type
LoopDecider

Function that decides whether the loop should continue.

workflow

Property
Type
BaseWorkflow

Inner workflow to execute on each loop iteration.

Methods

MethodSignatureClass
protected
buildEdges(): GraphEdge<AgentGraphState<TState>>[]
inherited protected
buildNodes(agents: BaseAgentLike<TState>[]): GraphNodes<AgentGraphState<TState>>
generate(parameter0?: WorkflowGenerateOptions<TState>): WorkflowGenerateResult<TState>
getAgents(): BaseAgentLike<TState>[]
protected
getEntryNode(): string
protected
isTerminalAgent(): boolean
inherited protected
validateAgents(agents: BaseAgentLike<TState>[]): void

buildEdges

protected Method
Signature
buildEdges (): GraphEdge<AgentGraphState<TState>>[]

Builds the workflow-specific edges.

buildNodes

inheritedprotected Method
Signature
buildNodes (agents: BaseAgentLike<TState>[]): GraphNodes<AgentGraphState<TState>>
Inherited from: BaseWorkflow

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

ParameterTypeDescriptionRequired
agents
Returns
GraphNodes<AgentGraphState>

generate

Method
Signature
generate (parameter0?: WorkflowGenerateOptions<TState>): WorkflowGenerateResult<TState>

Generates the workflow's graph and shared workspace based on its agents and optional boundary schemas.

Parameters

ParameterTypeDescriptionRequired
parameter0
Returns
WorkflowGenerateResult

getAgents

Method
Signature
getAgents (): BaseAgentLike<TState>[]

Returns the agents coordinated by this workflow.

Returns
BaseAgentLike[]

getEntryNode

protected Method
Signature
getEntryNode (): string

Returns the id of the first node in the workflow graph.

Returns
string

isTerminalAgent

protected Method
Signature
isTerminalAgent (): boolean

Indicates whether the agent at index is terminal and should expose terminal runtime fields in workflow state.

Returns
boolean

validateAgents

inheritedprotected Method
Signature
validateAgents (agents: BaseAgentLike<TState>[]): void
Inherited from: BaseWorkflow

Throws if the workflow contains no agents. Concrete workflow classes may add validation for their requirements.

Parameters

ParameterTypeDescriptionRequired
agents
Returns
void

Type definitions

LoopDecider

Type definition
Type parameters
<TState extends AgentData = AgentData>

Loop continuation predicate. Return true to run another iteration.

Parameters

ParameterTypeDescriptionRequired
state

Current workflow graph state.

config

Optional execution configuration.

Returns
Promise<boolean> | boolean

LoopWorkflowConstructProperties

Type definition
Type parameters
<TState extends AgentData>
Supertypes
Pick<LoopWorkflow‚ "decideContinue" | "workflow">