---
title: Graph shapes · Agent Playground docs
description: The shapes a flow can take, with a small example of each: a straight line, branches, loops, loops inside loops, parallel lanes, agents working together, and how paths join again.
url: https://www.quietrobot.ai/docs/playground/graph-shapes
---

# Graph shapes

The shapes a flow can take, with a small example of each: a straight line, branches, loops, loops inside loops, parallel lanes, agents working together, and how paths join again.

A flow doesn't have to be a straight line. Arrows can split it, bring it back together, and send it round again. This page shows each shape with a small example you can draw in a few minutes. The diagrams are drawn like the builder's canvas: they read top to bottom, the word on an arrow is the exit it leaves from, and a dashed arrow going back up is a loop.

## A straight line

The simplest flow: each step runs after the one before.

```flow
{"title": "A straight line: each step runs after the one before.", "nodes": [["get", "run", "Get the code"], ["build", "run", "Build"], ["test", "run", "Run tests"], ["done", "end", "Done"]], "edges": [["get", "build", "Passed"], ["build", "test", "Passed"], ["test", "done", "Passed"]]}
```

If any step fails, the run ends there as failed, because its **Failed** exit has no arrow. That's often what you want.

## Branches

A branch sends the run one of two (or more) ways. There are three kinds.

**On pass or fail.** Draw an arrow from each exit of the same step.

```flow
{"title": "A branch on pass or fail.", "nodes": [["test", "run", "Run tests"], ["pkg", "run", "Package"], ["bug", "run", "Write a bug report"]], "edges": [["test", "pkg", "Passed"], ["test", "bug", "Failed"]]}
```

**On a condition.** A **Decide** block asks a yes or no question with a command, and the run goes on either way.

```flow
{"title": "A branch on a condition: the Decide block answers yes or no with a command.", "nodes": [["lint", "run", "Lint"], ["any", "branch", "Anything to say?", "test -s findings.txt"], ["ok", "approval", "Post the review?"], ["good", "end", "Looks good"]], "edges": [["lint", "any"], ["any", "ok", "Yes"], ["any", "good", "No"]]}
```

**On an AI choice.** An **Ask AI** block set to **Decision** gets one exit per choice.

```flow
{"title": "A branch on an AI choice: one exit per choice.", "nodes": [["read", "run", "Read the ticket"], ["sort", "choice", "Sort the ticket", "refund · bug · how-to · spam"], ["refund", "approval", "Refund this customer?"], ["bug", "run", "Draft a bug report"], ["reply", "model", "Draft a reply"], ["spam", "end", "Ignored"]], "edges": [["read", "sort"], ["sort", "refund", "refund"], ["sort", "bug", "bug"], ["sort", "reply", "how-to"], ["sort", "spam", "spam"]]}
```

> [!TIP]
> Name your Output blocks for the ending they mean ("Shipped", "Not posted", "Ignored"). A run's ending then tells you what happened without opening it.

## Loops

A loop is an arrow back to an earlier step. The classic is "try, check, fix, check again":

```flow
{"title": "A loop: the dashed arrow goes back up, and each trip round counts as one loop.", "nodes": [["write", "run", "Write code"], ["test", "run", "Run tests"], ["fix", "run", "Fix failures"], ["save", "run", "Save result"]], "edges": [["write", "test"], ["test", "fix", "Failed"], ["fix", "test", "Next"], ["test", "save", "Passed"]]}
```

