Multi-Step AI Workflow: Draft, Review and Revise Without Code
Hands-on lab · IDE in your browser

Multi-Step AI Workflow: Draft, Review and Revise Without Code

Build an AI workflow in a YAML file, with no code: split one prompt into a facts step and a writing step, give the writer rules it can follow, add a stronger model that reviews each draft for invented claims, revise only the drafts it flags, then swap in a cheaper writer and prove the workflow on books it has never seen, within a cost budget.

Time
50 min
Checked steps
5
Level
Beginner
Setup
None
Read step 1

Hands-on labs require Pro · $29.99/mo · cancel anytime

Lab cockpit50 min · 5 stepsSession running
4 / 5 steps passingA cheaper writer, tested on new books · step 5 of 5
workflow.yaml▶ Run✓ Check
    output: text    prompt: |      Write a newsletter blurb for a bookshop, using only these facts:      {facts}   
TerminalOutput

The job

Brightline Books' weekly newsletter carries a short blurb for every new title, written from the shop record and three customer reviews. Last month a blurb called a debut novel "award-winning", and it had never won anything. You build the workflow that writes the blurbs: a facts step, a writer, a reviewer and a reviser, each one a prompt in workflow.yaml. A harness runs it on real-looking books, checks the house rules with code and every claim with a fact-checking model, and prices each blurb.

5 steps, each checked when you finish it

A check runs your work at the end of every step. Hints and the full solution are there if you get stuck.

  1. 1

    Split one prompt into facts and a draft

    Brightline Books sends a weekly newsletter with a short blurb for each new title.

  2. 2

    Give the writer rules it can follow

    The newsletter template has a fixed slot for each blurb.

  3. 3

    Add a reviewer that catches invented claims

    Your drafts pass today, but a writer model can still invent a prize, a film deal or a wrong number on a new book, and nobody will notice until a customer does.

  4. 4

    Revise only what the reviewer flags

    A reviewer that finds a problem is only half a fix; someone still has to rewrite the draft.

  5. 5

    A cheaper writer, tested on new books

    The shop will run this workflow on every new title, about 400 a week.

Step 1 as it appears in the lab

The lab’s own text. The hint and the solution stay inside the lab.

Step 1: Split one prompt into facts and a draft

Brightline Books sends a weekly newsletter with a short blurb for each new title. The blurbs come from a shop record and three customer reviews, and last month one blurb called a debut novel "award-winning". It had never won anything. You will build the workflow that writes the blurbs, one step at a time, in workflow.yaml. There is no code to write.

Click Run first. The current workflow is one step: a large model reads everything and writes the blurb. Look at the scorecard. Every blurb is too long, most shout with exclamation marks, and the fact check finds praise that no reader gave.

One prompt doing everything is hard to check, because you cannot see what the model believed before it started writing. Split the job so that one step decides the facts and another step writes from them.

Do this in workflow.yaml:

  1. Replace the blurb step with a step called facts: model: small, output: json. Its prompt uses {record} and {reviews} and asks for JSON only, with keys you name, for example title, author, genre, price, premise and reader_views. Tell it to copy facts and add none.
  2. Add a step called draft after it: output: text. Its prompt asks for a newsletter blurb and includes {facts}, and not {record} or {reviews}. A writer that sees only the checked facts cannot copy anything else.
  3. Click Run, then run python3 run_workflow.py --book 6 in the terminal to watch one book go through both steps.

The check runs your workflow on the 8 practice books. The facts step must return JSON on at least 7, and at least 6 blurbs must name the title and the author. The length and hype rules come in the next step.

workflow.yaml, the file you edit22 lines
# workflow.yaml: how the newsletter blurb for one book gets written.
# Each step sends one prompt to a model and saves the reply under the step's name.
#   {record} and {reviews}  the book's shop record and three customer reviews
#   {facts}                 the whole output of an earlier step called facts
#   {review.ok}             one field of an earlier step's JSON output
#   model: small            Llama 3.1 8B, cheap      model: large   Llama 3.3 70B, about 6x the price
#   when: review.ok == false   run the step only when that field has that value
# The blurb is the output of the last text step that ran.
steps:
  # TODO (Step 1): split this one step into two: facts (small model, JSON) and draft (text,
  # written from {facts} only). Delete this step when you have both.
  - name: blurb
    model: large
    output: text
    prompt: |
      Write a newsletter blurb for our bookshop about this book, using the record and the reviews.

      Record:
      {record}

      Reviews:
      {reviews}
Provided for you:books.jsonlreview_tests.jsonlrun_workflow.pyworkflow.py

Frequently asked questions

Do I need to code for this lab?

No. You edit workflow.yaml, a text file of steps and prompts, and click Run. A harness runs the steps for each book and prints a scorecard.

Why split the work into several AI steps?

Each step does one job you can test. The writer sees only the extracted facts, so it cannot copy an unchecked claim, and the reviewer can be tested on drafts with known mistakes before you trust it.

Why use a large model to review and a small one to write?

Checking a draft against a source is the harder job, and the reviewer protects everything the writer produces. In the lab the small writer with a large reviewer passes the held-out books at lower cost than a large writer.

How are the blurbs graded?

Code checks the length, the title and author, and banned hype words. A large model compares each blurb with the book record and reviews and lists any claim they do not support.

Chaining AI steps: facts, draft, review, revise

One prompt that does everything is hard to check and hard to fix. Most AI automations that work in production are a few small steps: pull out the facts, write from them, check the result with a stronger model and rewrite only when the check fails. Each step is simple enough to test on its own. In this lab you build that chain in a YAML file with no code. You see why models follow a sentence shape better than a word count, test a reviewer on drafts with planted mistakes, add a conditional revise step that runs only when needed, and cut the cost by giving the writing to a small model while a large one checks it, confirmed on held-out books.