Engineering AI Agents · Week 6
Multi-agent, oversight, the outer loop, and when not to
Splitting the work · signing for it · running it overnight · deciding whether to buy it
Slides CC BY 4.0 · from the teaching kit of AI Agents, Engineered by Enrique Gutiérrez · aiagentsengineered.com/teach/
Where we are: last week finished Part III with quarantine and began Part IV with workflow patterns, in which your code fixes the list of subtasks before any input shows up. Today completes Part IV, one chapter per part of the lecture.
Part 1, Chapter 11: the subtask list now has to be produced at runtime, by a model, and handed to other models. Part 2, Chapter 12: which actions must wait for a person, where that waiting happens in the system, and how far an agent may go between your check-ins. Part 3, Chapter 13: taking yourself out of the prompting seat with a loop that runs unwatched. Part 4, Chapter 14: reading the full bill line by line, then deciding whether to pay it.
All four chapters are in the full book; the slides quote them where it matters.
Before anything else · one minute on paper
The task: “Summarize the competitive landscape for managed vector databases.”
Write down the subtasks you would hand to a team of workers.
Chapter 11, “The Orchestrator–Worker Pattern”
Chapter 11 opens with this exercise. One minute on paper, then ask two or three people how far down their list they got.
Expect most lists to stall after one line, something like “profile each vendor”, because nobody yet knows who the vendors are. Someone has to scan the market before the work can be split. Put the question to the room: could a pipeline you wrote a month ago already contain this list?
Don’t name the problem yet; the next slide does.
By the end of today you can
Four objectives
Decide single or multi-agent with one question; write a brief with four fields
Sort tools into four consequence tiers and write the gate policy
Specify a goal function with a hard cap and a kill switch
Price a request on the ladder with the four-line quote
One objective per chapter, each with a verb you can test: decide and write, sort and write, specify, price.
All four are on the reading quiz. The first two are today’s exercise, in two browser tools. The second and third are Lab 5: a gate in code in front of the risky tools, and a small outer loop that runs the agent against a checklist on disk. The fourth is the project proposal due with Lab 5.
Part 1 · Chapter 11 (full book)
Multi-agent systems
Open with a familiar moment: you watch one agent plod through a long task and think in org charts. One gathers, one drafts, one reviews, a lead hands out the work. The chapter says that instinct is half right. Right, because on some workloads parallel agents finish far faster and cover more ground than one window could hold. Wrong, because your sense of teamwork comes from colleagues who share history and corridors, and a worker agent shares none of that.
Also flag that this is where serious practitioners openly disagree. The chapter holds the argument until after the evidence, and this part follows the same order (slide 10).
The dividing itself takes judgment, exercised at runtime, on this input
The orchestrator–worker pattern
A lead decomposes , workers run in their own windows, the lead synthesizes
Week 5’s fan-out: you wrote the list at design time
Buys speed and clean desks
Costs tokens: ~4× a chat for one agent, ~15× for multi-agent
Figure from Chapter 11 · ~4× and ~15×: one team’s measurement of its own system, illustrative
Close slide 2: the list the room could not write is the point. This pattern hands that judgment to a model. Walk the figure: an orchestrator (lead, supervisor) takes the task, splits it, and gives each piece to a worker, which is a subagent running the whole loop in its own window. Workers run, often side by side; the orchestrator then synthesizes, which means merging overlaps, settling conflicts and spotting holes.
Drawn on a board it resembles last week’s parallelization. Point at the second bullet: the difference is who writes the list, and when. The chapter’s first test, to apply before anything else: “if you can write the subtask list before seeing the input, use the workflow.” Use an orchestrator only when making the list needs intelligence.
Benefits. Speed: one team reports cutting research time by up to 90 percent on hard queries (a snapshot figure, illustrative). And clean context: every worker starts fresh, can spend tens of thousands of tokens on dead ends, and sends back a short summary; this is quarantine grown into an architecture. Point at the cost bullet: each worker is a full agent, and the same team measured roughly four times a chat’s tokens for one agent and roughly fifteen for multi-agent. Parallelism gets you wall-clock time and breadth, never efficiency. One lever: put workers on a cheaper model tier and keep the costly tier for splitting and synthesis. The token count still multiplies; the bill doesn’t have to.
Predict before the next slide
An orchestrator hands three workers the same brief: “research the semiconductor shortage.”
What comes back?
Chapter 11, “Focused, Self-Contained Worker Context” · from one production team’s published report
Thirty seconds in pairs. Ask for a prediction, and above all for where the failure originates: inside the workers, or before them?
Then sit at the worker’s desk together. You start with no project memory. You never heard what the user asked, weren’t present for the planning, can’t see the other workers and don’t know they exist. All you have is one memo. Slide 8 names this seam; the production team’s own report of what came back is in the instructor pack (week 6).
Delegation quality is the variable that most separates systems that work from those that embarrass you
The brief: four fields
Objective : the one thing this worker produces
Output format : the shape it comes back in
Tools and sources : which tools, where to look
Boundaries : what belongs to a sibling
The test: a ticket for a contractor who has never seen your project and cannot ask questions
Figure from Chapter 11
Point at the four fields; the team behind the research system arrived at this checklist, and the chapter asks students to know it by heart. Objective: the single thing this worker must deliver. Output format: so that synthesis is assembly rather than a second round of interpretation. Tools and sources: their own cautionary case is an agent searching the open web for context that only exists in an internal chat tool, a lost cause from the first call. Boundaries: what to leave alone because a sibling owns it.
Give the chapter’s sample brief for one vendor in the landscape task. Objective: profile vendor X’s managed offering on pricing model, scaling limits and index types. Output: about 200 words under those three headings. Sources: web search, favoring the vendor’s own docs. Boundary: no vendor comparisons, since synthesis does that.
Two further choices. How agents share information: return values only (what most products default to), a shared scratchpad or blackboard, or message passing; begin with return values and change only when a failure you actually observed demands it. And keep bulky artifacts out of the messages: workers save them to a store and return a pointer, so nothing degrades through retelling. Read the contractor test at the bottom of the slide aloud.
With five agents you own a distributed system, and its bugs live in the seams
Four seams, one rule
Seam What it looks like
Duplicated work and gaps One vague brief, several private readings, an uncovered flank
Conflicting implicit assumptions Every piece is right; the pieces do not compose
The game of telephone A summary of a summary; the load-bearing caveat shaved off
The laundered return An injected instruction, delivered in a colleague’s voice
Keep writes single-threaded: one agent owns the artifact; everyone else advises.
Chapter 11, “Coordination Failure Modes” · 1,600+ traces, 14 modes in 3 clusters: Cemri et al. (2025)
Cite the map before the rows: a research group (Cemri et al., on the slide) annotated more than 1,600 traces from seven multi-agent frameworks and sorted fourteen failure modes into three clusters: system design, misalignment between agents, and weak verification. The brief is the first cluster, verification is week 8, and this slide is the middle one.
Row one is what the room just predicted, and it is the seam you control best, since you write its text. Row two survives even good briefs. The chapter borrows the skeptics’ example: split a small arcade game so one worker makes the scrolling background with its pipes and another makes the bird. Both deliver; the art styles don’t match, and it looks like two games stitched together. Each action carries quiet decisions (a style, an API choice, how to treat the empty case) that parallel workers can’t see in each other, and no brief can list them all.
Row three: anything passing through the lead is a summary of a summary, and the caveat that mattered is the first thing trimmed. Row four is friendly-looking: a return comes back polished, in house style, from one of ours, so it earns more trust than raw tool output. If the worker swallowed an injected instruction, that tidy summary now carries it. Rule: treat a worker’s return as tool output, unverified until checked. Underneath all four is week 2’s compounding arithmetic, which doesn’t stop at the boundary between agents.
Then the bottom line of the slide, the one rule the field agrees on. Parallelize reading: search, review, analysis, second opinions. Keep writing with one owner, because that is where mismatched assumptions get baked in. Log every brief and every return from the first day; the bugs live there, and week 7 shows why rebuilding them from memory fails.
Map is cheap and orderly; the reduce can be arbitrarily complicated
The merge wall
Workers branch from a baseline that each of them can change
A merge queue : serialize the rebases
Triage : some work is inherently serial
Rhythm : swarm for a while, then pause and serialize
Figure from Chapter 11
Chapter 11 · “Adding agents adds hands and coverage; it does not add judgment.”
The clearest evidence for where this pattern stops working comes from a practitioner running eight or more coding workers through an orchestrator he built himself. He describes swarming as map and reduce. Mapping fans out nicely. In classic map-reduce the reduce step is trivial, adding up counts; with agents it is the hard part. His extreme case: one worker deleted a whole subsystem while another shows up with a pile of edits to it. By the time worker four is done, what the first three changed may have knocked out its assumptions.
Walk the three remedies on the slide. A merge queue that serializes rebases and gives each worker enough context to land on the new baseline. Triage, because some work is serial by nature and shouldn’t be fanned out. A rhythm: swarm for a stretch, then stop and serialize; his example is a directory restructure that breaks every worker’s imports at once. Point back at the first remedy: a merge queue is the one-writer rule from slide 8, enforced at integration, where nobody can opt out.
He also reports one dazzling unattended success that he couldn’t repeat. Make the chapter’s distinction: working once and working are separate claims. The neutral evidence lines up: the trace study starts from the observation that multi-agent gains on popular benchmarks are often small.
Start with one agent; then ask one question
The verdict is a procedure
“Does this work decompose into branches that can run without seeing each other ?”
Yes Broad research, wide review, evaluation sweeps: the orchestrator is on the table
No Shared state, silent decisions, an order that matters: keep one continuous context
If you split: single-threaded writes, briefs for a stranger, tracing from day one, the bill measured
Chapter 11, “The Merge Wall and the Single-versus-Multi Verdict”
Now the debate held back from slide 4. Two teams that build agents professionally published opposite verdicts within weeks. The skeptics said collaborating agents make fragile systems and recommended one linear agent with careful context engineering. The other team, the research system again, showed numbers where orchestrator–worker won. Put side by side, the conflict comes down to something both stated openly: the workload. Research mostly reads, its sub-questions are largely independent, and a report can live with seams. Coding changes one shared artifact, merges results, and treats seams as bugs. Multi-agent isn’t a sign of maturity to graduate into; the chapter calls it “an architecture with a habitat.”
Unpack the question on the slide into three conditions: nothing mutable that branches share, no branch relying on what another decides, and no required sequence. Two supporting signs usually line up: the material truly overflows a single window, and the threads would be separate even if nobody had declared them so.
Last case: often the orchestrator is you, juggling several agents. Then your attention is the scarce resource. Practitioners argue over the number but agree there is a ceiling: past a handful, each additional agent dilutes your attention to all the others. Real capacity is how many finished results you can verify, understand and integrate in a day. Hands can be hired; judgment stays with you. Part B of today’s exercise uses the chapter’s brief check.
Part 2 · Chapter 12 (full book)
Oversight and autonomy
Ask the room to recall the most impressive person their team hired recently. On day one that person could out-argue everyone and still couldn’t merge to main alone, spend the company’s money or email a customer unsupervised, and nobody took offense, because people earn trust by being watched. Organizations even write it down as signing limits: who can approve what.
That is the model for oversight in this chapter: a written policy of which actions need a second signature, scaled to consequence, and loosened as trust builds. Three tools come out of it: gates, review and the dial. Where the analogy breaks is memory. The analyst carries earned trust from day to day; the agent starts every run from zero. So you keep the record on behalf of a worker that can’t.
Check · pairs · one minute
Which of five tools wait for a signature?
look up an order draft a reply send the reply issue a refund delete a customer record
Then: what did you consult to decide?
Chapter 12, “Approval Gates and Escalation” · the chapter’s support agent
The chapter’s own sorting exercise. Pairs mark which of the five tools need a person to sign off; most rooms agree fast.
Put the minute into the second question. Ask a pair what they based the decision on, and don’t accept “common sense”: did anyone weigh how capable the model is, or how it behaved last month? Slide 13 names the principle; the tool-by-tool key is in the instructor pack (week 6).
Grade the action by what it costs when it is wrong
Four consequence tiers
Read-only : runs freely
Reversible : runs, if logged to undo
Externally visible : review queue
Irreversible : a signature, every time
The model’s confidence plays no part
Figure from Chapter 12 · claimed 90% confidence, ~75% real: one production analysis, illustrative
Note what the pairs did: they graded the actions, not the model. Following one practitioner guide, the chapter formalizes that into four tiers; walk down the figure. Read-only runs freely: putting a gate there adds no safety and trains the approver to stop reading. Reversible runs too, as long as there is enough logging to undo and audit. Anything an outsider will see goes into a queue for review. Irreversible or high-stakes actions need a signature, with no exceptions. The chapter frames it as insurance: you only insure what you can’t afford to lose.
Point at the last line of the slide. Obvious, and broken all the time: the model’s confidence counts for nothing. Letting someone act when they say they’re sure is how you manage people. Today’s models are overconfident in exactly the dangerous direction; one production analysis found claims of 90 percent confidence matching roughly 75 percent actual accuracy, and the gap grows along a chain. Sycophancy makes it worse. Consequence is about the world; confidence is about the model’s mood.
Read the chapter’s caveat aloud: exactly where each tier begins is a judgment call, and the ordering principle is what lasts. Today’s exercise uses a browser tool that asks these questions in a set order; that order is the tool’s choice, and its page says so.
After the model has chosen, before anything runs
The gate lives in your code
model proposes → validate → gate → execute
Fires on what the action is
Escalation fires on how the run is going : repeated failure, out-of-policy input, signs of injection, a budget nearly spent
May it wait? Queue it. Irreversible or suspected injection? Block.
The handoff The action in plain language · why · what it touches, and can it be undone · before → after · approve · reject · reject with edits
Chapter 12 · “Send a decision, not a transcript.” · “Over-gating does more than annoy. It defeats the gate.”
Back to week 2’s seam: the model emits a proposed action as structured data, and plain deterministic code runs it. A gate is a checkpoint placed in that seam; walk the pipeline across the top of the slide. One builder’s guide specifically wants a way to interrupt between choosing a tool and calling it. The rule the chapter puts above all others: “the gate must live in your code, never in the agent’s judgment.” If the model decides whether it needs approval, anything that can talk the model round (an odd task, a poisoned document, an injected prompt) can talk it out of asking. The gate is triggered by the kind of action, never by the model’s reading of the request.
The other half gives the agent a way to stop on its own: a tool for asking a human. Anything findable, the agent finds itself; preferences and intent belong to the person. Escalation triggers, listed on the slide, fire during the run. Then the asymmetry: a minor question can wait in a queue while the agent carries on; an irreversible action or suspected injection stops everything until someone clears it. If approval arrives on Tuesday, the run must have checkpointed cleanly and the approval must bind to exactly the action the person saw; week 10 builds that.
The handoff box decides whether the gate works at all. Give someone a raw transcript late on a Friday and they’ll click yes without thinking. Send a decision, and offer more than yes or no: reject with edits is often the most useful button. Spend signatures only on the top tiers, since approvals that become routine stop being read. Lab 5 builds exactly this gate.
Four hundred lines across nine files, tests green, twenty minutes later: approved
Review intent and outcomes, not lines
Criteria “Done” stated before the run
Scope Declared; anything outside is a flag
Walkthrough What changed and why, in order
Evidence Proof a stranger could check
Cheapest of all: review the plan before any code exists. Verify what you can delegate; understand what your next decisions depend on.
Chapter 12, “Reviewing Intent and Outcomes, Not Lines” · review theater : diligence performed at a volume where it can no longer be real
Tell the scene from the slide title: end of the day, four hundred lines across nine files, tests passing. You begin at line one, by file three you’re skimming, you approve after reading about a quarter. The ceremony remained; its purpose didn’t. That’s review theater. The risk is that green checks measure less than they appear to: code can build and pass everything while solving a neighboring problem, or straying outside the scope you agreed.
Lift review up a level to two questions: did the agent aim at the right thing within the agreed scope, and can it show that what it did works? Walk the four boxes: criteria for done written before the run; a declared scope, which turns the diff into a checklist; a walkthrough in the agent’s own words; and evidence a stranger could check. Even cheaper, the line under the boxes: review the plan. Okaying five steps takes a couple of minutes and catches a misunderstood requirement while it is still one sentence.
Then raise the strongest objection: agents keep getting better at checking their own work, so why spend on human understanding? The chapter splits understanding in two. Understanding to verify is a thumbs-up question that tooling keeps absorbing. Understanding to participate is what produces your next idea, the better split, the hunch that an approach is wrong; that one you either do yourself or lose. The bottom line of the slide says it. Week 12 builds the comprehension toolkit.
How much an agent may do between moments of your attention, set per task
The autonomy dial
Moves on evidence , in both directions
Start every new task class tight
Re-earn the setting after every model upgrade
The same person runs both ends on the same day
Interruption is only cheap if resuming is
Figure from Chapter 12
Gates, escalation, plan review, intent review and steering all sit on one continuum; walk the figure’s four positions. Tightest: nothing consequential runs without a signature, which suits new agents, new kinds of task, and anything touching money, deletion or the public. Standing permissions: some action types pre-approved (always allow this, always ask about that, never the other), with the agent free inside that envelope and escalating at its edge. Plan approval: sign off the strategy and keep the right to interrupt. Monitored autonomy: runs alone within budgets, reviewed afterwards, kill switch close at hand. The dashed box belongs to Part 3.
What moves a task along the dial is evidence, and dull evidence: clean completed runs, sensible escalations, eval scores with honest sample sizes. Two contrasts with the new hire matter. You hold the record, not the worker. And the worker changes in jumps: a model upgrade can shift ability overnight, up on some tasks and down on others. So the settings have to be re-earned after every upgrade (third bullet).
Interrupting a run that’s drifting feels impolite; with an agent it’s just steering, provided the system makes it cheap. Point at the last bullet: cheap interruption depends on cheap resumption, so invest in resumability first. And the dial is set per task, as the fourth bullet says. The chapter’s clearest example splits one person’s day: core work at the tight end, side chores at the loose end, like a surgeon whose team handles the prep so the surgeon’s hands stay where judgment can’t be replaced.
Part 3 · Chapter 13 (full book)
Writing the outer loop
Every agent so far in the course has had one component sitting just off the slide: you. You wrote the task, watched it run, read the output and chose what to ask next. This chapter goes to the far end of the dial and replaces you as the one doing the prompting.
Pin down two terms first. The inner loop is the agent itself: one task, cycling through observe, reason, act until a stop condition trips. The outer loop is what surrounds it: it picks the task, starts the inner loop in a fresh window, judges the result, keeps durable score and decides what comes next. Students already run one manually, in their heads; the chapter’s source calls that the backlog. Offer the chapter’s picture of a night shift that starts when a trigger fires, leaves a report for the morning, and remembers only what it wrote down.
Predict before the next slide
The same prompt file, piped into a coding agent, forever, on a fresh project, overnight:
while :; do cat PROMPT.md | agent ; done
What is there in the morning?
Chapter 13, “A Short History of the Loop” · generalized from a practitioner’s post
Read the shell line slowly with the room. Nothing is remembered between passes, nothing orchestrates, and the only state is what the agent has left behind in the repository when it quits. Collect predictions; most rooms expect a wreck, one file rewritten forty times.
Then ask what leads into the next slide: if anything useful is left in the morning, where is it kept? Slide 19 gives the reported result and the answer; the instructor pack (week 6) lists what to listen for.
“Deterministically bad in an undeterministic world”
Three lessons from a line of shell
State lives on disk Spec, plan file, instructions file, the commit history: the model forgets, the files do not
Windows stay fresh One task per pass; no pass lives long enough to rot
Verification is a gate Commit only when the compiler, types, tests and linter say yes
Failure catalog: building a feature twice after wrongly concluding it was missing · stubs that pass the checks · paying to re-read the spec every pass
Chapter 13 · the technique’s nickname and slogan are its author’s; the phase loops that followed made the same three lessons explicit
On suitable tasks, people reported waking up to a working program and a long, tidy trail of commits. The technique picked up a cartoon nickname and the slogan in the slide title, which deserves a minute: every pass is dependably mediocre, yet the prompt stays fixed while the repository underneath improves. Progress accumulates in the artifact, and the artifact, unlike a conversation, only has to be gained once.
Walk the first card: where memory lives. A fixed spec that defines done; a changing plan file the agent reads, chooses from and updates each pass; an instructions file for building and testing; the commit history as a diary. Second card: one task per pass. Third card, back-pressure: hook up everything that returns a hard pass or fail, and commit only when it’s all green. For dynamically typed languages the post recommends adding a type checker, or else expecting “a bonfire of outcomes.”
Then the failure line at the bottom. Code search isn’t deterministic, so the agent decides a feature is missing and builds it a second time. The model games its reward with convincing stubs unless the gate is strong enough to reject them. And re-reading the spec every pass is deliberate waste: you’re paying for freshness, which only makes sense where results can be checked by machine. Its author aimed it at new projects and excluded existing codebases. The phase loops that came after (discuss, plan, execute, verify, ship) spelled out what this did by instinct.
Write the stopping condition for “make the app better.” Then look at what you wrote
The goal function
A persistent goal , held outside the model, on disk
A stopping condition a machine can evaluate, after every pass
An oracle outside the work; separate the checker from the maker
A hard iteration cap beneath it, and a budget
“A loop is exactly as trustworthy as its oracle .”
Is “done” machine-verifiable? Loop. If not: a person, or a calibrated judge, and a weaker guarantee
Chapter 13, “The Goal Function”
Do the title exercise live: one sentence giving the stopping condition for “make the app better.” Answers fall into two kinds. Either they appeal to judgment (“until it feels solid”), which the loop lacks, or they quietly swap in a sharper goal (“until the ten open bugs are closed”). The chapter’s rule comes from the second kind: you can loop toward a goal only if a machine can check that it has been met.
Walk the first two bullets: the outer loop needs two things the inner loop doesn’t provide. A goal kept outside the model, on disk, because the agent forgets between runs and the goal must stay put. And a check after every pass: met, stop; not yet, go again. Week 2 already gave the reason: “the model’s ‘done’ is testimony; a green test is evidence.” Taking testimony unattended means repeating the same mistake all night.
Third bullet: oracle is a testing term for a source of truth outside whatever is being judged. A test suite is a strong one; a compiler is crude but can’t be bribed; a checklist counts only if its items can be checked; and the model that produced the output is a poor judge of its own output. Then the cap: if done can never come true, the loop runs until something outside stops it, and without a limit that something is your credit card. Every goal gets a budget. Read the line about the oracle on the slide.
Strip any outer loop and the same five verbs are underneath
Find · assign · check · record · decide
Find : a trigger, then candidate work
Assign : a fresh window, a brief for a stranger
Check : the mechanical gate, then a fresh read-only verifier
Record : failures included
Decide : halt, go again, or escalate
Figure from Chapter 13 · “Build the loop. Stay the engineer.”
Go down the five verbs on the figure. Find needs a trigger, a schedule or an event, and no intelligence: a timer plus a script listing unassigned issues is a full implementation. Assign is where the inner loop sits: a fresh window and a brief a stranger could follow, since an agent launched by a loop is just a worker whose orchestrator is a script. Add separate workspaces when tasks run in parallel, and standing knowledge, best enforced as lint rules whose error message tells you the fix.
Check: the mechanical oracle first because it is cheapest; then, for what no unit test covers, a fresh read-only verifier agent that shares none of the writer’s context and has to produce proof. The team that described it got there after watching agents grade work they had just written. Record is the backbone: done, in progress, attempts that failed, consulted as each pass begins. A loop that only logs its wins is keeping a diary. Decide asks the goal function: done stops, blocked goes to a human, anything else runs again. Connectors are what turn a decision into a pull request.
The chapter’s suggested first loop: a morning schedule; triage that reads overnight failures into the state file; per finding, a fresh worktree and a brief; the gate and a reviewer; a pull request with evidence; and an inbox for whatever it couldn’t handle. You designed it once, prompted none of its steps, and read its report in the morning. When several loops share one store of findings they build on each other, and the chapter immediately warns that a system learning while you sleep can also learn the wrong thing while you sleep. Lab 5 implements these five verbs.
A loop that works unattended also makes mistakes unattended, at scale, on your bill
Two debts, five brakes
Verification debt A green gate is a fact about the checks you thought to write
Cognitive debt Verified work that has outrun your understanding
Budgets : iterations, money, time; per pass and per loop
Stuck detection : the same check failing pass after pass
Least privilege , sandboxed; audit the trifecta per loop
Human gates at the blast doors
A kill switch , tested before the first unattended run
Chapter 13, “Keeping the Loop Safe” · “A kill switch discovered broken during the fire is a design document for the next system.”
Set the morning scene: forty new commits on a branch, three evidence-backed pull requests, and a state file listing two failures. What do you owe all of it before merging? First debt, verification: a loop’s done is a claim, and a green gate covers only the checks somebody thought to write. When the diff landed overnight, the checkmark is happy to stand in for reading you haven’t done. Budget reading time as a real cost.
Second debt, slower: work you did verify can still get ahead of your understanding. The chapter quotes a conference talk: “it’s easy for the loop to run faster than the speed of human understanding.” Its remedy is a short quiz on each change, used to set the pace. The field calls this gap cognitive debt. And the habit that makes both debts certain is accepting whatever the loop produced simply because it produced it. Output volume isn’t progress.
Now the five brakes, all of them code. Budgets per pass and separately per loop, since cheap failure repeated nightly is still failure every night. Stuck detection: halt and notify instead of spending the budget proving the wall is there. Least privilege, because a loop is a standing permission exercised by a nondeterministic process while everyone sleeps; week 9 audits the lethal trifecta. Human gates at the blast doors: merges to protected branches, production, outside communication. And a kill switch, one obvious, quick, tested way to stop every loop and agent at once. Read every line of the first full run, and treat it as a measurement, not a launch.
Part 4 · Chapter 14 (full book)
Choosing your approach: when not to build an agent
Chapter 13 ended by presenting a bill and leaving one question: whether to pay it at all. Chapter 14 approaches this like buying industrial equipment, where the sticker price is the smallest figure on the quote and the cost of ownership is what decides.
Name the analogy’s weak spot, as the chapter does: equipment buyers get firm prices and you won’t, because prices in this field change too fast to print. What stays stable is the structure of the quote: what lines it has, and which decisions inflate each of them.
Commit to four answers before the next slide
The cheapest thing that would do the job well
Flag every wire transfer above fifty thousand dollars for manual review
Sort incoming support tickets into five categories and route them
Find out why the nightly build started failing, and fix it
Automate our customer support
Chapter 14, opening · the chapter’s four requests
Give the room a minute on paper. One answer per request: plain code, one model call, a workflow, an agent, or something else. Ask people to notice which answers came almost before they finished reading, and which request resisted being sorted at all.
Take a show of hands on the fourth. Slides 25 and 26 price the rungs; the chapter’s answer for each request is in the instructor pack (week 6).
A rung’s true quote has four lines; the fourth is the one engineers leave off
The ladder, priced
Line What grows up the ladder
Build Spec → eval set → decomposition and gates → a harness
Run Free → per call → costs add → costs multiply
Wrong Same bug every time → words → contained → deeds
Know A unit test → sampling forever → per-step tests → a second construction
Figure from Chapter 14
Chapter 14, “The Ladder Revisited” · “The sticker price of an agent is a prompt.”
Walk the four rows: the cost to build, to run, of being wrong, and of knowing whether it worked. Plain code: certainty, paid for in specification; when wrong, it is wrong identically every time, which is a gift; and “An if statement has never hallucinated.” One model call looks like an afternoon’s work, but from here on correctness is a rate, so the eval set goes on the invoice from day one; when it fails, it fails in words, one bad answer with nothing built on it. A workflow costs the decomposition plus a gate per seam to build; running costs add over a known number of calls; an error stays in its box until a seam catches it.
The agent column: the loop is maybe a page long, and everything around that page is what you are buying. Running costs multiply, since each turn resends a growing transcript, and subagents multiply them again. When it’s wrong, it fails in deeds, compounding along the loop and limited only by the blast radius you enforce. A vendor’s cautionary example: a demo that went flawlessly, then a retry loop that quietly made 847 duplicate customer records in production. Knowing it worked is the priciest knowledge on the ladder; at the top, proof means building a second thing, often bigger than the first.
Two takeaways. The rungs are destinations: if you can draw a problem’s steps, a lower rung is the final answer, not a stage. And quotes are per task, so multiply every row by expected volume. Close with the quote at the foot of the slide.
The litmus: can you draw the flowchart before the request arrives?
Signs, both ways, and a trap
Down the ladder
The steps can be enumerated
Correctness must be guaranteed or audited
A person waiting, or high volume at low margin
Lookup, classification, transformation
High stakes, no cheap verification
Up the ladder
Open-ended; judgment at branches you cannot list
And a machine-checkable success criterion, feedback at each step, a place for a person
Agent-washing : the label sells. Ask: does the model decide the next step, or does code?
Chapter 14, “Signs You Need One, Signs You Don’t” · the ladder is climbed in both directions
Down column first: five signs, and any one nearly settles it. If the steps can be listed, writing the flowchart in code is cheaper than paying for judgment to rediscover it on every request. If reproducibility is legally required, the rung picks itself. Someone watching a spinner, or an endpoint with huge volume and thin margins, rules out every multi-call design on price. Lookup, classification and transformation are one-call shapes however clever the judgment inside. And high stakes without cheap verification calls for the co-pilot setup: the agent proposes, a person approves.
Up column: an open-ended goal whose flowchart only exists after the fact, judgment at branches you can’t list, and three conditions students can now check concretely: a machine-checkable success criterion (Part 3’s goal function), a feedback signal at each step, and a sensible point for a person to look (gates and the dial). Coding became agents’ first stronghold because the domain hands you all three. Between the extremes is what ships most often: mostly workflow, with one or two agentic steps embedded.
The ladder runs both ways, as the slide’s footer says. Going up: build the simple version, measure, climb only when some class of inputs demonstrably beats it. Going down: use an agent while the flowchart is unknown, let its traces sketch the flowchart, and once the paths settle, freeze them into workflow steps. Then the trap at the bottom, agent-washing, which cuts both ways: a workflow sold as an agent overcharges in ceremony, and an agent shipped as an “automation” undercharges, because nobody paid for the budgets, gates and eval set. Ask the room the question on the slide about their own systems: who decides the next step, the model or the code?
In class · teams of three · 22 minutes · two browser tools
A gate policy, then a brief
A · the gate policy (10 min). Open the consequence tier classifier (seven helpdesk tools loaded, questions blank). Answer each tool from its description on the lecture page. Try the tightest dial: which row changes? Back to standing permissions; copy as Markdown
B · the brief (8 min). Open the multi-agent failure explorer with the one-line brief loaded; record its reading. Write the brief for the worker who lists product changes; check it; copy as Markdown
Debrief, 4 minutes: one warning and its fix; one brief read aloud as a contractor would read it
Tools after Chapters 11 and 12 · the question order and the brief’s word patterns are the tools’ own · scenarios invented for the exercise
Part A. The seven tools and today’s practice are described on the lecture page; teams answer each tool’s questions from those descriptions alone, not from what they imagine a helpdesk does. The tool fails closed: an action with unanswered questions shows as the top tier until it is answered, which is the tool’s own default. Ask teams to read every warning the tool raises and write one change per warning. The tightest-dial step takes thirty seconds; make sure they switch back before copying, because the export records the dial.
Part B. The orchestrator received “Find out why signups dropped last week” and split it three ways: the analytics of the signup funnel, the product changes shipped that week, and the marketing campaigns and traffic sources. Teams write the brief for the second worker. Walk the room and ask the contractor question: could a stranger who cannot ask anything do this from the text alone? The brief check is a word-pattern heuristic and says so; four of four is the checklist, not the test. Where it misses a field the brief plainly has, a team may overrule it and quote the sentence that carries the field.
The expected answers and the grading notes are in the instructor pack (week 6), not here, because students can open this deck.
Before next week
Lab 5, the proposal, and reading
Lab 5 · a gate and a loop
A gate in code for the two top tiers, with the handoff
An outer loop over a checklist on disk: five verbs
A machine-checkable stop, a cap , a tested kill switch
Project proposal (teams)
The problem, its rung with the four-line quote, the verification signal
This week’s reading: Ch. 11 · Ch. 12 · Ch. 13 · Ch. 14 (full book) · glossary: App. B (free) · no paid API needed
Lab 5 still uses a scripted model client. Part one: a gate in the code path between choosing a tool and invoking it, covering the externally visible and irreversible tools. Externally visible actions wait in a review queue and run once on approval; irreversible ones block until a person decides. The person receives the handoff: the action, the reason, what it affects and whether it is reversible, before and after, and a reject-with-edits option. Part two: a small outer loop (find, assign, check, record, decide) over a checklist on disk, with a machine-evaluated stop, a cap on passes and a kill switch.
Stress three criteria. The gate is tested against a model that never asks for permission: a prompt that says “ask before deleting” fails that test, and the lab wants them to demonstrate it. Parallel calls are gated individually. And “complete” is decided by rerunning the checks from disk, never by the agent’s final message.
The team project proposal is due with the lab: the problem, its rung on the ladder with the four-line quote, and the signal that will show it worked. Week 7 is observability: every model call and tool call as a span you can read.
Recap
Five things to keep
Split only work whose branches can run without seeing each other ; writes stay single-threaded
A worker is exactly as good as its brief : objective, format, sources, boundaries
Gate by consequence , in code ; send a decision, not a transcript
An outer loop is as trustworthy as its oracle ; cap it, and test the kill switch
Price the rung with four lines ; the fourth, knowing, is the one left off
Quick check before they leave: name one tool in your project that should never run without a signature, and the line of code where that signature would be checked.
Part IV is done: the book’s half that decides what gets built. Next week opens Part V, which makes whatever you built visible: traces, spans, and replaying a failure.
Engineering AI Agents · Week 6
Build the loop. Stay the engineer.
Slides from the teaching kit of AI Agents, Engineered by Enrique Gutiérrez, CC BY 4.0 · aiagentsengineered.com/teach/
Reuse, adapt and translate with attribution · creativecommons.org/licenses/by/4.0/
The closing line is the refrain of the essay that named loop engineering, which Chapter 13 quotes and ends on.
These slides are CC BY 4.0: instructors may reuse, adapt and translate them, keeping the attribution line on this slide.