Skip to main contentBy default, when running a Tool, each tool step is executed once. However, Relevance supports running a step multiple times in a loop as well.
Loops
Imagine a scenario where we wish to run a step across a set of items. For instance, a list of topics, for each we need to generate a description
using a large language model. Or a list of movie names for each we want to generate a summary.
- Access loops under the three-dot menu on the top right of steps. Click on Enable foreach.

Run this transformation multiple times
is the input field that expects a list of items (e.g. list of movie names).
Provide the input list manually or activate the variable mode as shown in the image below.

and use {{variable-name}}
to access an existing variable in the Tool, for instance {{movies}}
.
- Access every single item from your input list within a step via
{{ foreach.item }}
or/and {{ foreach.index }}
.
In the image below, there is a Python step returning a list of items. We wish to run a large language model
on each of the elements with the instruction “Write me a … ”.

After enabling Foreach, under Run this transformation multiple times
, we enable the variable mode and access
the Python step output via {{python.transformed}}
- note that the name of the step is python
in our example.
Next, we use {{foreach.item}}
to access each of the elements in the list.
After running the step, we will have as many output tabs as the number of elements in the input list.