# loop

Canonical URL: https://developers.iagenify.com/sdk/workflows/steps/loop/
Language: en

`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.

Status: over and body required · 500 items · 10 in parallel

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `over` | string | required | A template naming a list. |
| `body` | string | required | The id of the step to repeat. |
| `max` | integer | 100 | How many items. 1 to 500. |
| `concurrency` | integer | 1 | How many at a time. 1 to 10. |

```javascript
{ 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 {#body}

> **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}

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

## concurrency is 1 by default {#concurrency}

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 {#results}

```javascript
{{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 {#failures}

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 {#truncation}

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

- [mail.read](/sdk/workflows/steps/mail-read): A common source of lists.
- [Warnings](/sdk/workflows/warnings): Including truncation.
- [Workflow steps](/sdk/workflows/steps): The 23 types.

```python
{"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}}"}]}}
```

```python
"{{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"}]
```
