Slides · Harness engineering
Harness engineering: interview drills
1 / 26
Harness engineering: interview drills
Turning the module into spoken answers: ninety-second explanations, whiteboard arithmetic, a forty-minute design structure and failure diagnosis by layer.
By the end you can explain the core ideas briefly, work the standard derivations, structure a design answer in eight parts and diagnose a failure by layer.
Concept
How to use these drills
- Answer aloud first, under a clock, then compare with the key. Reading a drill teaches little.
- Provenance: the lesson’s questions are labelled Common industry pattern or Generated practice. None is verified as asked by a named company, and this deck makes no such claim.
- The lesson says interviewers for agent-platform and AI-infrastructure roles often probe definitions, derivations, design structure and diagnosis. That is the lesson’s own observation, not a measured fact.
- A sample answer is one good answer, not the only one.
Process
A ninety-second recipe
- Claim in one sentence: what it is.
- Why it exists: the failure it prevents.
- Example: one concrete case.
- Trade-off: what it costs or when it does not apply.
- Link to the next idea if time remains.
First check which meaning the interviewer intends. “Harness” can mean the agent’s scaffolding, an evaluation harness that runs a benchmark, a test harness, or an environment wrapper for reinforcement learning. Say which one you will answer.
Compare
The five ideas in one table
| Idea | One line | Source says |
|---|---|---|
| Harness | Everything around the model that is not the model | Osmani: all the code, settings and runtime logic outside the model itself |
| Guides and sensors | Steer before the action, observe after it | Böckeler: guides are feedforward, sensors are feedback; computational ones are deterministic, inferential ones use judgment |
| State across sessions | Progress lives in files and version control, not in memory | Young: a progress file, git commits, and a feature list initially marked failing |
| Subagents | Isolate context and return short results | Anthropic: clean windows, summaries often 1,000 to 2,000 tokens |
| Proving a change | One change, same held-out tasks, several trials, state-based grading | Anthropic: grade what the agent produced; run multiple trials |
Each one pairs with a trade-off to say aloud: harness rules go stale, sensors cost time, files need a schema, subagents cost tokens, experiments cost runs.
Sources[1] Agent Harness Engineering[2] Harness engineering for coding agent users[3] Effective harnesses for long-running agents[4] Effective context engineering for AI agents[5] Demystifying evals for AI agents
Worked example
Sample ninety-second answer: guides and sensors
“A guide steers the agent before it acts: conventions, instructions, code mods. A sensor observes after the action and lets the agent correct itself: tests, linters, an AI review. You need both, because feedback alone gives an agent that repeats mistakes and feedforward alone gives rules nobody checks. I prefer computational sensors first, since they are deterministic and fast, and add inferential ones, such as a model judge, for what code cannot see, accepting that they are slower and less deterministic. For example, a type checker runs after every edit and states the rule and the fix. The trade-off is that sensors that never fire are ambiguous: quality or blindness? I would seed a known fault to find out.”
Note the order: claim, why, example, trade-off. The summary of guides, sensors and the open question is from Böckeler (2 April 2026).
Worked example
Sample ninety-second answer: surviving many sessions
“A long task outlives one context window, so the agent cannot rely on memory. Anthropic’s long-running harness has an initializer create a feature list with every feature marked failing, a progress file and an init script, and has each session commit to git with descriptive messages. A new session reads those files and the git log, then continues. They chose a JSON feature list because, they report, the model is less likely to overwrite JSON than Markdown. The trade-off is that someone has to design the files and the startup routine, and the agent still needs end-to-end checks: it tended to mark features complete without proper end-to-end testing.”
Source: Justin Young, Anthropic, 26 November 2025. Rehearse your own version with a different example.
Math
The standard formulas
whole-task success=pnpass@k=1−(1−p)kpassk=pkcost per resolved task=success ratecost per attemptsteps before compaction=⌊sc(W−R)−F⌋| Symbol | Meaning |
|---|---|
| p | Per-step (or per-trial) success probability, assumed independent |
| n | Number of steps in the task |
| k | Number of trials |
| W | Context window size in tokens |
| R | Tokens reserved for output |
| F | Fixed tokens (system prompt, tools) |
| c | Compaction threshold as a fraction of the window left after the reserve |
| s | Tokens added per step |
Independence is a simplification: real errors are often correlated, so say “roughly”. Anthropic defines pass@k as at least one success in k attempts and passk as all k succeeding.
Worked example
Worked: long tasks and repeated trials
A 30-step task, each step 0.97. 0.9730≈0.401. A step success of 97 percent sounds safe, yet the whole task succeeds about 40 percent of the time.
One task, p=0.6 per trial, k=4.
| Aspect | Arithmetic | Result |
|---|---|---|
| pass@4 | 1−0.44=1−0.0256 | 0.9744 |
| pass4 | 0.64 | 0.1296 |
At least one success in four tries is almost certain, but all four succeeding is rare. Which you quote depends on whether a user can retry (pass@k) or relies on it every time (passk).
Worked example
Worked: cost and steps before compaction
Cost per resolved task (illustrative): 0.75 dollars per attempt at 25 percent success: 0.250.75=3.00 dollars. 1.50 dollars at 60 percent: 0.601.50=2.50 dollars. The pricier attempt is cheaper per result.
Steps before compaction (illustrative): W=100,000, R=6,000, F=9,000, c=0.60, s=1,800.
| Step | Arithmetic | Result |
|---|---|---|
| Window after the reserve | 100,000−6,000 | 94,000 |
| Compaction threshold | 0.60×94,000 | 56,400 |
| Room after fixed tokens | 56,400−9,000 | 47,400 |
| Steps | 1,80047,400=26.3 | 26 whole steps |
Round down: a partial step does not fit. If each step added 9,000 tokens, the same room would hold only 5 steps (9,00047,400=5.3), which is why capping tool output matters.
Worked example
Worked: subagent token overhead
Illustrative: N=4 subagents each read W=30,000 tokens, receive a 500-token brief and return S=1,200 tokens.
| Aspect | Parent does it | Four subagents |
|---|---|---|
| Parent context growth | 4×30,000=120,000 | 4×(500+1,200)=6,800 |
| Total work tokens | 120,000 | 120,000+4×500+4×1,200=126,800 |
| Overhead | none | 6,800, about 5.7% |
You trade a little extra total work for a parent window that grows by 6,800 instead of 120,000, plus parallelism. Anthropic’s measured whole-system multipliers were far higher: about 4 times chat for agents and 15 times for multi-agent systems, so treat this simple count as a floor, not the real bill.
Sources[4] Effective context engineering for AI agents[6] How we built our multi-agent research system
Check yourself
Check: a task you need three times in a row
A task has 12 steps and each succeeds with probability 0.97 (independent). A user needs it to work three times in a row. What is the chance, and what does it tell you about step reliability?
Answer
One run succeeds with 0.9712≈0.694. Three in a row is 0.6943≈0.334, which equals 0.9736. Even strong step reliability gives a one-in-three chance of a perfect streak. The remedy is to shorten the chain, verify steps, or improve step reliability, and to state that independence is an assumption.
Diagram
The order of a strong answer
Process
The eight parts of a forty-minute design
The six-step order on the previous slide is the spoken spine; the eight parts spread it out. Step 1 (what you optimise) is part 1. Step 2 (context and tools) is parts 2 and 3. Step 3 (loop and state) is part 4, and orchestration (part 7) fits beside it. Step 4 (enforcement and checks) is parts 5 and 6. Step 5 (people) shows up as approvals and review inside parts 5, 6 and 8. Step 6 (how you will know) is part 8.
- Clarify: what success means, risk, languages, CI time, who reviews, budget per task.
- Context: a short instruction file that maps to docs, search tools, skills loaded on demand.
- Tools and environment: a sandbox per task, scoped tools, no secrets given to the agent, outbound network denied by default (this matters most for pushes and exfiltration).
- Loop and state: reproduce first, plan and progress files, limits, repeated-call detection.
- Enforcement: hooks, structural tests with fix-it messages, protected paths, approval to push.
- Verification: independent of the author, targeted then full tests, then a person.
- Orchestration: one agent by default, subagents for isolation, models routed by step.
- Evaluation and operations: held-out replay set, passk, cost per merged fix, traces, rollout, kill switch.
Diagram
Drill 1 at a glance: a coding agent for a monorepo
The prompt: about 300 issues a week, mixed difficulty, strict review, no production access.
Concept
What a strong answer shows
- It reproduces the problem before fixing it.
- Someone or something other than the author checks the result.
- It puts figures on the design: cost per task, how often reviewers should accept, step and spend ceilings.
- Each task runs in its own space, and every loop has a clear stopping rule.
- It names the kinds of failure expected and raises the improvement loop unprompted.
- It is candid about what stays with people, such as judgment calls and security-sensitive code.
- The usual weakness: a list of components with no reason or cost attached to each.
Worked example
Worked: re-costing when volume jumps tenfold
Illustrative numbers for the monorepo agent. The team spends 4.00 dollars per issue on 300 issues a week.
| Aspect | Arithmetic | Result |
|---|---|---|
| Current weekly spend | 300×4.00 | 1,200 dollars |
| Volume now 3,000 issues, same per-issue budget | 3,000×4.00 | 12,000 dollars |
| Per-issue budget to hold 1,200 dollars | 3,0001,200 | 0.40 dollars |
| Issues that can get a full attempt at 4.00 | 4.001,200 | 300 (10% of 3,000) |
Say the choice aloud. Triage keeps the full budget where it pays: give a full attempt only to issues likely to succeed (reproducible, small, well-tested areas) and route the rest to people. The alternative, spreading 0.40 dollars over every issue, would leave each attempt far too thin for hard issues. Name the risk either way: measure acceptance on the triaged set before promising the numbers.
Diagram
Drill 2: a support agent that issues refunds
Sources[7] The lethal trifecta for AI agents: private data, untrusted content, and external communication[8] Idempotent requests
Concept
Drill 2 key points
- Split tools into read, propose and commit; gate the commit with a policy (amount limits, customer history, fraud signals).
- An idempotency key lets the server recognise a retried request; Stripe’s API documents this for safe retries.
- Willison’s lethal trifecta: private data, untrusted content and external communication in one agent make data theft easy. Do not let the agent that reads ticket text also hold private data and an outbound channel.
- Redact personal data, keep an audit log, evaluate on historical tickets with state-based graders, use proxy measures while outcomes arrive days later, keep a kill switch, and roll out by customer segment.
Sources[7] The lethal trifecta for AI agents: private data, untrusted content, and external communication[8] Idempotent requests
Diagram
Diagnose by layer first
Source[9] Harness Engineering: How to Build Reliable AI Agents by Engineering the System, Not the Model
Worked example
Worked: four new scenarios
| Scenario | Layer | Structural fix |
|---|---|---|
| The agent deletes a branch it did not create | Constraint | Scope the git tool to the task’s own branches; approval for deletes |
| After three hours it ignores the project’s naming rule | Context | Re-load the rule from the instruction file after compaction; keep state in files |
| It reports “all tests pass” but the test runner never ran | Verification | A stop hook that requires a passing run of the targeted tests |
| It retries the same failing command 30 times | Planning | Repeated-call detection, a step limit and an escalate-after-N-failures rule |
Each fix changes the harness so the failure cannot recur quietly, and each gets a regression check: a task that reproduces the symptom.
Check yourself
Check: an API key in a commit
A coding agent commits a file that contains an API key it read from the environment. Which layer broke, and what is the structural fix?
Answer
Constraint: the agent acted outside what it should be allowed to do. Fixes: do not give the agent long-lived secrets in its environment, add a pre-commit hook that scans for secrets and blocks the commit with a clear message. Denying outbound network by default does not stop a local commit; it stops the push or upload that would send the secret out. Add a regression task that tempts the agent to commit a secret and expect the hook to stop it.
Check yourself
Check: a reviewer that approves everything
A second agent reviews every change, but it always approves. The team runs it with the same prompt and the same context as the author. Which layer is weak, and what would you change?
Answer
Verification: the check is not independent of the author. Change the reviewer’s instructions and context, and prefer deterministic checks (tests, type checks, structural tests) wherever one exists. Define what done means before the work starts. Anthropic also advises reading transcripts to see whether a grader accepts or rejects valid work, so sample the reviewer’s decisions against a human judgment.
Process
How to rehearse
- Time yourself on one explanation and one derivation. If either takes more than twice its budget, reread the lesson it comes from.
- Run a mock with a friend who may only ask, not teach. A 35-minute version: three explanations, one derivation, one scenario.
- For a 45-minute version, do one design drill and have the interviewer change a constraint twice.
- Afterwards, note the two places you lost the thread and repeat those on a nearby variant a few days later.
- Lead with what you are optimising and the order you will cover things.
Summary
Recap
- Explain each core idea in ninety seconds with one example and one trade-off, after checking which meaning of “harness” is meant.
- Know the derivations: pn, pass@k, passk, cost per resolved task and steps before compaction.
- Design in eight parts and re-cost aloud when a constraint changes.
- Diagnose by layer, then fix structurally and add a regression check.
- Every component should trace to a behaviour or a failure.
References
References & Sources (1 of 2)
Agent Harness Engineering (opens in a new tab)
Addy Osmani2026Article
https://www.oreilly.com/radar/agent-harness-engineering/
Used for Defines a harness as everything that is not the model, and lists its component families (15 May 2026).
Harness engineering for coding agent users (opens in a new tab)
Birgitta Böckeler2026Article
https://martinfowler.com/articles/harness-engineering.html
Used for Guides as feedforward and sensors as feedback, computational versus inferential controls, and the open question about sensors that never fire (2 April 2026).
Effective harnesses for long-running agents (opens in a new tab)
Justin Young2025Article
https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents
Used for Feature list marked failing, progress file, git commits, JSON over Markdown, and the end-to-end testing observation (26 November 2025).
Effective context engineering for AI agents (opens in a new tab)
Prithvi Rajasekaran, Ethan Dixon, Carly Ryan, Jeremy Hadfield2025Article
https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents
Used for Subagents with clean windows returning summaries, often 1,000 to 2,000 tokens (29 September 2025).
Demystifying evals for AI agents (opens in a new tab)
Mikaela Grace, Jeremy Hadfield, Rodrigo Olivares, Jiri De Jonghe2026Article
https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents
Used for Definitions of pass@k and pass^k, grading outcomes, multiple trials and reading grader transcripts (9 January 2026).
References
References & Sources (2 of 2)
How we built our multi-agent research system (opens in a new tab)
Jeremy Hadfield, Barry Zhang, Kenneth Lien, Florian Scholz, et al.2025Article
https://www.anthropic.com/engineering/multi-agent-research-system
Used for Measured token multipliers of about 4x for agents and 15x for multi-agent systems (13 June 2025).
Simon Willison2025Article
https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/
Used for Private data, untrusted content and external communication together let an attacker steal data through an agent.
Idempotent requests (opens in a new tab)
Stripe2026Documentation
https://docs.stripe.com/api/idempotent_requests
Used for Idempotency keys make a retried request safe against performing the same operation twice.
deepset2026Article
https://www.deepset.ai/blog/harness-engineering
Used for Classifying failures by the layer that broke, which depends on structured tracing (21 May 2026).
Keys: ← → move, Home End first and last, F full screen.