Eight fully worked answers to the interview question “design an agent that does X.” Each file is one complete design round from end to end: the architecture, the arithmetic that prices it, the ways it breaks, and the interviewer’s objections with each one answered. Each file covers enough to defend its design in a forty-five-minute interview, and the eight share a template you can apply to a ninth problem that nobody wrote up.
These are the applied end of the agentic systems track. Each file restates the idea it depends on before using it and links to the chapter that derives it, so you can read them without any other chapter first and follow the links back when you want the mechanism underneath a number.
The vocabulary every file below uses
A handful of terms recur in all eight studies and are defined once here.
An agent is a program that puts a large language model (LLM) in a loop: the model proposes an action, your code runs it, the result is appended to the conversation, and the loop repeats until the model says the task is finished. A tool is one of the actions you permit — a function with a name, a description and typed arguments, which the model invokes by emitting a structured request rather than by running anything itself. The harness is all the code around the model: the loop, the tool implementations, the budget checks. A turn is one pass around the loop, and one turn costs one call to the model’s application programming interface (API), which is why “how many API calls does this make?” is a cost question.
Everything the model can see at once is its context window, measured in tokens — the sub-word chunks text is split into, roughly three-quarters of a word each. Prices are quoted per MTok, meaning one million tokens, and output tokens cost several times what input tokens cost. Prompt caching appears in every cost table: you mark a stable prefix of the conversation, the provider keeps its computed state, and re-sending that prefix on the next turn bills at about a tenth of the input price in exchange for a one-time write premium of 1.25× (Prompt caching derived). Finally, evals are the automated test suite for an agent — fixed inputs, a scoring function, and a threshold you can gate a release on.
What goes in and what comes out
Two input/output pairs matter here and are easy to confuse: the exercise has one, and the agent you design inside it has another.
| Input | Output | |
|---|---|---|
| The exercise (this folder) | One sentence from an interviewer, e.g. “Build an agent that can use a desktop app that has no API.” | A diagram, a tool list, a memory plan, a table of API calls priced in dollars, failure modes with mitigations, an eval plan, and an answer to every objection |
| The agent (inside each file) | Stated in the first ten lines of every study, before any mechanism appears | Stated in the same place — see the middle column of the table below |
The interviewer’s sentence is the only thing you are given. Everything in the right-hand column is what you are expected to produce, roughly in that order, inside forty-five minutes. The method for running that clock is chapter 10; these eight files are that method already executed on eight problems.
The eight designs
Each row names what the running system consumes and emits, and the one idea the file exists to teach. Terms of art in the last column are defined where they first appear.
| # | Agent | What goes in → what comes out | The thing it teaches |
|---|---|---|---|
| 01 | Computer-use agent | A goal in plain English plus a live screen → mouse clicks and keystrokes | The perceive–act loop, and why an observation that is an image cannot be shrunk the way text can, so every turn pays for a fresh screenshot |
| 02 | Web form filler | 4,000 supplier records plus a portal with no bulk upload → each record submitted exactly once | Idempotency — designing so that a repeated attempt is harmless — because the hard part is never submitting twice, not filling the fields |
| 03 | Coding agent (a small Claude Code / Cursor) | A repository on disk plus a task in English → edited files, passing tests, a summary | Choosing a tool set, five tiers of memory, and the most complete cost accounting in the folder |
| 04 | Multi-agent research | An open-ended question → a written report with verified citations | Why context isolation — giving each worker its own clean window — rather than speed is the reason to fan out into subagents |
| 05 | Autonomous agent | A goal and a budget → progress on the goal plus an honest report of what it did | How a run with nobody watching stops itself: a machine-checkable success test, drift detection, and two separate budget ceilings |
| 06 | Support agent with escalation | A customer message plus their account context → a resolution, or a clean handoff to a human | Routing beats tuning: a cheap classifier in front decides which lane you pay for, and grounding checks run before the reply ships |
| 07 | Natural language → SQL | A plain-English question plus a 400-table warehouse → an answer, plus the Structured Query Language (SQL) that produced it | The query that runs fine and returns a wrong but plausible number, and read-only credentials as the guardrail that actually holds |
| 08 | Document processing | 5,000 invoice PDFs a month → ledger rows correct enough to pay against | When a fixed pipeline beats an agent — 27× cheaper here — and why a pipeline’s errors are the detectable kind |
Three terms in that table carry the designs and are worth defining. Grounding means checking every claim in a drafted reply against a document actually retrieved, so the model cannot state a policy that does not exist. Drift detection means scoring the agent’s current task queue against the goal it was given, to catch a run that is still busy but no longer working on the right thing. A subagent is a second model instance with its own context window, given a written brief and returning a summary — the mechanism, and the one good reason for it, are derived in chapter 06.
In what order to read them
Nothing here depends on anything else here, so what follows is a recommendation rather than a prerequisite chain. Read 01 through 08 straight through if you are working the whole track. If you have limited time before a specific interview, the order below front-loads the designs that get asked most and the judgments that transfer furthest.
| Read | Why it goes here |
|---|---|
| 03 — coding agent | The design most AI startups actually ask about, and the one whose cost table is the most complete. It sets the standard for what “how many API calls?” should sound like |
| 06 — support agent | The most common prompt at startups, and it introduces routing and model tiering, which then reappear in 04, 07 and 08 |
| 08 — document processing | The study whose correct answer is “this should not be an agent.” Read it early; it sharpens the judgment the other seven quietly assume |
| 04 — multi-agent research | The hardest one to bluff. Fan-out is easy to propose and hard to justify, and this file is the justification |
| 05 — autonomous agent | Pairs with 04: once you can defend fan-out, defend running for eight hours with nobody watching |
| 07 — SQL agent | The cleanest example of the silent-wrong-answer failure class, which generalizes far past SQL |
| 01 — computer use | Narrower applicability, but the clearest arithmetic on prompt caching and image cost anywhere in the repo |
| 02 — form filler | Last because it is the most specific, and best because exactly-once delivery is a distributed-systems answer wearing an agent costume |
Each file’s interviewer pushback section is the last section of all eight, and it is the only part written as dialogue.
The shape they share
All eight files follow one template, so you can navigate any of them without re-reading it and can compare two designs section by section.
Eight sections appear in every file, always in this order — only the evals and alternatives pair ever swaps:
flowchart LR A[Problem] --> B[Architecture] B --> C[Design-specific core] C --> D[Memory] D --> E[How many API calls] E --> F[Failure modes] F --> G[Evals and alternatives] G --> H[Interviewer pushback]
The design-specific core is where each design does its own thing, and it is the bulk of the file. What varies is worth knowing before you use these to compare designs:
| Section | Where it actually is |
|---|---|
| Tools | Its own section in 6 of 8. 05 never enumerates a tool set — its guardrail is stated as an allowlist with no publish verb in it, so what matters is the absent tools. 08 lists tools only under The agent fallback, because the main design is a single constrained generation with no tools at all, which is its entire argument |
| The loop, turn by turn | Only 01, 03 and 07 walk a numbered turn sequence. In 02, 04, 05, 06 and 08 the control flow lives in the architecture diagram and the code instead of in a walkthrough |
| Evals vs. alternatives order | Evals come first in 01, 02, 03, 07 and 08; alternatives come first in 04, 05 and 06 |
| Memory | Present in all eight, though 03 expands it into five tiers, and 01 and 02 fold it into a caching argument |
The API-calls section is not the ending. It lands between two-fifths and four-fifths of the way into each file — 45% through 03, 74% through 06, around 75% typically — because everything after it exists as a consequence of it. Failure modes, evals and alternatives are all things an interviewer starts probing once that table is on the board, not things they move on from.
What the money section contains
Every file includes one thing a typical design writeup omits, and it is what you are being asked to reproduce.
The section is a table of turns, input tokens, output tokens, cache hits and dollars, with the arithmetic shown rather than asserted, followed by a ranked list of the levers that would cut it. The levers land in a consistent order — prompt caching first, then how many turns the loop is allowed, then how much each observation costs, and only then which model you picked (Optimization order). Here is what each study’s table comes out to, which is also a fast index to how the eight problems differ in scale:
| Study | The unit it prices | Result | The comparison that gives it meaning |
|---|---|---|---|
| 01 | one 7-step desktop task | $0.107 | 2.55× better than the $0.273 uncached, full-resolution baseline; a 30-step task runs $0.72 |
| 02 | all 4,000 records | $1.45 | 1,275× better than the ~$1,850 obvious design of one agent loop per record |
| 03 | one small bugfix | $0.105 | $0.44 for a medium feature, $2.48 for a large refactor; caching alone is worth 4.5× |
| 04 | one research question | $2.68 | 88% of it is the 32 worker calls, so every optimization worth doing targets that one row |
| 05 | an 8-hour overnight run | $22.01 | 83% is the 240 task-execution calls; the drift checks people worry about cost $0.35 in total |
| 06 | one support ticket, blended | $0.034 | $343/day at 10,000 tickets, against $5,595/day for one large-model loop on everything — 16.3× |
| 07 | one question | $0.031 | About $16/month at 500 questions. Warehouse compute does not dominate on average — a filtered query is ~$0.02 against $0.031 of model spend — it dominates in the tail, where one missing WHERE scans 2 TB for $10, or 230× the model call that wrote it |
| 08 | 5,000 invoices/month | ~$80 | Against $2,185/month to run an agent on every document (27×) — and against $3,000/month of human review, which is the number actually worth attacking |
In half these studies the model bill is not the largest number on the page, and saying so is what separates a senior answer from a competent one.
Failure traces, shown rather than described
Every study names what it rejected and why, and most of them print the failing artifact instead of describing it.
Case study 07 is the cleanest example. A one-to-many join between orders and their line items makes each order’s total repeat once per line, so summing that column counts it several times — a fan-out double count. The join is correct, the query runs without error, and revenue reads $2,300 instead of $1,000. Both queries are printed side by side and they differ in a single aggregate expression. The reported number is not 2× or 3× but 2.3×, so no magnitude check catches it and a finance team can run on it for two quarters.
Case study 08 prints an extraction that is schema-valid and arithmetically self-consistent and still wrong by $15. The model computed a line total from quantity times unit price instead of reading the discounted total printed on the page, so the validator checked the model’s arithmetic against itself and learned nothing. That is a harder failure than a malformed record, and it is the reason every numeric field in that schema is nullable — a field that must contain a number is a guarantee the model will invent one. (This study’s own failure modes section is a table rather than a trace.)
The rest carry traces too. Study 01 has a prompt-injection trace, in which text on the screen is read by the model as an instruction, alongside a second failure worth memorizing; 02 and 03 each carry one; 04 has two, an averaging failure and an injection through a fetched page; and 05 traces a goal the agent rewrote at step 17, after which drift detection kept scoring the run as aligned — never above 0.08 — because it was comparing the queue against a goal that had already moved.
Pricing used throughout: claude-opus-5 $5/$25 per MTok input/output, claude-sonnet-5 $3/$15,
claude-haiku-4-5 $1/$5. Cache reads bill at about 10% of the input price and cache writes at
1.25×. The ordered queue that interleaves these eight with the rest of the material is
Study_plan.