Skip to content

Free · 7 modules · 46 lessons

Master AI Agents in Production

A traveller types a trip in plain words and gets real flights and hotels back. You build the system that does that. Then you keep it running when a worker crashes, a supplier fails, or the model quotes a price that no supplier returned.

  • 7 modules
  • 46 lessons
  • $0 price
  • 100% on GitHub

The course is free. You sign in with an email address.

Globetrotty planning a real trip. By the end of module 5 you'll have built everything on this screen.

The seven modules

The course is one repository built in seven modules. Each module starts from the code the previous one left.

  1. Stage 01 7 lessons

    From one call to an agent

    You write one call to the model and study the main shapes an agent can take. Then you build the first version of Globetrotty, which answers a real trip request.

    A working agent that answers one real trip request
  2. Stage 02 7 lessons

    Harness foundations

    You create the database, the background job that runs the agent, and an engine you can test without calling a model. You also add a type for money amounts and a log that records every model call with its cost.

    A database, a background worker, and an engine you can test
  3. Stage 03 7 lessons

    Surviving crashes

    A worker gets killed in the middle of a job. You make the job resume where it stopped without repeating the model calls it already made. Tests against a real Postgres prove it.

    A turn that resumes after a killed worker, with tests on a real Postgres
  4. Stage 04 6 lessons

    Suppliers, provenance, and gates

    You connect real flight and hotel searches. Then you add checks that reject a price with no matching search result, so every number the traveller sees comes from a search.

    Live suppliers and gates that reject any price no supplier returned
  5. Stage 05 7 lessons

    The fleet

    The agent makes its first live model call. You give it tools, guard it against untrusted input, add a memory that lasts across conversations, and decide what the traveller sees.

    Live model calls with tools, memory, and injection guards
  6. Stage 06 6 lessons

    Evals

    You measure whether the agent did a good job by grading its answers and the steps that produced them. The grading uses recorded trips, a simulated traveller, and a model as judge that you calibrate against human decisions.

    Grades for both answers and steps, with a model judge calibrated against human decisions
  7. Stage 07 6 lessons

    The self-improving loop

    You use the travellers' edits, choices, and bookings to pick better prompt examples. Each change ships as a reviewed commit on a schedule.

    Prompt examples chosen from real bookings, shipped as reviewed commits
Neciu Dan speaking at a conference
Who's teaching this

Hi, I'm Dan.

I'm a Senior Engineering Manager at Perk with 14+ years shipping production systems. I host Señors at Scale, a podcast for senior engineers, and I've given 30+ talks in 15 countries. The talks were about frontend, then architecture, and the recent ones are about agents.

I built this course the way I build at work, in one real repository where every design decision gets tested by running the code. The agency books real trips. You can check out any lesson's tag and run it yourself.

  • 14+years building
  • 30+conference talks
  • 15countries

Inside every module

Each module lists what you build, what you learn, and what goes wrong without it. Every lesson is free once you sign in.

// Ten shapes an agent can take. We hire eight.
type Shape =
  | 'single-call'   | 'chain'
  | 'router'        | 'supervisor'
  | 'parallel-fan'  | 'reflection'
  | 'tool-loop'     | 'evaluator'

const AGENCY: Shape[] = pickEight(all)
Stage 01 7 lessons

From one call to an agent

You write one call to the model and study the main shapes an agent can take. Then you build the first version of Globetrotty, which answers a real trip request.

You build
The agency's org chart and the eight architectures it is built from.
You learn
When to use a chain, a router, or a supervisor instead of a single model call.
The challenge
If the first version has the wrong shape, changing it means editing every file.
7 lessons in this module
  1. The first call
  2. Seats
  3. Reading her numbers
  4. The first tool
  5. Bounding the loop
  6. Two desks
  7. The notebook
// The engine is pure: same inputs, same plan.
export function turn(state: TurnState, io: Deps): Step {
  const notebook = applyRequirements(state.notebook)
  const spend    = ledger.reserve(SEATS.front_desk)
  return decide(notebook, spend)   // no I/O in here
}
Stage 02 7 lessons

Harness foundations

You create the database, the background job that runs the agent, and an engine you can test without calling a model. You also add a type for money amounts and a log that records every model call with its cost.

You build
The turn, the pure engine, the money type, the notebook, the call ledger.
You learn
The primitives every desk shares and why the engine stays pure.
The challenge
The model returns a different answer on every run, so no test can compare the plan to a fixed expected value.
7 lessons in this module
  1. Persist first
  2. Four tiers with a clock each
  3. Engine and shell
  4. Money is never a bare number
  5. Record every call
  6. Control the money
  7. Fifty presses, one turn
