Skip to main content

Loops

A Loop step repeats its inner steps once for each item in a list. This is how you process multiple items in a single workflow.

Example: Analyze a list of companies

Say you have a list of 5 companies and want to research each one:
  1. Add a value step or Input that provides the list: ["Apple", "Google", "Tesla", "Amazon", "Meta"]
  2. Add a Loop step and set its Items to reference that list (drag in the token pill)
  3. Inside the loop, add an Ask AI step with a prompt like:
Research [current item pill] and summarize their business.
  1. The Ask AI step runs 5 times — once per company — automatically.
Loop step on the canvas showing the loop body with inner Ask AI step that runs for each item

Viewing loop results

During a run, you’ll see the loop expand on the canvas. Each iteration shows as a separate execution of the inner steps. Click on any iteration’s completed step to see that specific result in the side panel.

Collecting loop results with Mixer

Loop outputs are scoped — steps outside the loop can’t directly reference them. To use loop results in a later step:
  1. Add a Mixer step after the loop
  2. Set its Source to the inner step whose outputs you want to collect
  3. The Mixer produces a single list of all iteration outputs
Then downstream steps (like Export Table) can reference the Mixer’s output.
[Company List] → [Loop] → [Ask AI (×5)] → [Mixer] → [Export Table]

Loop limits

  • Maximum 1,000 items per loop
  • A cost estimate shows before running — loops multiply the cost by the number of items
  • StewAI warns you if a loop would use more than 90% of your remaining credits

Conditions (If Gate)

An If Gate step checks a condition and only runs certain downstream steps when the condition is true.

Example: Content approval

  1. Add a Decision step with the prompt: “Is this content appropriate for publication?”
  2. Add an If Gate step and set its Condition to reference the Decision step’s output
  3. Set the If Gate’s Targets to the steps that should only run when approved (e.g., a publish or email step)
If the Decision says “no” (false), the target steps are skipped entirely.

Combining loops and conditions

You can put an If Gate inside a Loop:
  1. Loop over a list of items
  2. For each item, run a Decision step: “Is this item relevant?”
  3. If Gate: only run the detailed analysis for relevant items
  4. Ask AI: deep analysis (only runs when the gate is true)
This saves credits by skipping items that don’t meet your criteria.

Next steps

  • Step Types — Full reference for Loop, If Gate, and all other steps
  • Exporting Results — Export loop results as spreadsheets
  • Schemas — Define structured output for each loop iteration