Skip to main content
Looping allows you to Loop through a list of Tool steps in your Tools, based on a list outputted from previous steps, or an input from the Tool.

How to set up Looping in a Tool

  1. Add a Loop by clicking the button to create a new Tool step, then navigate to the Flow Controls tab to select a Loop
  2. Select the list you want to Loop over in List to loop
  3. Choose how to process list items, either at the same time or one by one
  4. Add Tool steps inside the Loop
  5. Once you’ve done that, run the Tool to test the Loop

Accessing Loop items within steps

Inside a Loop, each step runs once per item in the list. You can reference the current item and its position using template variables.

{{foreach.item}}

Use {{foreach.item}} to access the current element being processed. For example, if your list contains movie names, {{foreach.item}} resolves to the name of the current movie on each iteration.

{{foreach.index}}

Use {{foreach.index}} to access the zero-based position of the current item in the list. The first item has index 0, the second has index 1, and so on. This is useful when you need to track position or produce numbered output.

Referencing step outputs

To Loop over the output of a previous step, enable variable mode on the List to loop field and use {{step_name.output_field}} syntax. For example, if an earlier step named python returns a list in a field called transformed, you would enter {{python.transformed}} as the list source.
Suppose you have a Python step named python that returns a list of movie names in a field called transformed. You want to run an LLM step on each movie with the prompt “Write me a summary of …”.
  1. Add a Loop step and set List to loop to {{python.transformed}} (enable variable mode first).
  2. Inside the Loop, add an LLM step.
  3. In the LLM prompt, write: Write me a summary of {{foreach.item}}.
  4. Run the Tool. The Loop produces one row per item in the list, with each row containing the LLM’s response for that movie.
You can also reference the item’s position — for example, Item {{foreach.index}}: {{foreach.item}} — to include a numbered label in each output.

Output format

When a Loop runs, the output is returned in a cell-based format where each row represents one run of the Loop — one per item in the list. If your list has five items, you will see five rows, each containing the output for that iteration. This lets you inspect the result for each individual item in a table structure rather than a single aggregated output. If an item errors during processing, its row appears under the Errors tab of the Loop step results by default (see error handling settings below).

Advanced settings

How should errors be handled?

Specifies how the Loop should handle errors. Defaults to continue (skip item), but you can also choose to throw an error.

Index of item to test Loop on

You can also choose a specific index to test with. This is helpful for debugging and also for testing your overall flow with a single item to reduce credit costs.

Frequently asked questions (FAQs)

Yes, you can choose to process items in your list either in parallel or sequentially. If you select parallel processing, all items will be processed at the same time, which can speed up execution. If you prefer to handle them one at a time, you can opt for sequential processing.
By default, if an item in the Loop errors, it will be skipped, and you can view the errored items in the errors tab of the Loop step results. If you prefer to be notified of errors instead, you can adjust the error handling settings to throw a tool error. This way, you can address issues as they arise.