Slides · Harness engineering

Evaluating and operating a harness

Evaluating and operating a harness

How to tell whether a harness change really helped, what a resolved task costs, how to keep the harness healthy as models change, and how to run an agent safely.

By the end you can design the experiment, compute cost per resolved task, run the improvement loop, re-baseline after a model change and operate with limits.

Concept

Two questions that make the method

A new routing rule closes tickets faster than ever. Two questions test the claim.

  • “Faster than what?” asks for a baseline: the same tickets, run the same way, without the rule.
  • “How many came back?” asks for the outcome that matters: tickets resolved correctly, not tickets closed quickly.
  • A good experiment holds everything else fixed, changes one thing, counts the right outcome over enough runs, then reads the failures.

Concept

Why one run tells you little

  • Anthropic notes that the same agent can give different outputs on different runs, which is why its evaluations repeat each task over several trials.
  • The run you look at after a change is the one you remember, so it feels like proof.
  • Three good runs in a row can come from a lucky draw on easy tasks.
  • Several trials per task, on the same tasks, with and without the change, is the minimum.

Source1 Demystifying evals for AI agents

Process

Designing the experiment

  1. Start small. Anthropic began its multi-agent evaluation with about 20 queries from real usage, and describes 20 to 50 simple tasks taken from real failures as a good starting set.
  2. Change one thing (an ablation), with the model fixed. To compare models, fix the harness instead.
  3. Use the same tasks, split into a development set you tune on and a held-out set you report on. Anthropic’s tool-writing post says it used held-out test sets to avoid overfitting.
  4. Run several trials per task and report an interval. The interval is this course’s advice.
  5. Grade the end state, such as tests passing, not how the transcript reads.
  6. Seal the environment so the agent cannot find answers it would not have in production.

Sources1 Demystifying evals for AI agents2 Writing effective tools for agents — with agents3 How we built our multi-agent research system

Diagram

One experiment, two harness versions

Diagram: One task set splits into a development set, where you tune, and a held-out set, where you report.

Same task set

Dev set: tune here

Held-out set: report here

Run A and B, several trials, state grader

Compare pass^k, cost, interval

Diagram summary: One task set splits into a development set, where you tune, and a held-out set, where you report. Both harness versions run on the held-out set with several trials and a state-based grader. The comparison at the bottom uses passk\text{pass}^k, cost per resolved task and an interval.

Compare

Choose graders on purpose

AspectCode-basedModel-basedHuman
StrengthQuick, inexpensive, objective, repeatableAdaptable, scales, can weigh nuanceBest quality, mirrors what experts would decide
WeaknessBreaks on valid variations; weak on subjective tasksVaries between runs, costs more than code, needs calibratingCostly, slow, needs expert access
RoleFirst choice where a check existsWhere code cannot judgeCalibrates model graders

The source’s summary of each grader type is condensed here. Prefer a deterministic check where one exists and use a model judge for what code cannot see.

Source1 Demystifying evals for AI agents

Concept

Traps: broken graders and leaked answers

  • Anthropic’s advice: to learn whether a grader works, read many trials’ transcripts alongside the grades they received.
  • It reports that Opus 4.5 first scored 42 percent on CORE-Bench; after grading bugs and ambiguous specs were fixed and the scaffold loosened, the score rose to 95 percent.
  • It also saw Claude examine git history from earlier trials in some internal evals, which gave an unfair advantage.
  • Isolate each trial from a clean environment, or leftover state correlates failures and inflates scores.

Source1 Demystifying evals for AI agents

Concept

Treat harness-only gains as claims to replicate

  • Public leaderboards are useful for orientation.
  • Gains reported from changing only the harness often come from vendor or practitioner posts without full methodology; this is the course’s observation, not a measured rate.
  • A higher benchmark score does not by itself mean a better production agent for your tasks.
  • Replicate on your own tasks before you believe a number.

Math

Reliability: pass@k and pass^k

pass@k=1−(1−p)k\text{pass@}k = 1 - (1 - p)^kpassk=pk\text{pass}^k = p^k
SymbolMeaning
ppChance one trial of a task succeeds (assumed the same and independent each time)
kkNumber of trials
pass@k\text{pass@}kChance of at least one success in kk trials
passk\text{pass}^kChance that all kk trials succeed