$ npm test -- worker-resume

  ✓ a killed worker resumes from its last ledger row
  ✓ a poison loop trips the step cap, not the bill
  ✓ two workers cannot claim the same turn

  Tests  3 passed (3)  ·  real Postgres
Stage 03 7 lessons

Surviving crashes

A worker gets killed in the middle of a job. You make the job resume where it stopped without repeating the model calls it already made. Tests against a real Postgres prove it.

You build
A turn that resumes after a killed worker, and a cap that stops a poison loop.
You learn
Durability, idempotency, and replay from the call ledger.
The challenge
When a worker is killed mid-turn, a retry restarts the turn from the first step and bills every model call again.
7 lessons in this module
  1. The claim with a fencing token
  2. Heartbeats and leases
  3. Completion in one transaction
  4. The tool-call intent ledger
  5. The sweeper
  6. The worker loop assembled
  7. Building the harness with agents
// Every quoted amount must trace to a supplier row.
for (const price of quotedAmountsIn(reply)) {
  if (!corpus.backs(price))
    return refuse('unbacked', price)   // model invented it
}
return pass()
Stage 04 6 lessons

Suppliers, provenance, and gates

You connect real flight and hotel searches. Then you add checks that reject a price with no matching search result, so every number the traveller sees comes from a search.

You build
Live flight and hotel data, behind gates that check every number.
You learn
Provenance, grounding, and refusing a price that has no source.
The challenge
Some replies from the model contain a price no supplier returned. Without a check, that number reaches her unchanged.
6 lessons in this module
  1. The supplier port
  2. Live adapters
  3. The provenance corpus
  4. The rehydration gate
  5. Freshness, currency, slots, totals, budget, dates
  6. The cashier
const desk = loadDesk('planning')          // hashed prompt
const out  = await callModel(desk, {
  tools: DESK_TOOLS,                       // fenced
  memory: readUserMemory(user),            // per traveller
})
record(out)                                // every call ledgered
Stage 05 7 lessons

The fleet

The agent makes its first live model call. You give it tools, guard it against untrusted input, add a memory that lasts across conversations, and decide what the traveller sees.

You build
The first real model call, with its tools, context fences, and memory.
You learn
Tool use, context fencing, memory, and what the traveller sees.
The challenge
Once the model has tools and memory, an instruction planted in untrusted input can call those tools and read that memory.
7 lessons in this module
  1. The first real model call
  2. Tools are doors
  3. The front desk and the planning desk
  4. Staff
  5. The exits nobody counted
  6. Memory and context
  7. What she sees
scorecard (3 cases graded)
  must_include              3/3 (100%)
  every_number_has_search   2/2 (100%)
  call_count_fits_the_job   0/3   ← the desk over-asks
  questions_before_guesses  3/3 (100%)
  judge agreement           0.83  ≥ 0.80 floor
Stage 06 6 lessons

Evals

You measure whether the agent did a good job by grading its answers and the steps that produced them. The grading uses recorded trips, a simulated traveller, and a model as judge that you calibrate against human decisions.

You build
Golden trips, a simulated traveller, and a model judge calibrated against human decisions.
You learn
Grading the output and the steps that produced it, and what to do about variance between runs.
The challenge
Two runs on the same trip return different answers, so one passing run is no evidence that the next one passes.
6 lessons in this module
  1. Why snapshot tests lie
  2. The gates are already evals
  3. Golden trips and the simulated traveller
  4. Pinning variance
  5. Trajectory grading
  6. The judge
// The loop writes data and proposes changes.
// A commit changes behaviour, never the model at runtime.
export const CADENCE = {
  weekly:    'npm run worst',      // read the worst traces
  monthly:   'npm run examples',   // refresh the prompt set
  quarterly: 'count, then decide', // fine-tune? usually no
}
Stage 07 6 lessons

The self-improving loop

You use the travellers' edits, choices, and bookings to pick better prompt examples. Each change ships as a reviewed commit on a schedule.

You build
A loop that reads her edits, choices, and bookings and produces prompt changes shipped as reviewed commits.
You learn
Conversions, example selection, release canaries, and cadence.
The challenge
A loop that rewrites prompts at runtime changes the agent's behaviour without a commit, so no one reviews the change.
6 lessons in this module
  1. The signal we already collect
  2. Three requirements
  3. The inversion bug
  4. Examples and memory
  5. Calibration and canaries
  6. The cadence

Start with module 1

All forty-six lessons are free. By the end of module 3 you have a repository you can run.