Module deck
Harness engineering flashcards
Reviewing needs JavaScript. You can read every card in the list below.
Loading your cards...
Back to the module84 cards in this deck
Read all 84 cards as a list
What is an agent harness?
- Front
- What is an agent harness?
- Back
- Everything around the model that makes it an agent: loop, tools, state, sandbox, permissions, verification, orchestration, observability. Agent = model + harness.
- Front
- What is harness engineering, and what is its unit of improvement?
- Back
- Designing the environment, constraints and feedback loops so an agent stays reliable, and improving them from observed failures. The unit is the environment, not the prompt.
- Front
- How do prompt, context and harness engineering nest?
- Back
- Prompt (wording of one call) sits inside context (what the model sees now), which sits inside the harness (adds persistence, enforcement, orchestration, observability and the improvement loop).
- Front
- Name the six harness component families.
- Back
- Instructions, tools, infrastructure (filesystem, git, sandbox, browser), orchestration, enforcement (hooks, permissions, linters, tests), observability.
- Front
- Inner versus outer harness?
- Back
- Inner (Böckeler: the builder's harness) is shipped by the tool or model builder and you do not control it. Outer (the user's harness) is what you add: instruction files, MCP servers, skills, hooks, linters, tests. That is where application engineers have leverage.
- Front
- What are the four failure layers and their fixes?
- Back
- Context (it lacked information): fix retrieval and docs. Constraint (acted outside scope): fix permissions and hooks. Verification (wrong output unchecked): fix tests and evaluators. Planning (wrong approach, loops): fix decomposition and loop detection.
- Front
- How do you estimate success of an n-step task?
- Back
- About p to the power n for per-step success p, assuming independent steps. 0.98 over 25 steps is about 0.60. Errors are usually correlated, so say roughly.
- Front
- Two levers for long tasks that keep failing?
- Back
- Raise per-step reliability (better tools, context, verification after a step) or add recovery (detect and repair an error mid-task, with checkpoints).
- Front
- What is the ratchet?
- Back
- Every real mistake becomes a permanent rule, check or hook, with the incident noted. When a stronger model makes it redundant, remove it.
- Front
- What does "assumptions decay" mean for a harness?
- Back
- Each component assumes something the model cannot do. Re-test it when the model changes: some scaffolding retires, harder tasks need new scaffolding.
- Front
- Which meanings of "harness" should you disambiguate in an interview?
- Back
- Test harness, evaluation harness (benchmark runner), reinforcement-learning environment wrapper, and agent harness. Ask which is meant.
The agent loop and tool design
- Front
- Who decides that an agent's work is done?
- Back
- The harness, by checking. The model proposes that it is done; a message with no tool call is a claim to verify with tests, a schema, a required artefact or a check the harness runs itself.
- Front
- Why was a feature list that starts all failing useful for long-running agents?
- Back
- The agent was told to mark an entry passing only after testing it, so it could not simply declare the job finished from earlier progress. It is an instruction, not a mechanism; a check the harness runs itself is stronger (Anthropic, Nov 2025).
- Front
- What does a good tool error look like?
- Back
- It says what failed, why, and what to try, written for a model: "File not found: src/a.py. Did you mean src/app.py? Use list_dir." Not a code or a stack trace.
- Front
- Where do you handle transient tool failures?
- Back
- In the harness, with retries and backoff the model does not see. Return a message only when retries run out. Otherwise the model burns its step budget on flakiness.
- Front
- What signals no progress, and what do you do?
- Back
- The same call with the same arguments, or the same error, repeated. Nudge once, then stop or escalate to a human, and log it.
- Front
- Guidelines for a tool set?
- Back
- Few, thoughtful tools for real workflows, not one per endpoint; no overlaps; descriptions written for a new colleague; readable short output; arguments that make mistakes hard (poka-yoke); read and write split.
- Front
- How do you improve tools?
- Back
- Run realistic multi-step tasks with checkable outcomes, read the transcripts, find where the model misuses a tool, then change the tool, not the prompt. Keep a held-out set.
- Front
- What is a conditional edit and why use it?
- Back
- An edit that carries the text it expects to replace, so a stale line number fails instead of editing the wrong line. Optimistic concurrency for model edits.
- Front
- What is progressive disclosure of tools?
- Back
- The model starts with a way to find tools and loads full definitions only for those it needs, so a large catalog does not fill the window before work starts.
- Front
- How do you handle a very long tool output?
- Back
- Keep the head and tail, write the full output to a file and give the model the path, summarise noisy sources with a cheaper model, and redact secrets first.
- Front
- Trade-off of giving an agent a general shell?
- Back
- Few definitions and great capability, but a large blast radius and noisy output. It needs a sandbox, allow and deny lists, timeouts and output caps.
- Front
- When is replaying a crashed run safe?
- Back
- Only when tools are idempotent: an idempotency key or a conditional edit means a repeated step has no extra effect. Persist messages, results, plan and side-effect ids after each step.
- Front
- Why version tool schemas?
- Back
- A model's behaviour can depend on tool names and shapes. Renaming a tool or changing an argument can regress calls that worked, so re-run your tasks and record the change.
Context and long-running agents
- Front
- Name the two problems that long agent runs hit.
- Back
- Context rot inside a session (a crowded window degrades use of what is in it) and amnesia across sessions (each new window starts blank). The harness budgets the first and writes state down for the second.
- Front
- What is context rot?
- Back
- As the number of tokens in the window grows, the model's ability to recall information from it falls. Treat the window as a finite attention budget (Anthropic, Sep 2025).
- Front
- Three cheap moves to protect the context budget?
- Back
- Cap what enters (truncate and offload large outputs), clear old raw tool results, and compact the conversation late and in one step.
- Front
- What should a compaction keep as written?
- Back
- The goal and acceptance criteria, constraints, key decisions with their reasons, open to-dos, files touched, the last failing command and error, and identifiers needed later.
- Front
- What can a compaction drop or replace with a pointer?
- Back
- Raw tool output (save it to a file), repeated reads, and exploration that led nowhere. Keep the fact of what was tried and why it failed.
- Front
- Two ways a compaction goes wrong?
- Back
- Details are lost and then reinvented with confidence, and negative knowledge (what failed and why) disappears. Changing early context also defeats prefix caching.
- Front
- What does the initializer session create in Anthropic's long-running pattern?
- Back
- An init script, a progress file, a first git commit and a feature list with every entry failing. Later coding sessions use the same harness and tools with a different first prompt.
- Front
- Why a JSON feature list rather than Markdown?
- Back
- Anthropic reports the model was less likely to change structured JSON inappropriately than Markdown. The agent was told to change only each entry's passes field.
- Front
- Is "change only passes" a lock?
- Back
- No: it is an instruction in a prompt. The harness should reject other edits, or keep the list where the agent can write only the status.
- Front
- What is the session startup routine?
- Back
- Check the working directory, read the git log and progress file, read the feature list and pick one unfinished item, run the init script, and run a basic end-to-end check before adding anything.
- Front
- Why keep the instruction file short?
- Back
- A long file crowds the window, flattens priorities and goes stale. Keep a short map that points into a docs folder, and tie each rule to a past failure (Osmani).
- Front
- What does "if the agent cannot read it, it does not exist" mean in practice?
- Back
- Decisions held in chat or in heads must be written into the repository as plain versioned text. Scope memory per session and make it fail closed when no scope is known.
Guides, sensors and enforcement
- Front
- What is a guide, and what is a sensor?
- Back
- A guide steers the agent before it acts (instructions, skills, templates). A sensor observes after it acts so the agent can correct itself (linters, tests, reviews). Use both (Böckeler, Apr 2026).
- Front
- Computational versus inferential controls?
- Back
- Computational: deterministic, fast, cheap checks (tests, linters, type checkers, structural tests). Inferential: a model's judgment (AI review, LLM judge): slower, costlier, less predictable.
- Front
- Which sensors run on every change?
- Back
- Computational ones. Spend inferential checks where meaning matters and no deterministic test exists, and treat their verdicts as less certain.
- Front
- What does keep quality left mean?
- Back
- Run checks as early as possible: fast ones (format, lint, types, quick tests) right after an edit or before commit; expensive ones (slower tests, deep review) later; drift scans continuously.
- Front
- What is the rule for sensor output?
- Back
- Success silent, failure verbose: print nothing when a check passes, and a short, specific message the agent can act on, with the fix, when it fails.
- Front
- Why is a hook a guarantee and a prompt rule a suggestion?
- Back
- A hook is code the harness runs at a defined point whatever the model decides. A prompt rule depends on the model following it every time.
- Front
- Which hook points can block, and which cannot?
- Back
- Before a tool call can block it. After a tool call cannot undo it (it can feed a message back). A stop hook can prevent the agent from finishing, for example while tests fail. Other points, such as prompt submission, can block too, so check the current docs (Claude Code).
- Front
- How should permissions be tiered?
- Back
- Read-only: allow. Reversible write in a sandbox: allow. Costly or external: allow-list or approve each use. Destructive or irreversible: explicit human approval. Fail closed when scope is unknown.
- Front
- Why does approval fatigue matter?
- Back
- If people click approve constantly they stop looking. Sandboxing sets boundaries so the agent works freely inside them; Anthropic reports 84 percent fewer permission prompts in internal use (Oct 2025).
- Front
- Why do sandboxes need both file and network limits?
- Back
- Without network limits a compromised agent could send out files; without file limits it could escape the sandbox and reach the network. Each covers the other's gap.
- Front
- What is the lethal trifecta and the response?
- Back
- Private data, exposure to untrusted content and external communication in one agent allow data theft (Willison, Jun 2025). Avoid the combination: remove a leg, separate by trust, least privilege.
- Front
- How do you stop an agent from editing the tests?
- Back
- Make them unwritable for the agent (permissions or a hook on protected paths), keep success criteria where it cannot rewrite them, and grade with an independent run in CI.
- Front
- Which part of verification is weakest?
- Back
- Behaviour (does it do the right thing). Böckeler says reliance on AI-generated tests is not good enough yet; add coverage and mutation checks and manual testing for critical paths.
Orchestration, subagents and people in the loop
- Front
- What is the first reason to use a subagent?
- Back
- Context isolation: it explores in its own window and returns a short result (often 1,000 to 2,000 tokens), so the parent's window stays clean (Anthropic, Sep 2025).
- Front
- What does isolation cost?
- Back
- Total tokens: Anthropic reports agents used about 4 times a chat's tokens and multi-agent systems about 15 times in their system, so the task must be valuable enough.
- Front
- When do subagents not pay?
- Back
- Small tasks, work where all agents need the same context, and tightly coupled edits. Most coding tasks have fewer parallel parts than research.
- Front
- What goes in a delegation contract?
- Back
- Objective and what good looks like, constraints and budget, allowed tools, an output format the parent can read without redoing the work, and a stop condition with where to write artefacts.
- Front
- How should agents hand work to each other?
- Back
- Through files and structured, validated results, not long transcripts. Use job ids and status fields to make handoffs resumable, and name one owner per artefact.
- Front
- Why separate builder and checker?
- Back
- An agent grading its own work has a conflict. Prefer deterministic tests, or a separate agent, and agree what done means before the work starts. It adds a second pass of cost.
- Front
- How should models be routed?
- Back
- By step type, risk and context size: strong for planning and ambiguity, smaller for routine work, with a fallback to the stronger model. Re-test routing on each new model; switching models mid-conversation can lose cached context.
- Front
- How do you isolate parallel agents on one repository?
- Back
- A working copy or container per task, ownership by module, a queue with locks for shared resources, small changes and an integration step. In our judgment, coordination cost grows faster than throughput.
- Front
- Why state a practice's conditions?
- Back
- A practice is right only under its operating conditions. Minimal blocking review suits high throughput, cheap corrections and strong tests, and would be risky in low-volume or high-risk work.
- Front
- Where do people belong in an agent system?
- Back
- At intent and acceptance, irreversible actions, escalations and the steering loop, where they turn recurring failures into guides, sensors and hooks (Böckeler).
- Front
- What is an autonomy ladder?
- Back
- Suggest only, act with approval, act and notify, act alone. Move each kind of action up as evidence builds, based on reversibility, blast radius and verification strength.
Evaluating and operating a harness
- Front
- What makes a fair harness experiment?
- Back
- Hold the model fixed and change one component; use the same tasks, split into tuning and held-out sets; run several trials; grade the end state; seal the environment.
- Front
- What should you do with graders?
- Back
- Choose them on purpose (code, model or human), calibrate model graders against people, and read transcripts from many trials to find broken graders (Anthropic, Jan 2026).
- Front
- Why replicate leaderboard gains?
- Back
- Harness-only gains often come from vendor or practitioner posts without full methodology. Replicate on your own tasks before relying on them.
- Front
- How do pass@k and pass^k differ for p = 0.8, k = 5?
- Back
- pass@5 = 1 − 0.2^5 ≈ 0.9997 (at least one success). pass^5 = 0.8^5 ≈ 0.328 (all succeed). An agent that usually works can be unusable if someone relies on it every time.
- Front
- What is cost per resolved task?
- Back
- Attempt cost divided by success rate. 0.80 at 40 percent is 2.00; 1.00 at 65 percent is about 1.54. Better success can justify a pricier attempt.
- Front
- What is the improvement loop?
- Back
- Run tasks, collect traces, classify failures by layer, make a structural change, re-run held-out tasks; keep it if better with no regressions, otherwise revert.
- Front
- Why prefer structural fixes to prompt text?
- Back
- A tool, sensor or hook can be measured and enforced. Add a regression check for each fix. Prompt patches depend on the model complying every time.
- Front
- What goes in a trace?
- Back
- Versioned prompts, model, tool calls and results, permission decisions, durations, tokens, cost and stop reason, in a standard format such as OpenTelemetry, with secrets redacted.
- Front
- What do you do when the model changes?
- Back
- Run the held-out tasks first to re-baseline, ablate components that assumed the old model's weaknesses, tie each rule to a failure, delete what you cannot justify, and version the harness as code.
- Front
- A sensor never fires. Good or bad?
- Back
- Unknown: quality or blindness. Seed a known fault to see whether it fires. Böckeler lists this as an open question.
- Front
- What does operating an agent need?
- Back
- Checkpoint and resume with idempotent tools, budgets and timeouts with a kill switch, rollback, safe degradation when a check is down, a runbook, and an incident that ends in a new guide, sensor or hook.
- Front
- What should the agent do if its verifier is unavailable?
- Back
- Stop and escalate rather than proceed unverified.
Harness engineering: interview drills
- Front
- Give the 90-second answer shape for any concept.
- Back
- Define it in one sentence, give one concrete example, name one trade-off or cost, and say how you would check it. Rehearse until it fits in about ninety seconds.
- Front
- What are the six harness component families?
- Back
- Instructions, tools, infrastructure, orchestration, enforcement, observability.
- Front
- Why is "done" a hypothesis?
- Back
- The model may be wrong or inventing. The harness checks against tests and state before the run ends.
- Front
- Why a hook rather than a prompt rule?
- Back
- A hook runs in code at a defined point whatever the model decides, so the rule holds. A prompt rule is a suggestion.
- Front
- What is the ratchet, and why can a better model mean fewer rules?
- Back
- Each real failure becomes a permanent check. Components assume model weaknesses, so remove one when its assumption stops holding.
- Front
- n-step success, pass@k, pass^k and cost per resolved task: the formulas?
- Back
- p^n; 1 − (1 − p)^k; p^k; attempt cost divided by success rate. For example 0.99^40 ≈ 0.67, and 0.9^10 ≈ 0.35.
- Front
- How do you compute steps before compaction?
- Back
- (threshold share × (window − output reserve) − fixed prompt) ÷ tokens per step. Capping tool output is the cheapest way to get more steps.
- Front
- What are the eight parts of a harness design answer?
- Back
- Clarify; context; tools and environment; loop and state; enforcement; verification; orchestration; evaluation and operations.
- Front
- What marks a strong design answer?
- Back
- Reproduce first, independent verification, numbers, isolation per task, explicit stop conditions, named failure classes, the improvement loop, and honesty about what stays with people.
- Front
- What do you do when the interviewer changes a constraint?
- Back
- Re-cost the design aloud: cap steps and output, route routine steps to a smaller model, and say what quality risk you accept.
- Front
- Scenario: it edits the tests to pass.
- Back
- The success criteria were writable. Make tests unwritable for the agent, use a hook on protected paths, and grade in CI.
- Front
- Scenario: success is flat and cost is up 40 percent after an upgrade.
- Back
- Old compensations now add steps. Ablate them one at a time on held-out tasks and check that tool shapes still suit the model.