Workflow steps

loop

type: "loop"

Repeats one step over a list. Up to 500 items, up to 10 at a time — and a failed item does not stop the others.

over and body required500 items10 in parallel
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

overstringrequired

A template naming a list.

bodystringrequired

The id of the step to repeat.

maxinteger100

How many items. 1 to 500.

concurrencyinteger1

How many at a time. 1 to 10.

{ id: "each",   type: "loop", config: {
    over: "{{steps.inbox.output.messages}}", body: "triage", max: 50, concurrency: 4 } }

{ id: "triage", type: "model.generate", config: {
    model: "gemini-3.5-flash",
    inputs: [{ type: "text", content: "Classify: {{item.subject}}" }] } }
{"id": "each", "type": "loop", "config": {
    "over": "{{steps.inbox.output.messages}}", "body": "triage", "max": 50, "concurrency": 4}}

{"id": "triage", "type": "model.generate", "config": {
    "model": "gemini-3.5-flash",
    "inputs": [{"type": "text", "content": "Classify: {{item.subject}}"}]}}

The body carries no edges

It belongs to the loop, not to the graph

A step named as a body must have no connection of its own, and no other loop may claim it. That is what keeps the graph acyclic while the repetition happens inside one step.

A loop cannot repeat itself, and cannot repeat a human, condition, switch, merge, wait or another loop.

The body sees item and index

{{item}} and {{index}}, on top of the run's own context.

concurrency is 1 by default

Deliberately: a workflow saved before should cost the same and keep the order of its effects. Raising it changes how long the loop takes and whether it fits at all — but the ceiling is 10, because beyond that a provider starts refusing.

Results are ordered by index

{{steps.each.output.count}}        // processed
{{steps.each.output.failed}}       // how many failed
{{steps.each.output.total}}        // how many the list held
{{steps.each.output.results}}      // [{ index, ok, output } | { index, ok: false, error }]
"{{steps.each.output.count}}"      # processed
"{{steps.each.output.failed}}"     # how many failed
"{{steps.each.output.total}}"      # how many the list held
"{{steps.each.output.results}}"    # [{"index", "ok", "output"} | {"index", "ok": False, "error"}]

By index, never by order of completion — with concurrency the finishing order is not the list's, and an output whose order depends on timing cannot be used downstream.

One failure does not stop the rest

A failed item is recorded with its error and the loop continues. failed is what a condition after it should test — losing the work done on forty-nine items because the fiftieth was malformed would be the wrong trade.

More items than max

The extra ones are not processed, and a warning says how many arrived against how many were handled.