---
title: Limits and safety · Agent Playground docs
description: How the Agent Playground keeps a run from looping forever, overspending or doing something you didn't want, with limits, approvals, per-flow rules and keys that never enter the sandbox.
url: https://www.quietrobot.ai/docs/playground/safety
---

# Limits and safety

How the Agent Playground keeps a run from looping forever, overspending or doing something you didn't want, with limits, approvals, per-flow rules and keys that never enter the sandbox.

Letting an AI work on its own is useful because it can try again and again. That's also the risk: it can try forever, spend money while it does, or do something you'd have said no to. The Playground puts five kinds of protection around every run.

| Protection | Stops |
|---|---|
| [Limits](#limits) | A run that loops too often, runs too long or spends too much. |
| [Approvals](#approvals) | A step running before a person says yes. |
| [Policy](#policy) | Commands you don't want, and connections to sites you haven't allowed. |
| [Checkpoints and rewind](#checkpoints-and-rewind) | A stopped run leaving a half-done mess. |
| [Keys that stay out](#keys-that-stay-out) | Your API keys leaking from the sandbox. |

## Limits

Every run has three limits. Open **Limits** in the builder to set them.

| Limit | What counts | Default | Range |
|---|---|---|---|
| **Loops** | Each trip back round a loop counts once. | 5 | 1 to 50 |
| **Time** | Seconds from the first step, including time spent waiting for a person. | 300 | 10 to 3,600 |
| **Spend** | What the run costs: sandbox time plus AI usage at list prices. | $0.25 | $0.01 to $5 |

```flow
{"title": "The Runaway loop recipe: Check always fails, so the loop limit stops the run and the sandbox rewinds to Start.", "nodes": [["setup", "run", "Start", "go back here"], ["retry", "run", "Try again"], ["check", "run", "Check", "always fails"], ["done", "end", "Done", "never reached"]], "edges": [["setup", "retry"], ["retry", "check"], ["check", "retry", "Failed"], ["check", "done", "Passed"]]}
```

A run stops at whichever comes first. The limits are checked on our side, not in your browser, so a run stops on time even if you close the tab or lose your connection. A command that is running when a limit is reached is stopped within a couple of seconds.

**Picking good limits.** Run **Simulate** first. The forecast shows how often each limit would stop the run, and **At most**, the most a run could cost with the limits you set. If the loop limit stops a large share of simulated runs, raise **Loops** or improve the step that keeps failing. If the worst case is more than you'd want to spend, lower **Spend** or **Time**.

An agent has its own limits too: **Turns** and **Spend on the model**. Whichever is reached first, the agent's or the run's, stops it.

## Approvals

There are three ways to make a run wait for a person:

```flow
{"title": "Two of them in one flow: an Approval block before shipping, and a step that asks a person first.", "nodes": [["fix", "agent", "Fix the bug"], ["ok", "approval", "Ship this fix?"], ["deploy", "run", "Deploy", "asks a person first"], ["held", "end", "Not shipped"]], "edges": [["fix", "ok", "Done"], ["ok", "deploy", "Approved"], ["ok", "held", "Denied"]]}
```

1. **An Approval block.** The run pauses at that point with your question, like "Ship this fix?". **Approved** and **Denied** each have their own exit, so you decide what a "no" does.
2. **Ask a person first** on a step, under **Advanced**. That step waits before it runs. On an agent, every command it runs and every file it writes waits.
3. **Rules that hold commands.** Your organization's [approval rules](https://www.quietrobot.ai/docs/sandboxes/approvals) (like `rm -rf`, `sudo` or `git push`) hold matching commands in every run, and a flow's [policy](#policy) can add more.

A waiting step shows as **waiting** in the run, appears in **Approvals** in the dashboard, and sends the usual approval email to the people you chose. Only a signed-in person can approve: an API key can't, so an agent can never approve its own command. When a person or rule refuses an agent's command, the agent is told, and told not to work around it.

The run's **Time** limit keeps counting while a step waits. For a flow with an approval, give it enough time for a person to answer, like 900 seconds or more.

## Policy

Open **Policy** in the builder (or choose the **Rule** block) to set rules for this flow. **Your organization's rules always apply**, and a flow can only add to them.

### Network for this flow

What every sandbox in the run may reach:

| Choice | What it means |
|---|---|
| **Organization default** | Your organization's saved default. See [Outbound network](https://www.quietrobot.ai/docs/sandboxes/network). |
| **No internet** | Nothing in or out. AI steps still reach Claude. |
| **Only these sites** | Up to 50 sites, one per line, like `pypi.org` or `*.github.com`. Everything else is blocked. |
| **Open** | Any site. |

Turn on **Lock it** and nothing in the run can widen the network, not even a command that tries.

For one step only, open its **Advanced** settings and turn on **No internet for this step**. The sandbox is cut off while that step runs, then the flow's rules come back, whatever happened in the step. This is good for steps that run code you don't trust, like an agent's fix or a downloaded script.

### Also hold these commands for a person

Up to 20 extra rules for this flow. Each is a pattern matched against every command, with a description people see when it holds something:

| Pattern | Description |
|---|---|
| `git push\|npm publish` | Publishing needs a person |
| `DROP TABLE\|DELETE FROM` | Deleting data needs a person |
| `curl .*-X (POST\|PUT\|DELETE)` | Changing another system needs a person |

Patterns are regular expressions and ignore case. A pattern that's too slow to check holds the command, so a mistake fails safe.

A pattern matches the text of each command, and of each file an agent writes. Treat these rules as an early warning, not a wall: a program can do something a pattern doesn't spell out. For a hard stop, use an **Approval** block before the step, and the network rules above.

**Simulate** points out what your policy will likely touch, step by step: a step that waits for a person, a command a rule will hold, or a step without network whose command looks like it needs one.

## Checkpoints and rewind

After each step that passes, the sandbox saves a **checkpoint**: a copy of its files at that moment. They're kept for 24 hours after the run.

* **Rewind when stopped.** Choose a step and turn on **Go back here if a limit stops the run** under **Advanced**. If a limit stops the run, the sandbox goes back to that step's checkpoint, so a runaway loop doesn't leave half-applied changes behind. The **Runaway loop** recipe shows this.
* **Open a sandbox from any step.** In a finished run, open a step and start a new sandbox from its checkpoint, to look around or carry on by hand.

Turn off **Save a checkpoint when it passes** on quick steps that don't change anything, to make runs a little faster.

## Keys that stay out

AI steps use your own Claude key, saved once under **Policies → Secrets**. The key never enters the sandbox. Code in the sandbox, including whatever an agent writes, only sees a stand-in that's useless anywhere else, and the real key is added on the way out, only to the sites the secret allows. The same goes for any other secret a flow uses. See [Keys, identity and outbound check](https://www.quietrobot.ai/docs/sandboxes/secrets).

## Everything is recorded

Every command a run executes, every approval and every blocked connection is written to your organization's [audit log](https://www.quietrobot.ai/docs/sandboxes/audit), with the run it came from. An agent's commands are recorded one by one, like a person's.

## Run limits

| Limit | Free | Paid plans |
|---|---|---|
| Runs at the same time | 1 | 5 |
| Runs started an hour | 20 | 20 |
| Steps in a flow | 40 | 40 |
| Arrows in a flow | 80 | 80 |
| Parallel lanes | 10 | 10 |
| One command | 10 minutes | 10 minutes |
| A whole run | 1 hour | 1 hour |

Run sandboxes are billed like any other sandbox, at your plan's prices, and count toward your organization's [spend cap](https://www.quietrobot.ai/docs/sandboxes/plans-and-limits).
