Harness engineering: interview drills
- Advanced
- 40 min
- Lesson 7 of 7 in Harness engineering
- Last verified
Select text in the lesson first to keep it with your note. With the keyboard, move focus here and press the button: the note goes with the section you are reading.
In this module
On this page
Before you start
- Completed:Evaluating and operating a harness
You will be able to
- Explain the core harness ideas (harness, guides and sensors, state across sessions, subagents, proving a change) clearly in about 90 seconds each.
- Work the standard derivations: n-step success, pass@k and pass^k, cost per resolved task, and steps before compaction.
- Structure a 40-minute harness design answer in eight parts and name the markers of a strong one.
- Diagnose a described agent failure by layer and propose a structural fix.
A reviewer from management gives you a marker and forty minutes. The brief: design the setup for one agent that works alone and unattended for that long.
Vihaan waits at the board for your first line.
Where do you start?
Concept
This lesson turns the module into practice. Every answer below can be built from the earlier lessons; the point is to say it aloud, under a clock, in a structure an interviewer can follow. Use it in this order: answer a prompt aloud first, then open the key. A drill you read without answering teaches little.
The questions here are Common industry pattern or Generated practice, and none is verified for a named company. Sample answers are one good answer, not the only one.
Why It Matters
Knowing the ideas is not the same as explaining them in ninety seconds or designing a system in forty minutes. In our judgment (not data), interviews for agent-platform and AI-infrastructure roles tend to probe the same few things: whether you can define the harness, derive a number, structure a design and diagnose a failure by layer. Rehearsing each in turn exposes the gaps that reading hides.
Mental Model
The reviewer’s marker and the board are the whole exercise. A strong answer goes in a fixed order, because a fixed order lets you stay calm and lets the listener follow: say what you are optimising, draw the setup on the board (context, tools, loop, enforcement, checks), say where people stand, and say how you will know it works. The order matters more than any single component.
Ninety-second explanations
Rehearse these until each fits in about ninety seconds, with one example and one trade-off. If an interviewer says “harness”, first check which meaning they intend: the agent’s scaffolding, an evaluation harness that runs a benchmark, a test harness, or an environment wrapper for reinforcement learning.
- What is an agent harness, and what is harness engineering? Agent = model + harness; the harness is everything but the model, and the discipline is designing and improving that environment from observed failures. (Lesson 1.)
- Harness versus prompt versus context engineering. Nested: the prompt is one call’s wording, context is what the model sees now, the harness adds persistence, enforcement, orchestration and the improvement loop.
- Guides versus sensors; computational versus inferential. Steer before, observe after; deterministic versus a model’s judgment. Use both; computational first. (Lesson 4.)
- How a long-running agent survives many context windows. Budget the window, compact late, and write state to files: a failing-first feature list, a progress file, version control and a startup routine. (Lesson 3.)
- Why subagents, and what they cost. Context isolation and parallelism, paid for in total tokens. (Lesson 5.)
- How you prove a harness change helped. One change, the same held-out tasks, several trials, a state-based grader, and cost per resolved task. (Lesson 6.)
Whiteboard derivations
Try each before reading the key.
- B1. End-to-end success of an n-step task with per-step success p: for 25 steps at 0.98, and for 40 steps at 0.99.
- B2. and for and .
- B3. Cost per resolved task: 1.20 dollars per attempt at 50 percent success against 1.80 dollars at 80 percent.
- B4. Steps before compaction: window 200,000, 16,000 reserved for output, 12,000 fixed, compaction at 70 percent of what remains after the reserve, 3,000 tokens a step (then 15,000).
- B5. Token overhead of N subagents against doing the work in the parent.
Key.
- B1: 0.98 to the 25th is about 0.603, and 0.99 to the 40th is about 0.669. Say “roughly”, since errors are rarely independent.
- B2: , essentially 1 (0.9999999999). .
- B3: dollars against dollars, so the pricier attempt is cheaper per resolved task.
- B4: 70 percent of 184,000 is about 128,800; minus 12,000 leaves about 116,800. At 3,000 a step that is 38 whole steps (); at 15,000 it is 7 whole steps (7.8).
- B5: Subagents add the sum of their own work to the bill but keep the parent’s growth to the returned summaries. You trade total tokens for a clean parent window and for parallelism.
Design drill 1: a coding agent for a large monorepo (40 minutes)
Prompt. Engineers file issues; the agent should reproduce, fix, test and open a pull request. About 300 issues a week, mixed difficulty, a strict review policy, no production access.
A framework to say aloud.
- Clarify. What counts as success (merged, tests added)? Risk tolerance, languages, CI time, who reviews, budget per issue.
- Context. A short instruction file that maps to a docs folder, code search tools, per-module owners, skills loaded on demand.
- Tools and environment. A sandbox per task (container plus a separate working copy), read, search and conditional-edit tools, a shell with an allow list, a test runner, a browser for UI bugs, no secrets, outbound network denied by default.
- Loop and state. Reproduce first. A plan file and a progress file, compaction at a threshold, step, budget and time limits, repeated-call detection.
- Enforcement. A post-edit lint and type hook, structural tests with messages that say how to fix, tests unwritable except for new ones, a stop hook that requires green targeted tests, approval to push.
- Verification. Reproduce the failing test, fix, run targeted and impacted tests, an independent reviewer, CI, then a person. A policy for flaky tests.
- Orchestration. One agent by default; subagents for exploring the codebase and for independent review; a stronger model for diagnosis and a smaller one for formatting.
- Evaluation and operations. A replay set of past issues held out from tuning, , cost per merged fix, reviewer acceptance, a trace store, a weekly failure classification, gradual rollout of harness versions, a kill switch, and an incident that ends in a new sensor.
Markers of a strong answer. Reproduce-first; verification independent of the author; numbers (a budget per issue, expected acceptance); isolation per task; explicit stop conditions; named failure classes; the improvement loop; honesty about what stays with people, such as judgment and security-sensitive code. Expect the interviewer to change a constraint halfway (“the repo has secrets in its history”, “volume is ten times higher”, “the budget halves”). Re-cost the design out loud: cap steps and tool output, send routine steps to a smaller model, and say what quality risk you accept.
Design drill 2: a support agent that can issue refunds (30 minutes)
Key points for a security-heavy design. Split tools into read, propose and commit. Put the refund commit behind a policy engine (amount limits, customer history, fraud signals) with human approval above a threshold. Use idempotency keys so a retry cannot refund twice. Redact personal data. Treat ticket text as untrusted input, and do not let an agent that reads it also hold private data and an outbound channel (the lethal trifecta). Keep an audit log. Evaluate on historical tickets with state-based graders, and plan for outcomes that arrive days later by using proxy measures until they do. Have a kill switch, and roll out by customer segment.
Rapid-fire
Answer each in about twenty seconds.
- Define Agent = Model + Harness.
- Name the six component families.
- Why is “done” a hypothesis?
- What is a guide? What is a sensor?
- Why prefer computational sensors?
- What makes a good lint message for an agent?
- Why a JSON feature list rather than a Markdown checklist?
- What does a hook give you that a prompt rule does not?
- Why isolate agents with separate working copies?
- What is the ratchet?
- Why can a better model mean fewer harness rules?
- versus ?
Key. 1. The model is stateless; everything that lets it act reliably is the harness. 2. Instructions, tools, infrastructure, orchestration, enforcement, observability. 3. The model may be wrong or inventing; the harness checks against tests and state. 4. Steering before action; observing after. 5. Deterministic, cheap, fast, always on. 6. It states the rule broken and how to fix it, briefly. 7. Anthropic reported the model was less likely to change structured JSON inappropriately (and the harness can restrict the fields). 8. Guaranteed execution at defined points. 9. Parallel changes do not collide, and the copy is disposable. 10. Each real failure becomes a permanent check or rule, removed when no longer needed. 11. Components assume model weaknesses; remove them when the assumption stops holding. 12. At least one success of k attempts versus all of them succeeding.
Scenario drills
Diagnose each aloud by layer before reading the answer.
- F1. “The agent keeps declaring the migration finished at 40 percent.” Completion is not tied to a checklist: add an up-front task list with fields the agent cannot edit, a verification script and a stop check, and give each session a startup routine.
- F2. “It passes locally but breaks the UI in production.” Verification stopped at unit tests: add browser end-to-end checks and a staging smoke test.
- F3. “After a model upgrade, success is flat and cost is up 40 percent.” Old compensations now add steps: ablate them, and check that tool shapes still suit the model.
- F4. “It edited the tests to pass.” The success criteria were writable: make tests unwritable for the agent, use a hook on protected paths, and grade in CI.
- F5. “Costs doubled for the same tasks.” Read the traces by stage: uncapped tool output, subagent fan-out, a prompt layout that defeats caching, loops.
- F6. “An MCP server update started leaking data.” Tool descriptions and results are untrusted input: pin and review servers, scope credentials, limit outbound traffic, and require approval where data crosses a boundary.
- F7. “The instruction file grew to 800 lines and behaviour got worse.” It crowds the window and holds stale rules: shrink it to a map, tie each rule to a failure, and move detail into documents.
- F8. “Parallel agents keep producing conflicting pull requests.” Separate working copies, ownership by module, a queue with locks, and an integration step.
Real-World Application
Run a mock with a friend as the interviewer who may only ask, not teach. A 35-minute version: three explanations from the first list, one derivation, one scenario. A 45-minute version: one design drill, with the interviewer changing a constraint twice. Afterwards, note the two places you lost the thread and which lesson covers them, and repeat those drills a few days later on a nearby variant, such as the monorepo drill for an agent that runs SQL on production replicas.
Interview Perspective
Expect all of the above, in any order. The signals interviewers tend to look for are structure under time pressure, numbers you can derive, independent verification, honesty about limits, and the improvement loop raised without being asked. A common failure is to list components without saying why each exists or what it costs.
Provenance: Common industry pattern and Generated practice. None of these drills is verified as asked by a named company.
Practice Questions
- Basic: Give the 90-second answer to “What is a harness?” with one example.
- Intermediate: Work B4 again with a 128,000-token window, 8,000 reserved for output, 8,000 fixed, compaction at 75 percent of the remainder and 2,000 tokens a step.
- Advanced: Run drill 1 with the constraint “no sandbox is available”. What changes?
- Product-Company: Design a harness for an overnight agent that merges small dependency updates, in 40 minutes.
Activity
Time yourself on one explanation and one derivation. If either takes more than twice its budget, mark the lesson it comes from and read that section again, then try a nearby variant rather than the same prompt.
Homework
Record yourself answering drill 2 in 30 minutes. Play it back and list the points from the key you missed, then rewrite your opening 60 seconds so that it states what you are optimising and the order you will cover things.
Quick Revision
- Explain each core idea in 90 seconds with one example and one trade-off.
- Know the derivations: , , , cost per resolved task, steps before compaction.
- Design in eight parts: clarify, context, tools and environment, loop and state, enforcement, verification, orchestration, evaluation and operations.
- Diagnose by layer, then fix structurally.
- When a constraint changes, re-cost the design aloud and state the risk you accept.
Check yourself
- Walk-through: Design the harness for an agent that fixes bugs in a very large repository, in about forty minutes.
- Variation: Redo it for an agent that issues refunds.
- Common misconception: “More components means a better design.” Each component should trace to a behaviour or a failure.
Related
Resources & Further Reading
Checked sources to go deeper. The essential ones come first in each group.
Official documentation
Agent Harness (opens in a new tab)
A concrete product's harness with todo tracking, approval, observability and optional background agents, useful as a worked example when an interviewer asks what a harness contains.
Further reading
Don't Build Multi-Agents (opens in a new tab)
A well-argued case against default multi-agent designs, which prepares you for the interviewer who challenges your orchestration choice.
Research papers
τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains (opens in a new tab)
The source of the pass^k reliability metric you are asked to derive, with the benchmark design behind it.
More for this module: Harness engineering resources
Practice
Test what you just read. Quizzes and cards are grouped by module: Harness engineering.
Check yourself12 questions on what this lesson set out to teach
Checking answers needs JavaScript. You can still read every question and option below.
Keyboard: arrow keys move between options. Space or Enter selects the focused option.