Workflow fan-out: pipeline() against parallel()
You have a list of items to push through stages of agents. Running everything in parallel feels like it should finish first, but it doesn’t. A run that completes can still drop failed items from its results without saying so, and every stage that inherits your session model pays that model’s price. This page simulates the schedule both ways, shows what the results array really holds, estimates the cost by model, and checks a script you paste for these sharp edges.
Predict first
Four items go through two stages, at a concurrency of 16, so every agent can start the moment it’s ready. Each cell is how many minutes that item’s agent takes.
| Item | Stage 1 | Stage 2 |
|---|---|---|
| 1 | 1 | 10 |
| 2 | 1 | 1 |
| 3 | 1 | 1 |
| 4 | 10 | 1 |
Set up the run
Start from a preset, or change anything below.
Settings
Loading the settings…
The schedule, both ways
Rows are items and bars are agents. A vertical line marks when each run finishes. Seed 7.
- S1: Review (solid)
- S2: Verify (striped)
- Queued for a slot (hatched)
- Idle at a barrier
- Null or error
pipeline() finishes 1.9 min sooner than parallel().
pipeline(): 12.9 min Each item moves to its next stage as soon as its own agent finishes.parallel() per stage: 14.8 min Every item waits at the barrier until the slowest item of the stage finishes.Hover a bar, or focus a chart and use the arrow keys, to read it. Drag a bar’s right edge, or press + or − on a selected bar, to change its duration; the durations switch to the manual grid and both charts recompute.
Loading the schedule table…
What the script receives
The array pipeline() resolves to, item by item. Which way you
handle nulls changes what you’re told.
Loading the results…
Cost and scale
Loading the cost estimate…
Loading the copy buttons…
Check a script
Paste or drop a workflow script for a heuristic check of the sharp edges on this page.
Loading the script checker…
When not to use a workflow
| Skip a workflow when… | Use instead |
|---|---|
| You’re making just one edit. | Make the edit in the session. There’s nothing to fan out. |
| The shape is unknown, or the plan will change as you go. | Work it out in the session, or with one subagent, until the shape settles. |
| You need a person’s approval partway through. | Split it: run the first half, review it yourself, then start the second. |
| Agents would share files they all change. | Give each agent its own worktree, or keep the edits in one agent. |
| Checking the fan-out’s results costs more than the fan-out saves. | Do the work serially, where each step is easy to verify. |
The concepts, and where they come from
Loading the explanation…