Harness engineering: interview drills

  • Advanced
  • 40 min
  • Lesson 7 of 7 in Harness engineering
  • Last verified

Open slides(26 slides)

Before you start

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.

Diagram: A strong answer goes in a fixed order: say what you are optimising, draw the context and tools, then the loop and state, then enforcement...

1 Say what you are optimising

2 Context and tools

3 Loop and state

4 Enforcement and verification

5 Where people stand

6 How you will know it works

Diagram summary: A strong answer goes in a fixed order: say what you are optimising, draw the context and tools, then the loop and state, then enforcement and verification, then where people stand, and finally how you will measure success.

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.

  1. 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.)
  2. 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.
  3. Guides versus sensors; computational versus inferential. Steer before, observe after; deterministic versus a model’s judgment. Use both; computational first. (Lesson 4.)
  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.)
  5. Why subagents, and what they cost. Context isolation and parallelism, paid for in total tokens. (Lesson 5.)
  6. How you prove a harness change helped. One change, the same held-out tasks, several trials, a state-based grader, passk\text{pass}^k 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. pass@k\text{pass@}k and passk\text{pass}^k for p=0.9p = 0.9 and k=10k = 10.
  • 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: pass@10=1−0.110\text{pass@}10 = 1 - 0.1^{10}, essentially 1 (0.9999999999). pass10=0.910≈0.349\text{pass}^{10} = 0.9^{10} \approx 0.349.
  • B3: 1.200.5=2.40\dfrac{1.20}{0.5} = 2.40 dollars against 1.800.8=2.25\dfrac{1.80}{0.8} = 2.25 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 (116,8003,000=38.9\dfrac{116{,}800}{3{,}000} = 38.9); 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.

  1. Clarify. What counts as success (merged, tests added)? Risk tolerance, languages, CI time, who reviews, budget per issue.
  2. Context. A short instruction file that maps to a docs folder, code search tools, per-module owners, skills loaded on demand.
  3. 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.
  4. Loop and state. Reproduce first. A plan file and a progress file, compaction at a threshold, step, budget and time limits, repeated-call detection.
  5. 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.
  6. Verification. Reproduce the failing test, fix, run targeted and impacted tests, an independent reviewer, CI, then a person. A policy for flaky tests.
  7. 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.
  8. Evaluation and operations. A replay set of past issues held out from tuning, passk\text{pass}^k, 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.
Diagram: An issue enters a queue, runs in an isolated sandbox through the agent loop with hooks, goes to an independent reviewer, a pull request, CI...

new guides and sensors

Issue

Queue and triage

Sandbox: container and working copy

Agent loop: reproduce, plan, edit, test

Hooks: lint, types, structural tests

Independent reviewer

Open pull request

CI full tests

Human review

Traces and cost record

Evaluation and failure triage

Diagram summary: An issue enters a queue, runs in an isolated sandbox through the agent loop with hooks, goes to an independent reviewer, a pull request, CI and a person, while traces feed evaluation and new guides and sensors flow back into the hooks.

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.

Diagram: For any scenario, name the failing layer first: context, constraint, verification or planning.

lacked information

acted out of scope

wrong output unchecked

wrong approach or loop

A failure to diagnose

Which layer broke?

Context

Constraint

Verification

Planning

Change that layer, add a regression check

Diagram summary: For any scenario, name the failing layer first: context, constraint, verification or planning. Then change that layer and add a regression check so the failure is caught if it returns.

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.

  1. Define Agent = Model + Harness.
  2. Name the six component families.
  3. Why is “done” a hypothesis?
  4. What is a guide? What is a sensor?
  5. Why prefer computational sensors?
  6. What makes a good lint message for an agent?
  7. Why a JSON feature list rather than a Markdown checklist?
  8. What does a hook give you that a prompt rule does not?
  9. Why isolate agents with separate working copies?
  10. What is the ratchet?
  11. Why can a better model mean fewer harness rules?
  12. passk\text{pass}^k versus pass@k\text{pass@}k?

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: pnp^n, pass@k\text{pass@}k, passk\text{pass}^k, 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.

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)

    Microsoft Learn (Agent Framework)2026Documentation

    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

Research papers

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.

0 of 12 answered

Keyboard: arrow keys move between options. Space or Enter selects the focused option.

ObjectiveWork the standard derivations: n-step success, pass@k and pass^k, cost per resolved task, and steps before compaction.

  1. Question 1 of 12A task needs 50 independent steps and each step succeeds 99 percent of the time. About how often does the whole task succeed?

    Choose one answer.

  2. Question 2 of 12Each trial succeeds with probability 0.95, and you run 20 independent trials. What are pass@20 and pass^20?

    Choose one answer.

  3. Question 3 of 12Design X costs 1.50 dollars per attempt with 30 percent success. Design Y costs 2.00 dollars with 60 percent success. Which is cheaper per resolved task?

    Choose one answer.

  4. Question 4 of 12The window is 160,000 tokens, 10,000 are reserved for output and 14,000 are fixed. Compaction starts at 80 percent of what remains after the reserve, and each step adds 2,500 tokens. About how many steps fit before compaction?

    Choose one answer.

ObjectiveStructure a 40-minute harness design answer in eight parts and name the markers of a strong one.

  1. Question 5 of 12In a 40-minute harness design interview, what should you do first?

    Choose one answer.

  2. Question 6 of 12Which are markers of a strong harness design answer? Select all that apply.

    Choose all that apply.

  3. Question 7 of 12Midway through your design the interviewer says the budget has been halved. What is the best response?

    Choose one answer.

ObjectiveDiagnose a described agent failure by layer and propose a structural fix.

  1. Question 8 of 12An agent keeps declaring a migration finished when it is 40 percent done. What is the best diagnosis and fix?

    Choose one answer.

  2. Question 9 of 12An agent's change passes every test locally but breaks the user interface in production. What does that suggest?

    Choose one answer.

  3. Question 10 of 12After an update to a tool server, an agent starts sending data to an unknown address. What is the right response?

    Choose one answer.

ObjectiveExplain the core harness ideas (harness, guides and sensors, state across sessions, subagents, proving a change) clearly in about 90 seconds each.

  1. Question 11 of 12Which is the best ninety-second answer to "What is harness engineering?"

    Choose one answer.

  2. Question 12 of 12An interviewer asks about "the harness" and you are not sure what they mean. What should you do in the first fifteen seconds?

    Choose one answer.