Skip to main content
Loop tasks turn a single task into one subtask per row of a CSV or text file — no manual iteration.

Quick Start

1

Loop a task over a CSV

2

Same task, async entry point


How It Works

The workflow reads input_file before the run loop begins and expands the loop task into one subtask per row.

Choose the Right Loop


Sync vs Async

Loop pre-expansion runs identically for workflow.start() and await workflow.astart(). Prior to SDK versions from 2026-07-27 the async path ran the loop task once as an ordinary task and ignored input_file. If you were using async workflows with task_type="loop", upgrade to pick up the fix.

Common Patterns

Summarise a list of URLs

Loop then post-process each row


Best Practices

When task_type="loop" and no input_file is set, the workflow reads tasks.csv from the working directory.
Each row is passed to {input} as a single string. Put structured data in JSON inside the row and parse it in the agent instructions.
Subtasks execute one after another. Use AgentFlow.parallel when you want fan-out across rows.
Other rows still run. Check per-subtask TaskOutput to find which rows failed.

Workflow Loop

AgentFlow-level loops over a CSV as a pipeline step

Workflow Repeat

Repeat a step until a condition is met — no file needed