For AI agents: the complete documentation index is available at https://a3s-lab.github.io/Flow/en/llms.txt, the full documentation bundle is available at https://a3s-lab.github.io/Flow/en/llms-full.txt, and this page is available as Markdown at https://a3s-lab.github.io/Flow/en/nodes/iteration.md.

Iteration iteration

An iteration container applies one child-canvas scope to every member of a collection. The items expression is evaluated before the container starts, giving the host a deterministic input set to compile into stable tasks or child runs. Use it when every member follows the same processing structure and each item needs an explicit input and result boundary. Window very large collections before they reach the container so one run does not retain excessive task state.

Child-canvas structure

Each iteration container owns exactly one internal iteration-start node. Its ID must equal start_node_id, and its parentId must equal the container node ID. Every other child node uses the same parent ID. The entry node exposes the current member on its item data port, and next connects to the first executable child. Keep both endpoints of every child edge inside the same scope and include at least one executable node after the internal entry.

The normal graph stays acyclic. Do not draw a return edge to express repetition. Control enters through in and leaves through done after the host has resolved every member. The host defines serial or bounded-parallel execution, result aggregation, and failure policy. Publish those choices with the workflow because order and capacity behavior affect retries, incident handling, and reproducibility.

Stable members and validation

Give each member a repeatable business identity and avoid collections whose order depends on randomness or an unrecorded live query. Test an empty collection, one member, duplicate business keys, partial failure, runtime recovery, concurrency limits, and output ordering. When validation reports a cross-scope edge, inspect each child parentId and both edge endpoints. Use a loop container when one state should be processed repeatedly under a changing condition. For large deterministic sets, combine upstream pagination with a stable cursor and one iteration container per window.

Use it to create a child-canvas scope for each collection member. The items expression supplies the collection and the nested graph starts at one iteration-start node.

Runtime behavior

The container describes graph structure and emits no runtime command by itself. The host compiles the child canvas into stable steps or child workflows and owns member variables, concurrency, and aggregation.

Node contract

Type
iteration
Role
Child-canvas container
Runtime binding
Host compilation
Durable identity
Defined by graph structure

Configuration properties

PropertyType and controlDefaultRules
itemsItemsdictA3SFlowExpressionInput{"apiVersion":"a3s.dev/flow-expression/v1","expression":{"op":"field","path":"input.items"}}Collection evaluated before entering the iteration scope.Required
start_node_idStart node IDstrStrInputiteration-startStable identity of the iteration-start child in this container scope.Required · Advanced

Child-canvas structure

PropertyType and controlRules
iteration-startinternal nodeThe single nested entry whose parentId points to iterationRequired
parentIdnode idEvery nested node uses the same container IDRequired

Ports

DirectionPort IDKindValue types
InputinIncontrolFlowControl
OutputdoneDonecontrolFlowControl

Node JSON example

The CLI creates the same structure from manifest defaults. Canvas position, title, and selection are presentation data.

workflow.json
{
  "position": {
    "x": 320,
    "y": 160
  },
  "id": "example-iteration",
  "data": {
    "items": {
      "apiVersion": "a3s.dev/flow-expression/v1",
      "expression": {
        "op": "field",
        "path": "input.items"
      }
    },
    "start_node_id": "iteration-start",
    "type": "iteration"
  }
}

CLI usage

Inspect the installed manifest first, then create the node and validate the complete workflow. Every command emits JSON.

Terminal
a3s-flow node iteration --pretty
a3s-flow new iteration --id example-iteration --pretty
a3s-flow validate workflow.json --pretty
a3s-flow compile workflow.json --pretty
a3s-flow digest workflow.json --pretty

Skill usage

The package includes the a3s-flow Skill. It queries the CLI catalog before creating, validating, compiling, and digesting a workflow.

Prompt
Use $a3s-flow to add the "iteration" node to workflow.json, connect valid ports, and validate the result.

CLI usage · Skill usage

Operational notes

  • start_node_id must point to the nested iteration-start.
  • Add at least one executable child besides the start marker.
  • Edges cannot cross the container boundary.