The loop ends when a step takes another exit (the tests pass) or a [limit](https://www.quietrobot.ai/docs/playground/safety#limits) stops it. Every trip back counts as one loop, so with **Loops** set to 5 the run tries at most five fixes.

**A retry with a pause** puts a **Wait** in the loop, so a busy website gets a moment:

```flow
{"title": "A retry with a pause.", "nodes": [["fetch", "code", "Fetch page"], ["wait", "wait", "Wait 3 s"], ["parse", "code", "Parse table"], ["save", "run", "Save"]], "edges": [["fetch", "wait", "Failed"], ["wait", "fetch", "Next"], ["fetch", "parse", "Passed"], ["parse", "save"]]}
```

**A loop with a way out.** A step in the loop can have its own exit that leaves it. In the bug reproduction recipe, the step that writes the next test fails when it has run out of ideas, and that exit goes to "Ask for more detail" instead of round again.

## Loops inside loops

A loop can sit inside another loop. In this flow the inner loop retries a flaky download, and the outer loop rewrites the analysis until it runs:

```flow
{"title": "Loops inside loops: an inner retry and an outer fix, both counted by the same loop limit.", "nodes": [["write", "run", "Write analysis"], ["dl", "run", "Download data"], ["wait", "wait", "Wait 5 s"], ["run", "run", "Run analysis"], ["fix", "agent", "Read the error, fix it"], ["out", "end", "Summary"]], "edges": [["write", "dl"], ["dl", "wait", "Failed"], ["wait", "dl", "Next"], ["dl", "run", "Passed"], ["run", "fix", "Failed"], ["fix", "write", "Done"], ["run", "out", "Passed"]]}
```

Both loops count toward the same **Loops** limit, so set it for the total number of trips you'll allow.

## Parallel lanes

**Try in parallel** copies the sandbox into 2 to 10 lanes. Each lane has its own copy of the files, so the lanes can't break each other's work. On each step after it, set **Run in** to its lane.

```flow
{"title": "Parallel lanes: each lane gets its own copy of the sandbox, and Keep the best keeps one.", "nodes": [["setup", "run", "Set up"], ["fork", "fork", "Try in parallel", "lanes A, B, C"], ["a", "run", "Insertion sort", "Lane A"], ["b", "run", "Built-in sort", "Lane B"], ["c", "run", "Dedupe and sort", "Lane C"], ["judge", "judge", "Keep the best", "lowest ms"], ["keep", "run", "Keep the winner"]], "edges": [["setup", "fork"], ["fork", "a"], ["fork", "b"], ["fork", "c"], ["a", "judge"], ["b", "judge"], ["c", "judge"], ["judge", "keep", "Passed"]]}
```

A lane can be more than one step: draw a chain of steps that all run in lane A. A lane that fails just drops out of the contest.

Use lanes when you'd otherwise try ideas one after another: three prompts, three upgrade plans, three ways to research a question. They finish in the time of the slowest one, not the sum.

## Agents working together

**Agents together** is the other way to do things at once. Its members share one sandbox and its files, instead of each getting a copy.

```flow
{"title": "Agents together: both agents work at once in the same sandbox, sharing its files. Arrows go to and from the group.", "nodes": [["setup", "run", "Set up"], ["team", "team", "Docs and tests", "Write the docs + Write the tests"], ["check", "run", "Run tests"], ["done", "end", "Done"]], "edges": [["setup", "team"], ["team", "check", "Done"], ["check", "done", "Passed"]]}
```

| | Try in parallel | Agents together |
|---|---|---|
| Files | Each lane has its own copy | Shared by all members |
| How many | 2 to 10 lanes | 2 to 6 members |
| Ends with | **Keep the best** picks one lane | **All are done**, or **the first is done** |
| Good for | Competing ideas | Splitting one job into parts |

## Joins

When paths come back together, the step they meet at runs once, after the paths before it are finished.

* **Lanes join at Keep the best.** Draw every lane's last step to the same **Keep the best** block. It waits for the lanes, keeps the passing lane with the best number as the main sandbox, and deletes the rest.
* **Agents join when the group finishes.** With **all are done**, when every member passes. With **the first is done**, as soon as one passes; the others are stopped.
* **Branches join at a shared step.** Two branches can lead to the same next step, like the "Restart" and "Leave it running" paths that both go on to "Write the summary" in the alert recipe. Use **Either way** on an arrow when the next step should run whatever happened.

## What isn't possible yet

* **A flow inside a flow.** You can't use one saved flow as a single block in another. For now, build the shared steps into each flow. **Duplicate** on the Agent Playground page copies a whole flow to start from.
* **Lanes inside a loop.** A **Try in parallel** block can't run again on a later trip round a loop. Put the loop before the lanes or after **Keep the best**, or run the whole flow again.
* **Combining lanes.** Lanes can't be merged into each other: **Keep the best** keeps one. If you need parts of several lanes, have each lane print the number that matters, keep the best lane, and run a step after it that redoes the part you need.

## Size limits

A flow can have up to 40 steps and 80 arrows. Each step can write up to 20 files (256 KB in total) before it runs, and a single command can run for up to 10 minutes. See [Limits and safety](https://www.quietrobot.ai/docs/playground/safety) for the limits on a whole run.