Anthropic defines the two this way, and the tau-bench paper proposed passk\text{pass}^k as a reliability metric across trials. Worked, with p=0.7p = 0.7 and k=3k = 3: pass@3=1−0.33=1−0.027=0.973\text{pass@}3 = 1 - 0.3^3 = 1 - 0.027 = 0.973; pass3=0.73=0.343\text{pass}^3 = 0.7^3 = 0.343. An agent that usually works is nearly always right once in three and reliable all three times only about a third of the time.

Sources1 Demystifying evals for AI agents4 τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains

Math

Cost per resolved task

cost per resolved task=cost per attemptsuccess rate\text{cost per resolved task} = \frac{\text{cost per attempt}}{\text{success rate}}
SymbolMeaning
cost per attemptAverage spend for one try, including failed tries
success rateShare of attempts that end in a correct, accepted result

Illustrative prices. Design P costs 0.45 dollars per attempt and succeeds 35 percent of the time: 0.450.35≈1.29\dfrac{0.45}{0.35} \approx 1.29 dollars per resolved task. Design Q costs 0.70 dollars and succeeds 70 percent: 0.700.70=1.00\dfrac{0.70}{0.70} = 1.00 dollar. Q’s attempt is about 56 percent more expensive (0.700.45=1.56\dfrac{0.70}{0.45} = 1.56) yet each result is cheaper, because it fails far less. A cheap attempt that fails often can be the expensive design.

Worked example

Worked example: aggregate, don’t average the ratios

Four held-out tasks, 5 trials each, 0.50 dollars per trial (illustrative). Successes per task: 5, 3, 1, 0.

AspectValueArithmetic
Total cost10.00 dollars4×5×0.504 \times 5 \times 0.50 (tasks, trials, dollars per trial)
Total successes95+3+1+05 + 3 + 1 + 0
Cost per resolved taskabout 1.11 dollars10.009\dfrac{10.00}{9}
Mean success rate0.45920\dfrac{9}{20}
pass@5\text{pass@}50.753 of 4 tasks had at least one success
pass5\text{pass}^50.251 of 4 tasks succeeded all 5 times
Never solved1 taskthe task with 0 successes

Averaging per-task ratios is the wrong method. The ratios are 0.50, 0.83 and 2.50 dollars for three tasks and undefined for the fourth (zero successes). Dropping the undefined one gives a mean of about 1.28 dollars, which no longer equals total spend over total successes (1.11) and ignores the money the unsolved task consumed. Report total cost over total successes and count never-solved tasks separately.

Code

Put an interval around the difference

Python

import random
A = [5,4,4,3,3,2,2,1,1,0,0,0]   # successes out of k=5, baseline (illustrative)
B = [5,5,4,4,3,3,2,2,1,1,0,0]   # same 12 tasks, one component changed
k = 5
diffs = [(b - a) / k for a, b in zip(A, B)]
random.seed(7)
boots = sorted(
    sum(random.choice(diffs) for _ in diffs) / len(diffs)
    for _ in range(10000)
)
print(sum(diffs)/len(diffs), boots[249], boots[9749])

Output when run: mean difference 0.083, with a 95 percent interval of about 0.033 to 0.133. The code resamples tasks, not trials, because tasks are the unit you want to generalise over. With only 12 tasks the data and the interval are illustrative, and the interval says nothing about tasks unlike these.

Check yourself

Check: work backwards from the cost

A team reports that cost per resolved task fell from 2.10 dollars to 1.40 dollars after a harness change, with the attempt cost unchanged at 0.70 dollars. What happened to the success rate, and what would you check before believing it?

Answer

Success rate = attempt costcost per resolved task\dfrac{\text{attempt cost}}{\text{cost per resolved task}}. Before: 0.702.10≈33\dfrac{0.70}{2.10} \approx 33 percent. After: 0.701.40=50\dfrac{0.70}{1.40} = 50 percent. Before believing it, check that both numbers came from the same held-out tasks with several trials, whether the interval separates the two, whether passk\text{pass}^k (reliability) moved too, and whether a successful result still counts only when it is correct and accepted.

Check yourself

Check: better on the dev set

