---
title: Tutorial 2: Ask a person before anything real happens · Agent Playground docs
description: Build a flow that finds old files and waits for your OK before deleting them. Approve it from your phone, and set limits so a run can never cost or take more than you allow.
url: https://www.quietrobot.ai/docs/playground/tutorials/approvals-and-limits
---

# Tutorial 2: Ask a person before anything real happens

Build a flow that finds old files and waits for your OK before deleting them. Approve it from your phone, and set limits so a run can never cost or take more than you allow.

Some steps can't be undone: deleting files, sending an email, charging a card, publishing a change. In this tutorial you'll build a flow that does the safe part on its own, then **stops and waits for a person** before the part that can't be undone. You'll approve it from your phone, and set the limits that keep every run in check.

**Time:** about 10 minutes. **Plan:** Free. **Cost of a run:** a fraction of a cent.

```flow
{"title": "What you'll build: find the old reports, ask, then delete or keep.", "nodes": [["find", "run", "Find old reports"], ["ok", "approval", "Delete them?"], ["del", "run", "Delete old reports"], ["kept", "end", "Kept everything"]], "edges": [["find", "ok", "Passed"], ["ok", "del", "Approved"], ["ok", "kept", "Denied"]]}
```

## 1. Find the old reports

1. In **Agent Playground**, choose **New flow** and name it `Tidy up old reports`.
2. Click the **Start** step and name it `Find old reports`.
3. Set its **Command** to:

```bash
mkdir -p reports && touch -d '90 days ago' reports/january.pdf reports/february.pdf reports/march.pdf && touch reports/november.pdf && find reports -name '*.pdf' -mtime +30 | sort | tee old.txt && echo "$(wc -l < old.txt) reports are more than 30 days old"
```

The first part makes four practice files, three of them old, so you have something safe to try this on. The `find` part is the real job: it lists every report older than 30 days and saves the list in `old.txt`. In your own flow, you'd keep just the `find` part and point it at your real folder.

## 2. Add the approval

An **Approval** block pauses the run until a person approves or denies. Nothing after it happens until then.

1. With **Find old reports** selected, click **Approval** in the Blocks panel (under **People and rules**). It's added below, joined from **Passed**.
2. Name it `Delete them?`
3. In **What should a person approve?**, write the question your teammate will see:

```text
Delete the reports that are more than 30 days old? The list is in the output of Find old reports.
```

An approval has two exits: **Approved** and **Denied**. You decide what each one does.

## 3. Add what happens on each answer

1. With **Delete them?** selected, click **Run command**. Name it `Delete old reports` and set its **Command** to:

```bash
xargs rm < old.txt && echo "Deleted $(wc -l < old.txt) old reports" && ls reports
```

2. Add an **Output** and name it `Kept everything`.
3. Select **Delete them?** and, under **Where next**, set **Approved** to **Delete old reports** and **Denied** to **Kept everything**.

Choose **Tidy up** in the zoom controls at the bottom left. Your flow should look like this:

<figure class="shot">
  <img class="art-light" src="/docs/playground/tutorials/approvals-builder-light.webp" alt="The builder with Find old reports, then an Approval called Delete them?, which goes to Delete old reports when approved and Kept everything when denied." width="1440" height="900" loading="lazy">
  <img class="art-dark" src="/docs/playground/tutorials/approvals-builder-dark.webp" alt="" width="1440" height="900" loading="lazy">
  <figcaption>The approval sits between finding the files and deleting them.</figcaption>
</figure>

## 4. Set the limits

Open the limits button in the toolbar (it reads `5 loops · 300 s · $0.25`) and set:

| Limit | Set it to | Why |
|---|---|---|
| **Loops** | 1 | This flow doesn't repeat anything. |
| **Time** | 900 seconds | The clock keeps running while the flow waits for you, so give a person 15 minutes to answer. |
| **Spend** | $0.05 | The most this run may cost. It will cost far less. |

A run stops at whichever limit comes first. The limits are enforced on our side, so a run stops on time even if you close the tab or lose your connection.

> [!TIP]
> If nobody answers before the **Time** limit, the run stops and nothing after the approval happens. For a flow that waits on a busy person, raise **Time** (up to 3,600 seconds).

## 5. Run it, and approve from your phone

Choose **Run**. **Find old reports** passes and lists three files, then the run stops at **Delete them?** and shows as **waiting**. Three things happen:

* A banner appears at the top of the dashboard: **Waiting for your OK**, with **Approve** and **Deny** buttons. On the Approvals page the button is called **Approve and run**.
* The approval shows under **Approvals** in the dashboard menu.
* Your team gets an approval email, if your organization has approval emails turned on (**Policies**, **Approval emails**).

Now pick up your phone, sign in to the dashboard, and open **Approvals**.

<figure class="shot shot-phone">
  <img class="art-light" src="/docs/playground/tutorials/approvals-phone-light.webp" alt="The Approvals page on a phone: Delete them? from Tidy up old reports, with the question, and Approve and run and Deny buttons." width="393" height="852" loading="lazy">
  <img class="art-dark" src="/docs/playground/tutorials/approvals-phone-dark.webp" alt="" width="393" height="852" loading="lazy">
  <figcaption>A waiting approval on a phone. Read the question, then choose Approve and run, or Deny.</figcaption>
</figure>

Choose **Approve and run** (or **Approve** on the banner). Back in the builder, the run carries on: **Delete old reports** deletes the three old files and lists what's left (`november.pdf`). Run it again and choose **Deny** instead: this time the run ends at **Kept everything** and nothing is deleted.

Only a signed-in person can approve. An API key can't, so an AI agent can never approve its own work.

## 6. Two more ways to make a run wait

An Approval block is the clearest way, but there are two more:

* **Ask a person first** on any step. Select the step and tick **Ask a person first** under **Rules for this step**. The step waits for an approval before it runs. On an AI agent, every command it runs and every file it writes waits. It's a quick way to keep a close eye on a new flow while you get to know it.
* **Your organization's rules.** Some commands always wait for a person in every run, such as deleting everything in a folder (`rm -rf`) or pushing code. See them under **Policies** in the dashboard, and add your own there. A flow's **Policy** button can add more rules for just that flow.

## What you learned

* An **Approval** block pauses a run until a person says yes or no, and each answer gets its own arrow.
* You can approve from the builder's banner, the **Approvals** page on any device, or the approval email.
* **Limits** cap every run's loops, time and spend. The time keeps counting while a run waits, so give a person enough time to answer.

## Next

In [Tutorial 3](https://www.quietrobot.ai/docs/playground/tutorials/loops), you'll make a flow try again when something fails, and see the loop limit stop a run that would never finish.
