Spec-Driven Dev
BeginnerBeginner engineers and product managers

Building and Evaluating AI Agents

Build a support agent, make it measurable, find its failures, gate it with tests, red-team it, and improve accuracy and cost.

You will build a support agent for a tiny fictional plant shop, record everything it does, find where it fails, turn those failures into tests, red-team it, and then make it both more accurate and cheaper. Every idea comes with a small example, and Eve, the built-in tutor, is one highlight away.

11 lessons · about 10 hours of reading · quizzes graded by code and by Eve

What you will build
  1. 1SPEC.mdscope, tools, risk tiers
  2. 2Agent + tracespermissions in code
  3. 3Scenarios~500 synthetic cases
  4. 4Failure taxonomyopen + axial coding
  5. 5Evaluatorscode checks + judges
  6. 6CI gatepass^k, monitoring
  7. 7Red teamguards + approval
  8. 8Frontieraccuracy × cost
Analyze Measure Improve

How the course is organized

PhaseQuestion it answersLessons
AnalyzeWhat is the agent actually doing, and where does it fail?L0–L4
MeasureHow often does each failure happen, and can we detect it automatically?L5–L7
ImproveWhich change fixes it at the lowest cost, and did it really help?L8–L9

Modules

Module 0

Start Here

A gentle primer for beginners: what language models, agents, tools, and traces are, and why normal testing is not enough.

0/1 done · 35 minStart
Module 1

Building Agents

Write the spec, build a support agent with permissions enforced in code, instrument it so its behavior is measurable, and generate the scenarios every later module uses.

0/3 done · 165 minStart
Module 2

Error Analysis

Turn traces into a human-owned failure taxonomy, then build validated evaluators and a prevalence estimate you can defend.

0/2 done · 120 minStart
Module 3

CI/CD

Turn failures into a regression suite that gates deployments, and monitor production with the same evaluators.

0/1 done · 60 minStart
Module 4

Security, Safety, and Governance

Map the attack surface, red-team the running agent, add guards and human approval, and keep a governance record.

0/1 done · 60 minStart
Module 5

Improving Agents

Compare configurations on accuracy and cost, route each fix to the cheapest layer, and run the upgrade drill when new models ship.

0/2 done · 120 minStart
Module 6

Bonus

Common traps in eval-focused interviews and how to avoid them.

0/1 done · 30 minStart

Every lesson

Module 0Start Here

Module 1Building Agents

  • L1Analyze· 60 min Not started
    Building Agents: Foundations

    Write Sprout's SPEC.md, meet the Three Gulfs, build the agent loop, and put permissions in code.

  • L2Analyze· 50 min Not started
    Building Agents: Designing for Evaluability

    Record model calls, tool calls, and permission decisions as nested spans, send them to self-hosted Langfuse, and read a trace to find the first failure.

  • L3Analyze· 55 min Not started
    Building Agents: Synthetic Data and Scenarios

    Build a tiny seeded world for Pip's Plant Shop, write scenarios with ground truth, generate hundreds from a dimension grid, and read your first smoke report.

Module 2Error Analysis

  • L4Analyze· 55 min Not started
    Error Analysis: Finding Failures

    Read traces one at a time, write the first failure in plain words, group the notes into binary failure modes, and stop when new traces stop surprising you.

  • L5Measure· 65 min Not started
    Error Analysis: Measuring with Evaluators

    Turn each failure mode into a binary evaluator, prove it works with TPR and TNR on labeled traces, and report prevalence with a confidence interval you can defend.

Module 3CI/CD

  • L6Measure· 60 min Not started
    CI/CD for Agents

    Turn each failure into a replayable test case, pick a cost tier, measure reliability with pass^k, gate merges in GitHub Actions, and keep watching production.

Module 4Security, Safety, and Governance

  • L7Measure· 60 min Not started
    Safety and Adversarial Evaluation

    Map Sprout's attack surface, red-team it with promptfoo, turn attacks into fail-closed tests, add guards and human approval, and keep a governance record.

Module 5Improving Agents

  • L8Improve· 60 min Not started
    Improving Agents: Accuracy and Joint Optimization

    Compare configurations on a Pareto frontier, route each fix to the cheapest layer, run a manual fix loop before automating, and prove the win on a held-out test slice.

  • L9Improve· 60 min Not started
    Improving Agents: Cost

    Profile where the tokens go, cut cost with caching, trimming, routing, and cascades calibrated on labeled data, and run the upgrade drill when a new model ships.

Module 6Bonus

  • B1Bonus· 30 min Not started
    Bonus: Evals Interview Prep

    Recognize the nine traps of eval-focused interviews, answer with Analyze, Measure, Improve and real numbers, and build a portfolio that proves you have run the loop.

Meet Pip's Plant Shop

A small online store that sells houseplants. Sprout is its support agent. Customers ask about orders, shipping, refunds, and plant care. Every lesson uses the same shop, the same people, and the same six tools, so you never have to re-learn the setting.

ToolWhat it doesRisk tier
lookup_orderStatus, items, and dates for one orderT0 · read-only
get_shipping_statusCarrier and tracking eventsT0 · read-only
search_care_guidePlant-care articlesT0 · read-only
cancel_orderCancels an unshipped orderT1 · reversible write
issue_refundSends money backT2 · irreversible, needs a human
escalate_to_humanHands the chat to MayaT0 · always allowed

The module and lesson structure follows the public syllabus of "AI Evals for Engineers & PMs" by Hamel Husain and Shreya Shankar. All lesson text, examples, quizzes, the glossary, and the Pip's Plant Shop world were written for this course.