A new compaction policy lifts success from 50 to 70 percent on the tasks the team tuned it on. On a fresh held-out set, success is 52 percent against 50. What do you conclude?

Answer

The change was probably fitted to the development tasks. The held-out result is the one to report, and a two-point gain on a small set may be noise. Run more trials on the held-out set and look at the failures. This is why tuning and reporting use different tasks: Anthropic’s tool-writing post used held-out test sets to avoid overfitting to its training evaluations.

Diagram

The improvement loop

Diagram: Run tasks and collect traces, classify each failure by the layer that broke, make a structural fix, and re-run the held-out tasks.

better, no regressions

worse

Run tasks, collect traces

Classify each failure by layer

Make a structural fix

Re-run held-out tasks

Keep it

Revert

Diagram summary: Run tasks and collect traces, classify each failure by the layer that broke, make a structural fix, and re-run the held-out tasks. A change that is better with no regressions is kept, and one that is worse is reverted. The loop is then repeated from the first step (the return edge is not drawn). deepset describes the same cycle of run, observe, classify, update and repeat.

Source5 Harness Engineering: How to Build Reliable AI Agents by Engineering the System, Not the Model

Concept

Doing the loop well

  • deepset says tracing makes the loop possible: without structured logs of tool calls, decisions and state changes, classifying failures is guesswork.
  • Böckeler’s rule of thumb: a problem that keeps recurring is a signal to strengthen the controls that steer the agent beforehand and those that check it afterwards.
  • Prefer a structural fix (a tool, a sensor, a hook) to more prompt text, and add a regression check for each fix. Both are this course’s guidance.
  • Trace the versioned prompt, model, tool calls and results, permission decisions, durations, tokens, cost and stop reason. Redact secrets and personal data.
  • Microsoft’s harness documentation (page updated 28 September 2026) says OpenTelemetry observability is enabled by default in its harness.

Sources5 Harness Engineering: How to Build Reliable AI Agents by Engineering the System, Not the Model6 Harness engineering for coding agent users7 Agent Harness

Worked example

Worked example: sample, classify, pick the layer

deepset names these four failure types (context, constraint, verification, planning), each mapped to a kind of fix. Illustrative sample of 40 failed runs:

LayerCountShareExample symptom
Context2152.5%Forgot a naming rule after compaction
Constraint410.0%Edited a file outside its scope
Verification922.5%Reported success; the test runner never ran
Planning615.0%Retried the same failing command in a loop
Total40100%

Fix context first (2140=52.5\dfrac{21}{40} = 52.5 percent). deepset’s mapping for context failures is to change how the agent retrieves information, manages memory and structures what it sees. A structural version: reload the rules file and the progress file at the start of every session and after each compaction, instead of hoping the model remembers. Add a regression task that reproduces the forgotten rule, re-run the held-out set, and keep the change only if the total improves and no previously passing task fails.

Source5 Harness Engineering: How to Build Reliable AI Agents by Engineering the System, Not the Model

Check yourself

Check: read the tally

A sample of 30 failed runs shows: context 6, constraint 3, verification 5, planning 16. Which layer do you fix first, and what kind of fix fits it?

Answer

Planning: 16 of 30 is about 53 percent. deepset’s mapping for planning failures is in orchestration: split the task into smaller steps, delegate, or add loop detection that makes the agent rethink after repeated failures. Make that structural, for example repeated-call detection with a step limit and an escalate rule, then add a regression task that reproduces the loop and re-run the held-out tasks to keep or revert.

Source5 Harness Engineering: How to Build Reliable AI Agents by Engineering the System, Not the Model

Diagram

When the model changes, test the harness

Diagram: A new model triggers a re-baseline on the held-out tasks before anything else is touched.

yes

no

New model

Re-baseline held-out tasks

Ablate components one at a time

Still helps?

Keep, tied to its failure

Remove it, re-test

Diagram summary: A new model triggers a re-baseline on the held-out tasks before anything else is touched. Then each component is removed one at a time. If it still helps, it is kept and tied to the failure it prevents. If not, it is removed and the harness is tested again. Osmani quotes Anthropic that every harness component encodes an assumption about what the model cannot do alone.

Source8 Agent Harness Engineering

Concept

