Evaluating and operating a harness
- Advanced
- 35 min
- Lesson 6 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:Orchestration, subagents and people in the loop
- Completed:Agent evaluation: state, trajectory, pass^k and release gatesContext, memory and multi-agent systems
- Completed:Observability and eval pipelinesProduction: cost, serving and observability
You will be able to
- Design an experiment that shows whether a harness change helped: one change, the same held-out tasks, several trials and a state-based grader.
- Compute cost per resolved task and say why a pricier attempt can be the cheaper design.
- Run the improvement loop from traces: classify failures by layer, make a structural fix, add a regression check, and keep or revert.
- Re-baseline a harness when the model changes, and prune components that no longer earn their place.
- Operate an agent with budgets, checkpoints, rollbacks, a kill switch and a runbook, and degrade safely when a check is unavailable.
A new routing rule has made tickets close faster than ever this week.
Ananya reads the numbers twice. “Faster than what?” she asks. “And how many came back?”
Vihaan says the rule is working, and then says it again. What would it take to know?
Concept
A harness change feels like an improvement because the next run you look at went well. Agents are stochastic, so one run tells you very little. This lesson is about measuring a harness honestly and keeping it healthy. You already have the building blocks: grading an agent on its final state and comparing with are covered in agent evaluation, and tracing and monitoring in observability and evals. Here they are applied to a specific question, which is whether a change to the harness helped, and to the work of operating one over time.
Why It Matters
A harness gathers components that each encode an assumption, and models change under it. Without measurement you cannot tell which components still help, whether a “fix” made things worse somewhere else, or what each resolved task costs. Teams that cannot answer “how do you know that change helped?” tend to accumulate rules nobody can justify. It is also a common practice topic for agent-engineering interviews (our judgment, not data).
Mental Model
Ananya’s two questions are the whole method. “Faster than what?” asks for a baseline: the same tickets, run the same way, without the new rule. “How many came back?” asks for the outcome that matters, not the speed: the tickets that were resolved correctly. A good experiment holds everything else fixed, changes one thing, counts the right outcome over enough runs to see through the noise, and then looks at the failures, not just the total.
Design the experiment
Anthropic’s post on agent evaluation (9 January 2026) gives the ingredients, and the rest follows from them.
- Grade the outcome. Check the end state, such as tests passing or a record being correct, not that the transcript sounds right. The post says it is often better to grade what the agent produced than the path it took.
- Run multiple trials. Outputs vary between runs, so run each task several times. Reporting a mean and an interval, not one run, is our own advice; the post itself says to run multiple trials.
- Choose grader types on purpose. Code-based graders are fast, cheap and reproducible but can be brittle. Model-based graders are flexible but non-deterministic and need calibrating against people. Human graders are the standard against which the others are calibrated.
- Read transcripts. The post says you will not know your graders work unless you read transcripts and grades from many trials. It describes broken graders that understated performance, and an agent that gained an unfair advantage by reading git history left by earlier trials.
For comparing harness versions, add three rules of your own:
- Change one thing at a time (an ablation). Hold the model fixed and vary a single component: the tool set, the compaction policy, the verifier. To compare models, hold the harness fixed. A harness tuned for one model may not suit another, so re-baseline after a swap.
- Use the same tasks. Split them into a development set you tune on and a held-out set you report on, so the harness is not fitted to the test. Anthropic’s tool-writing post reports relying on held-out test sets for the same reason.
- Seal the environment. Do not let the agent find answers in a repository’s history or on the web if that is not allowed in production.
Start small. Anthropic’s multi-agent write-up describes starting with about 20 queries taken from real use. For agents that change state, they evaluate the end state, not each turn.
Public leaderboards are useful, but gains reported from changing only the harness often come from vendor or practitioner posts without full methodology. Replicate on your own tasks before you believe them.
The numbers that matter
Beyond success rate, a few quantities decide whether a harness is worth running. For reliability, pass^k versus pass@k matters: with a per-task success probability of 0.8 and , and . An agent that usually works can still be unusable for someone who relies on it every time.
Cost per resolved taskCost per resolved taskThe average cost of an attempt divided by the success rate. A pricier attempt that succeeds more often can cost less per result.Open the glossary entry is attempt cost divided by success rate, and it is the figure the business cares about. At 0.80 dollars per attempt and 40 percent success, a resolved task costs 2.00 dollars. After a harness fix that raises the attempt cost to 1.00 dollar and success to 65 percent, it costs about 1.54 dollars. So better success can justify a more expensive attempt, and a cheaper attempt that fails more can cost more per result. The prices here are invented for the arithmetic.
| Aspect | Attempt cost | Success rate | Cost per resolved task |
|---|---|---|---|
| Before the harness fix | $0.80 | 40% | |
| After the harness fix | $1.00 | 65% |
The more expensive attempt is cheaper per result, because it succeeds far more often (the prices are invented for the arithmetic).
When the outcome arrives days later, such as a customer who does not come back, use a proxy that you have shown to track it, and measure the real outcome as it arrives. Track a few more, per task and per tool: steps, tokens and wall time; tool error rate, retries and loops; how often a person had to step in; and safety events such as denied actions. Together they show where to look.
The improvement loop
deepset describes the same cycle: run the agent on real tasks, observe where it fails, classify the failure, update the harness, repeat, and note that tracing makes this possible because classification without structured logs is guesswork. In practice: sample the failures, cluster them by cause, fix the most frequent layer first, add a regression check for each fix, and prefer structural fixes (a tool, a sensor, a hook) to adding prompt text. Be wary of claims about how much this beats a model upgrade; teams report large gains but rarely publish figures.
Trace everything you will want to ask about: the versioned prompts, the model, tool calls and results, permission decisions, durations, tokens, cost and the reason the run stopped. Use a standard format so traces cross agents. Microsoft’s harness documentation notes that its harness enables OpenTelemetry observability by default. Simple log files are a fine start. Redact secrets and personal data, and control who can read the traces. Where possible keep recorded tool results so you can replay a session against a changed harness.
Keeping it healthy when the model changes
Each component assumes something about what the model cannot do. When the model changes, test the assumption.
- Re-baseline on every model upgrade. Run the held-out tasks before touching anything. Some scaffolding becomes unnecessary, and some tool shapes the old model liked may now hurt.
- Tie every rule to a failure and say which one, so that you can remove it when its failing test no longer fails. Delete what you cannot justify, then re-test.
- Prune contradictions between guides and sensors, and ask whether a sensor that never fires means quality or blindness. Böckeler lists that as an open question. One way to find out is to seed a known fault and see whether anything catches it.
- Version the harness as code: prompts, tool schemas, hooks and policies, reviewed in diffs and rolled out gradually.
A typical symptom after an upgrade is flat success and rising cost. The likely causes are old compensations that now only add steps, such as extra verification loops or forced re-reads, so ablate them one at a time.
Operating an agent
An agent that runs unattended needs the controls of any production service, and a few more.
- Checkpoint and resume, with idempotent tools and keys for side effects. Anthropic’s multi-agent system resumes from where an error happened instead of restarting, and combines the model’s own adaptability, such as telling it a tool is failing, with deterministic retries and regular checkpoints. It also describes rainbow deployments, which shift traffic gradually so that running agents are not interrupted.
- Budgets and timeouts per tool and per run, with a kill switch; circuit breakers around flaky dependencies.
- Rollback that suits the thing changed: version control for code, snapshots or transactions for data, feature flags for behaviour.
- Graceful degradation. If the verifier or a tool is down, stop and escalate; do not carry on unverified.
- A runbook covering how to disable the agent, revoke its credentials, replay a session and audit its actions.
- Incident learning: every incident ends in a new guide, sensor or hook. That is the ratchet from the first lesson.
An illustrative evaluation runner
def evaluate(tasks, harness, run_trial, k=5):
rows, total_cost, total_wins = [], 0.0, 0
for t in tasks:
trials = [run_trial(t, harness) for _ in range(k)]
wins = [x["success"] for x in trials]
total_cost += sum(x["cost"] for x in trials)
total_wins += sum(wins)
rows.append({"p_hat": sum(wins) / k, "pass_at_k": any(wins), "pass_hat_k": all(wins)})
n = len(rows)
return {
"mean_p": sum(r["p_hat"] for r in rows) / n,
"pass_at_k": sum(r["pass_at_k"] for r in rows) / n,
"pass_hat_k": sum(r["pass_hat_k"] for r in rows) / n,
"cost_per_resolved": total_cost / total_wins if total_wins else None,
"tasks_never_solved": sum(r["p_hat"] == 0 for r in rows),
}Cost per resolved task is total cost divided by total successes, and tasks that never succeed are counted separately, because a per-task ratio is undefined for a task with no successes, so averaging ratios drops that task and hides what it spent. Run harness A and harness B on the same held-out tasks, put an interval around the difference by resampling tasks, and read the failures behind the scores, including some of the successes.
Real-World Application
An agent that merges small pull requests overnight. Its traces record every tool call, decision and cost, and a dashboard shows success rate, cost per merged change, steps per task, the tools that fail most, how often it escalates and how often it hit its budget. A weekly review samples failures and sorts them by layer, so that the most common one gets a structural fix and a regression check. After a model upgrade the team runs the held-out set first, then removes two verification loops that no longer help. A kill switch stops the agent, a runbook says how to revoke its access, and each incident ends with a new hook.
Interview Perspective
Expect: “How do you know a change to your agent’s harness made it better?” “Define and with an example where they diverge.” “After a model upgrade, success is flat and cost is up 40 percent. Diagnose it.” “Design the observability and runbook for an agent that merges pull requests overnight.”
A strong answer fixes the model, changes one component, uses the same held-out tasks, runs several trials, grades the end state, reports and cost per resolved task, reads failures, adds a regression check and rolls out gradually. Common mistakes: judging by one run or a demo; tuning the harness on the evaluation set; reporting average success without reliability or cost per success; using a model judge as the only signal where a deterministic check exists; keeping stale scaffolding after an upgrade, or deleting it without re-testing; treating a leaderboard gain from a blog post as a fact about your system. A misconception to watch for: “a higher benchmark score means a better production agent.”
Provenance: Common industry pattern. These are typical of agent-engineering interviews; none is verified for a named company.
Practice Questions
- Basic: Define and with an example where they diverge.
- Intermediate: Design an A/B test for adding an independent verifier agent. What do you measure, and what could confound it?
- Advanced: After a model upgrade, success is flat and cost rose 40 percent. Diagnose it.
- Product-Company: Design the observability and the runbook for an agent that merges pull requests overnight.
Activity
Take two versions of a harness (or invent them) and 20 tasks. Write down the experiment: what you fix, the single thing you change, how you split dev and held-out tasks, how many trials, the grader, and the numbers you will report. Then compute cost per resolved task for two made-up cases (for example 1.20 dollars at 50 percent success against 1.80 dollars at 80 percent) and say which design you would run.
Homework
Write a one-page plan for re-baselining your agent after a model upgrade. Include the held-out set, the ablations you will run on existing components and in what order, how you decide to remove a rule, what you watch during a gradual rollout, and the entries you would add to the runbook.
Quick Revision
- One run proves little: fix the model, change one thing, same held-out tasks, several trials, grade the end state.
- measures reliability; cost per resolved task is attempt cost divided by success rate.
- Loop: run, trace, classify by layer, structural fix, regression check, re-run, keep or revert.
- Re-baseline after a model upgrade; tie rules to failures; prune what you cannot justify; version the harness.
- Operate with checkpoints, idempotent tools, budgets, a kill switch, rollback, safe degradation and a runbook.
- Leaderboard gains from posts are claims to replicate, not facts about your system.
Check yourself
- Walk-through: How do you know a change to your agent’s harness made it better?
- Variation: Success is a customer outcome that arrives days later. What do you measure in the meantime?
- Common misconception: “A higher benchmark score means a better production agent.”
Related
Resources & Further Reading
Checked sources to go deeper. The essential ones come first in each group.
Further reading
Your AI Product Needs Evals (opens in a new tab)Essential
A practitioner article on reviewing traces and writing fast assertions that grow as new failures appear, which supports the loop of reading failures and adding regression checks.
Effective context engineering for AI agents (opens in a new tab)
Compaction and context policies are the kind of single component you ablate in a harness experiment; this explains what they do.
Research papers
Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (opens in a new tab)
Reports high agreement between strong model judges and human preferences and examines position, verbosity and self-enhancement biases, so you can judge when a model-based grader needs calibrating.
Hands-on
tau-bench (Code and Data for Tau-Bench) (opens in a new tab)
Code to run a tool-agent benchmark whose leaderboard reports Pass^1 to Pass^4, so you can see pass^k used on a real task set (its README warns it can be expensive to run and that the tasks in this repo are no longer updated, pointing to the τ³-bench repository (sierra-research/tau2-bench) for the latest fixed tasks).
More for this module: Harness engineering resources
Practice
Test what you just read. Quizzes and cards are grouped by module: Harness engineering.
Check yourself10 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.