---
title: Recipe: Runaway loop · Agent Playground docs
description: Retries something that will never work. A guard stops it and rewinds the sandbox to the last good checkpoint. What it does, when to use it, how to make it yours, and what a run costs.
url: https://www.quietrobot.ai/docs/playground/recipes/runaway-loop
---

# Recipe: Runaway loop

Retries something that will never work. A guard stops it and rewinds the sandbox to the last good checkpoint. What it does, when to use it, how to make it yours, and what a run costs.

Retries something that will never work, on purpose, so you can see what a limit does: the loop limit stops the run, and the sandbox goes back to its last good checkpoint.

| At a glance | |
|---|---|
| **Category** | Safety |
| **Shape** | A limit stops it |
| **Plan** | Free and up |
| **Needs a Claude key** | No |
| **Limits it comes with** | 4 loops, 120 seconds, $0.05 |

```flow
{"title": "Runaway loop, as it is on the canvas.", "nodes": [["setup", "run", "Start", "go back here"], ["retry", "run", "Try again"], ["check", "run", "Check"], ["done", "end", "Done"]], "edges": [["setup", "retry"], ["retry", "check"], ["check", "retry", "Failed"], ["check", "done", "Passed"]]}
```

<figure class="shot">
  <img class="art-light" src="/docs/playground/recipes/runaway-loop-light.webp" alt="The Runaway loop recipe in the builder after a run, with each step's result on the canvas and the run's steps listed on the right." width="1440" height="900" loading="lazy">
  <img class="art-dark" src="/docs/playground/recipes/runaway-loop-dark.webp" alt="" width="1440" height="900" loading="lazy">
  <figcaption>A real run of the recipe. The panel on the right lists every step with what it printed.</figcaption>
</figure>

## When to use it

* You're new to the Playground and want to know what happens when something goes wrong.
* You're choosing limits for your own flows and want to see one in action.
* Showing a teammate why every loop needs a limit.

## Run it

1. Open **Agent Playground** in the dashboard and find **Runaway loop** under **Start from a recipe**. In the builder, **Recipes** in the toolbar lists them too.
2. Choose **Use this recipe**. It becomes a flow of your own, so changing it never changes the recipe.
3. Choose **Simulate** to see the forecast, then **Run**.

**What you'll see:** The loop goes round four times, then the run ends as **Stopped at a limit**, with the loop limit named as the reason. The sandbox is rewound to the checkpoint after **Start**, so none of the half-finished attempts are left behind. **Simulate** says it before you run: nearly every run will hit the loop limit.

## Make it yours

This recipe is for learning, not for changing. In your own flows:

* Give every loop a limit you'd be happy to hit.
* Tick **Go back here if a limit stops the run** (under **Advanced**) on the last step that leaves things clean.
* Run **Simulate** before you run, and raise the limit or fix the failing step if the forecast says the limit will often stop the run.

## What a run costs

These are the builder's own forecast for the recipe as it comes, with its limits, rounded. **Simulate** shows the same numbers for your version, and they change as you change the flow.

| | Typical | 1 in 10 runs | At most |
|---|---|---|---|
| **Sandbox time** | $0.0002 | $0.0002 | $0.0015 |
| **How long it takes** | 14 seconds | 16 seconds | 120 seconds |

A typical run uses $0.0002 of sandbox time, so about 5,500 runs cost $1, and every plan includes $5 of usage a month. **At most** is the most a run could cost with these limits: it stops at $0.05 or 120 seconds, whichever comes first.

## Related

* [Tutorial 3: Keep trying until it works](https://www.quietrobot.ai/docs/playground/tutorials/loops)
* [Limits and safety](https://www.quietrobot.ai/docs/playground/safety)
* [Safety recipes](https://www.quietrobot.ai/docs/playground/recipes/safety)
* [All recipes](https://www.quietrobot.ai/docs/playground/recipes)
