quiet robot

Agent Playground

Tutorial 4: Try several ideas at once

Copy a sandbox into three lanes that run side by side, get a shipping quote in each, and keep the cheapest. The pattern behind bake-offs, A/B tests and comparisons.

View as Markdown

When you're not sure which way is best, you don't have to try them one after another. In this tutorial you'll split a run into three lanes that run at the same time, each with its own copy of the files, and then keep the best result. The example asks three shippers for a quote and books the cheapest, but the same shape works for comparing prompts, settings, suppliers or ideas.

Time: about 15 minutes. Plan: Pay as you go. This flow runs four sandboxes at once (the main one and three lanes), and Free runs up to three. Cost of a run: a fraction of a cent.

What you'll build: write the order, ask three shippers at once, keep the cheapest, book it.Write the order (Run command), Ask three shippers (Try in parallel), Quote from shipper A (Run command), Quote from shipper B (Run command), Quote from shipper C (Run command), Keep the cheapest (Keep the best), Book it (Run command). Arrows: Write the order to Ask three shippers; Ask three shippers to Quote from shipper A; Ask three shippers to Quote from shipper B; Ask three shippers to Quote from shipper C; Quote from shipper A to Keep the cheapest; Quote from shipper B to Keep the cheapest; Quote from shipper C to Keep the cheapest; Keep the cheapest to Book it on Passed.Passed>_ RUN COMMANDWrite the order⑂ TRY IN PARALLELAsk three shipperslanes A, B, C>_ RUN COMMANDQuote from shipper ALane A>_ RUN COMMANDQuote from shipper BLane B>_ RUN COMMANDQuote from shipper CLane C★ KEEP THE BESTKeep the cheapestlowest price>_ RUN COMMANDBook it
What you'll build: write the order, ask three shippers at once, keep the cheapest, book it.

1. Write the order

  1. In Agent Playground, choose New flow and name it Get three shipping quotes.
  2. Click the Start step, name it Write the order, and set its Command to:
Terminal
echo '12 boxes, 140 lb, Indianapolis to Denver' > order.txt && cat order.txt

Every lane gets a copy of this file, so each shipper quotes on the same order.

2. Split into three lanes

  1. With Write the order selected, click Try in parallel in the Blocks panel (under Sandbox). Name it Ask three shippers.
  2. In its settings, set the lanes to A, B and C. You can name lanes anything short, like Fast and Safe.

When the run reaches this block, it copies the sandbox into three lanes, in about a second.

3. Get a quote in each lane

Add three Run command steps, one per lane. For each one, set Run in to its lane, and connect it from Ask three shippers.

NameRun inCommand
Quote from shipper ALane Aecho 'Shipper A: $48.20' > quote.txt && cat quote.txt && echo '{"price": 48.20}'
Quote from shipper BLane Becho 'Shipper B: $41.75' > quote.txt && cat quote.txt && echo '{"price": 41.75}'
Quote from shipper CLane Cecho 'Shipper C: $52.00' > quote.txt && cat quote.txt && echo '{"price": 52.00}'

These commands stand in for asking a real shipper. In your own flow, each lane would call that shipper's website or API, or use an Agent to fill in their quote form.

The important part is the last bit of each command: a line of JSON with the number to compare, here {"price": 48.20}. That's how the next block knows which lane did best.

4. Keep the cheapest

  1. Add a Keep the best block (under Sandbox) and name it Keep the cheapest. Connect all three lanes to it.
  2. Set Number to compare to price.
  3. Set Best is to Lowest.

Keep the best reads each lane's number, keeps the winning lane as the main sandbox, and deletes the others. Only a lane that passed can win, so a lane whose step failed (say, a shipper's site was down) simply drops out.

Finally, add a Run command named Book it, connected from Passed on Keep the cheapest, with:

Terminal
echo "Booking with $(cat quote.txt)"

It runs in the winning lane's sandbox, so quote.txt is the cheapest shipper's quote.

5. Run it

Set the limits to Loops 1, Time 120 seconds and Spend $0.05, and choose Run.

A finished run: three lanes ran side by side, Keep the cheapest kept lane B at 41.75, and Book it says Booking with Shipper B.
The three quotes run at the same time. Keep the cheapest picks shipper B, and Book it runs in that lane's copy.

All three quotes run at the same time, so three take about as long as one. Keep the cheapest shows every lane's number and which one it kept: shipper B, at $41.75. Book it says Booking with Shipper B: $41.75.

When to use lanes

  • Compare and pick: three suppliers, three prompts for an AI, three settings for a report. Print the number you care about (price, score, seconds) and let Keep the best choose.
  • Try risky options safely: each lane has its own copy, so a lane that makes a mess can't affect the others. The Dependency upgrade bot recipe tries three upgrade plans this way and keeps the boldest one that still works.
  • Make a wrong answer lose: have each lane fail if its answer is wrong, so a fast or cheap wrong answer can never win. The Try 3, keep the best recipe shows this.

Each lane is a sandbox, and you pay for each one's time, so three lanes cost about three times one. A short lane still costs a tiny fraction of a cent.

What you learned

  • Try in parallel copies the sandbox into lanes that run at the same time.
  • Run in on each step picks its lane.
  • Keep the best compares a number each lane prints as JSON, keeps the best lane that passed, and carries on in it.

Next

In Tutorial 5, you'll add AI to a flow: one step that drafts a reply with Claude, and an agent that works toward a goal on its own.

  • Agent PlaygroundQuickstart: build and run your first flow
  • Agent PlaygroundBlocks
  • Agent PlaygroundRecipes
  • SandboxesQuickstart: your first sandbox
  • SandboxesMCP server
  • SandboxesAPI reference