Keeping it healthy

  • Re-baseline on every model upgrade, before changing anything.
  • Tie every rule to the failure it prevents, so you can remove it when that failure stops occurring. Delete what you cannot justify, then re-test.
  • Prune contradictions between guides and sensors.
  • Version the harness as code: prompts, tool schemas, hooks and policies, reviewed in diffs and rolled out gradually.
  • A sensor that never fires may mean quality or blindness. Böckeler leaves this as an open question and suggests coverage ideas like those from mutation testing. Seeding a known fault and seeing whether anything catches it is one practical test.

Source6 Harness engineering for coding agent users

Worked example

Worked example: ablating after an upgrade

Illustrative held-out results (30 tasks, 5 trials each, 150 trials per variant; percentages rounded) after moving to a new model, harness unchanged. The baseline row is the harness as it stands.

VariantSuccess (rounded)Steps per taskCost per resolved task
Baseline, new model61%341.80 dollars
Without the extra planning step61%291.52 dollars
Without the automatic retry wrapper60%311.70 dollars
Without pruning of old tool results49%362.35 dollars

Reading it: the planning step buys no success on this model and adds steps, so it is a candidate to remove and re-test. The retry wrapper’s one-point difference is within what 150 trials per variant can blur, so run more before acting. Pruning clearly earns its place: success falls by 12 points without it. Cost per resolved task is attempt cost over success rate, as before; the attempt costs themselves are not shown.

Check yourself

Check: a clean-up spree

On the day a new model arrives, a team deletes half its hooks and rules because “the new model is smarter”. A week later unrelated regressions appear. Which parts of the method did they skip?

Answer

They did not re-baseline first, so they had no number to compare against. They removed many components at once, so they cannot tell which removal caused which regression. Nor did they test on held-out tasks. The method is to re-baseline, ablate one component at a time, keep what still helps tied to its failure, and roll out gradually. Components can be removed, but only on evidence.

Compare

Operating an agent: the controls

AspectControlWhy
FailureCheckpoint and resume; idempotent tools with keys for side effectsA retry must not repeat a side effect
SpendBudgets and timeouts per tool and per run; circuit breakersA loop must not run up a bill unattended
StoppingKill switchSomeone can end a run now
UndoRollback fitted to the change: version control, snapshots or transactions, feature flagsReversal differs by what was changed
DependenciesGraceful degradation: stop and escalate when the verifier or a tool is downNever carry on unverified
ResponseA runbook: disable, revoke credentials, replay, auditIncidents need steps written in advance

Anthropic’s research system resumes from where an error occurred and uses rainbow deployments, which shift traffic gradually so running agents are not disrupted. Stripe’s API accepts an idempotency key so a retried request does not perform the same operation twice.

Sources3 How we built our multi-agent research system9 Idempotent requests

Concept

Retries and side effects

  • An agent that retries a tool call after a timeout may repeat the action if the first call actually succeeded.
  • A client-generated idempotency key lets the server recognise the retry. Stripe’s API v1 saves the first result for a key and returns it on retry.
  • Stripe compares the retry’s parameters to the original and errors if they differ; its v1 keys can be pruned after at least 24 hours.
  • Lesson for tool design: give state-changing tools an idempotency key, and have the harness reuse the same key when it retries.
  • Every incident should end in a new guide, sensor or hook: the ratchet from the first lesson.

Source9 Idempotent requests

Code

Limits as code: a run guard

Python

class RunGuard:
    """Costs are integer cents, so ten 10-cent steps are exactly 100."""
    def __init__(self, max_steps, max_cents, kill_switch=lambda: False):
        self.max_steps, self.max_cents, self.kill_switch = max_steps, max_cents, kill_switch
        self.steps, self.cents = 0, 0

    def before_step(self, verifier_up, est_next_cents):
        if self.kill_switch():                              return ("stop", "kill switch")
        if self.steps >= self.max_steps:                    return ("stop", "step budget used")
        if self.cents + est_next_cents > self.max_cents:    return ("stop", "next step would exceed budget")
        if not verifier_up:                                 return ("escalate", "verifier unavailable")
        return None                                         # safe to take the next step

    def record(self, cents):
        self.steps += 1
        self.cents += cents

