For each
Step · Stable
Loop over a list, running the body once per item (sequential).
Four invariants to know:
- Items source is upstream — the foreach itself does not make a list; it iterates one that already exists in context (e.g. {{ memory_find.items }}).
- The body is one path with a loop variable — inside the body, {{ <loop_var> }} (default: {{ item }}) is the current item.
- The body must back-edge to the foreach — without it the foreach runs once and stops. This is the ONLY legitimate cycle in the graph (the validator allows this one back-edge and rejects all others).
- After-edge runs once — whatever connects via the “after” label out of the foreach runs exactly once, with the foreach’s label equal to a list of each iteration’s results.
Execution is sequential (no concurrency). limit hard-caps the number of iterations. A human gate (Ask actor) inside the body pauses per item; resume rotates to the next.
When to use
Section titled “When to use”Use when an upstream step produces a list (e.g. List Contacts returns values: [...], List from memory returns neighbour entities) and you need to run the same body — enrich, notify, update — for every item. The loop variable (default: item) is the current array element; inside the body, primitives bind directly as {{ item }} (numbers, strings) while objects expose fields via {{ item.field }}. Nested access works the same way: {{ item.address.city }} for nested objects and {{ item.roles[0].title }} for nested arrays. The after-edge runs once when all items are processed.
When not to use
Section titled “When not to use”For a single conditional split use Branch or Switch — they are far cheaper when there is only one item to route. For parallel fan-out (multiple concurrent asks), use fire-and-continue Ask Actor with a downstream Checkpoint; For each is strictly sequential.
Inputs
Section titled “Inputs”string · required
A {{ reference }} to a list to iterate.
Example: {{ memory_find.items }}
loop_var
Section titled “loop_var”string · optional
The name each item binds to inside the body (default: item).
Example: item
int · optional
Optional hard cap on how many items to process.
Example: 5
Auto-generated from the skill registry (load_skills()). Do not edit by hand.