Agent Playground
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.
1. Find the old reports
- In Agent Playground, choose New flow and name it
Tidy up old reports. - Click the Start step and name it
Find old reports. - Set its Command to:
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.
- With Find old reports selected, click Approval in the Blocks panel (under People and rules). It's added below, joined from Passed.
- Name it
Delete them? - In What should a person approve?, write the question your teammate will see:
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
- With Delete them? selected, click Run command. Name it
Delete old reportsand set its Command to:
xargs rm < old.txt && echo "Deleted $(wc -l < old.txt) old reports" && ls reports- Add an Output and name it
Kept everything. - 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:
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.
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, you'll make a flow try again when something fails, and see the loop limit stop a run that would never finish.