Test runs, with a loop that calls before_step and then record:

CaseResult
20-step cap, 5 cents per stepstopped after 20 steps, 100 cents
Cap 100 cents, 10 cents per stepstopped after 10 steps at exactly 100 cents
Cap 100 cents, 30 cents per stepstopped after 3 steps at 90 cents, before an overrun
Estimate 10 cents but a step really costs 500one step ran, 500 cents spent against a 100 cap
Kill switch turned on before the 8th stepstopped after 7 steps
Verifier down at its 4th check (up for the first 3)escalated after 3 steps, did not continue
No caps (test limit of 50 iterations)ran all 50; only the test’s own limit ended it

Checking the estimate of the next step keeps the cap honest only if the estimate is. The overshoot is bounded by the cost of the largest single step: a 500-cent step overshoots a 100-cent cap by 400. So put a cap on single-step cost too (timeouts, output limits), and keep the money in integers, because floating-point sums such as repeated 0.10 can land on the wrong side of a cap.

Check yourself

Check: a duplicate email

An agent’s “send invoice” tool times out. The agent retries, and the customer receives two emails. Name two controls that would have prevented the duplicate, and one that helps afterwards.

Answer

Prevent: an idempotency key on the send call, reused on the retry so the server recognises it as the same request, and a checkpoint or status record that shows the send already happened before retrying. Afterwards: the runbook and audit log, which let you see what was sent and replay the session, and a new hook or guard so the incident ends in a permanent control.

Summary

Recap

  • One run proves little: fix the model, change one thing, use the same held-out tasks, run several trials, grade the end state.
  • passk\text{pass}^k measures reliability; cost per resolved task is attempt cost divided by success rate, aggregated over tasks.
  • The loop: run, trace, classify by layer, make a structural fix, add a regression check, re-run, keep or revert.
  • Re-baseline after a model upgrade, tie rules to failures, prune what you cannot justify, and version the harness.
  • Operate with checkpoints, idempotent tools, budgets, a kill switch, rollback, safe degradation and a runbook.

References

References & Sources (1 of 2)

  1. Demystifying evals for AI agents (opens in a new tab)

    Mikaela Grace, Jeremy Hadfield, Rodrigo Olivares, Jiri De Jonghe2026Article

    Used for Multiple trials, grading outcomes over paths, grader types, reading transcripts, the CORE-Bench and git-history examples, pass@k and pass^k definitions, 20 to 50 tasks (9 January 2026).

  2. Writing effective tools for agents — with agents (opens in a new tab)

    Ken Aizawa2025Article

    Used for Used held-out test sets to avoid overfitting to training evaluations (11 September 2025).

  3. How we built our multi-agent research system (opens in a new tab)

    Jeremy Hadfield, Barry Zhang, Kenneth Lien, Florian Scholz, et al.2025Article

    Used for Started with about 20 real queries, checkpoint-based resume, and rainbow deployments (13 June 2025).

  4. τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains (opens in a new tab)

    Shunyu Yao, Noah Shinn, Pedram Razavi, Karthik Narasimhan2024Preprint

    Used for Proposes the pass^k metric to evaluate reliability over multiple trials.

  5. Harness Engineering: How to Build Reliable AI Agents by Engineering the System, Not the Model (opens in a new tab)

    deepset2026Article

    Used for Describes the run, observe, classify, update, repeat loop and says tracing makes failure classification possible (21 May 2026).

References

References & Sources (2 of 2)

  1. Harness engineering for coding agent users (opens in a new tab)

    Birgitta Böckeler2026Article

    Used for Improve controls when an issue recurs, and the open question of whether a sensor that never fires signals quality or blindness (2 April 2026).

  2. Agent Harness (opens in a new tab)

    Microsoft Learn (Agent Framework)2026Documentation

    Used for States that its harness enables OpenTelemetry observability by default (page updated 28 September 2026).

  3. Agent Harness Engineering (opens in a new tab)

    Addy Osmani2026Article

    Used for Quotes Anthropic that every harness component encodes an assumption about what the model cannot do alone (15 May 2026).

  4. Idempotent requests (opens in a new tab)

    Stripe2026Documentation

    Used for Idempotency keys let a retried request avoid performing the same operation twice.