# Harness engineering: how to test agent changes safely

> Harness engineering is improving an agent by changing the code around the model, one tested change at a time. This guide covers the loop, what to hold fixed, how to version a harness, and the 3 stages a change passes on its way to everyone.

---

## What is harness engineering?

Most of what decides whether an agent finishes a task sits outside the model, so most of the fixes do too.

Harness engineering is the practice of improving an agent by changing its harness instead of its model. The agent harness is the code around the model. It includes the system prompt, the tools and their descriptions, the loop, how context is assembled, and memory. It also includes the checks that run before and after each step. Harness engineering treats each change to those parts like a product release. One change at a time, given a version, tested, measured and rolled out.

This guide covers the loop a change goes through, how it differs from prompt engineering, what to hold fixed while testing, how to version a harness, and the 3 stages a change passes before everyone gets it.

| Approach | What changes | What stays the same |
| --- | --- | --- |
| Prompt engineering | The instructions the model reads | Tools, loop, checks and the model |
| Context engineering | What goes into the context on each turn | Tools, loop and the model |
| Harness engineering | Any part around the model, one at a time, with a version | The model |
| Fine-tuning | The model’s weights | The harness |
| Model swap | The model | The harness, though the prompt often needs rework |

## What are the steps of harness engineering?

Every change runs through the same loop. It starts from a step where tasks stop, not from an idea for a better prompt. It ends with a decision and a line in the change log. Start from [failures you have detected](/blog/ai-agent-failure-detection/), not from guesses.

The running example on this site is the AI assistant inside a CRM. People ask it to “update these contacts from the trade-show list”. The task has 3 steps: find the contacts, update them, log the activity. Of 2,400 attempts, 1,536 finish, which is 64%. The step that loses the most is **update them**: 528 of the 2,308 attempts that reach it stop there.

1. **Find the step.** Pick the step that stops the most attempts. On the CRM agent that is update them, at 22.9%.
2. **Read the stopped attempts.** Open a sample and find the turn where each went wrong. Here it is turn 7: 6 of the 9 emails didn’t match, and `update_contacts` still returned success.
3. **Write a hypothesis.** Name the harness part and the number it should move: “If `update_contacts` returns the skipped contacts with a reason, fewer attempts stop at update them.”
4. **Make one change.** Change that part only, and give the harness a new version.
5. **Test it on recorded conversations.** Run the new version on conversations that already reached the step.
6. **Test it on live traffic.** Give the new version to a small share of people and compare it with the current one.
7. **Roll it out or roll it back.** Move everyone to the version that does better at the step without making another step worse.

The hypothesis is the easiest step to leave out. Written down, it says which number should move and which should stay still. Without it, any movement after the change can be read as a win.

Each pass starts from whatever step now stops the most attempts. After a fix at update them, that may be **log the activity**, because more attempts now reach it.

**Who gets version 14 at each stage** (the CRM agent’s change to `update_contacts`):

| Stage | On version 14 | Compared | Pauses if |
|---|---|---|---|
| Recorded | No one live. Version 14 runs on 528 stopped and 211 finished recorded conversations. | What each version says at turns 7 and 8. | A finished conversation that version 14 now gets wrong. |
| Small share | 7% of people. Everyone else stays on version 13. | Stops at update them, version 14 against version 13. | Tool errors, cost per finished task or friction rise. |
| Half | Half of people, a 50/50 split. | Stops at update them, then the finish rate for the task. | Any rule above, or more stops at log the activity. |
| Everyone | Everyone. Version 13 stays runnable for a rollback. | Stops at update them, against the live test. | Any pause rule sends new conversations back to version 13. |

## How is harness engineering different from prompt engineering?

Prompt engineering is one part of harness engineering. It changes the instructions the model reads. Harness engineering covers the prompt and every other part around the model, and adds the release habits: versions, tests and staged rollouts.

The difference matters because many stops are not prompt problems. On the CRM agent, no wording in the system prompt tells the model which 6 contacts were skipped. Only the tool result can carry that. An instruction such as “always check that every contact was updated” asks the model to check something it cannot see.

| Question | Prompt engineering | Harness engineering |
| --- | --- | --- |
| What changes | The instructions | Prompt, tools, tool results, loop, context, memory, checks |
| Unit of change | A rewrite of the text | One part, under one new version |
| Where it is tested | Usually by hand, on a few examples | On recorded conversations, then on live traffic |
| What is measured | Whether replies read better | Stops at the targeted step, then the finish rate |
| How it is undone | Edit the text back | Switch new conversations to the old version |

A prompt change still belongs in the loop. It gets a version, a hypothesis and a test like any other part. What harness engineering adds is a question asked before any edit: which part let the failing turn happen? The [symptom-to-harness map](https://tryabracadabra.com/blog/symptom-to-harness-component/) runs that question from the sentence in the chat.

## What should you keep fixed while testing a change?

A test compares 2 versions that differ in one part. Anything else that changes during the test lands in the result and cannot be separated out. Some of those changes are easy to miss, because they happen outside the harness code. Loop limits belong on that list; see [how to stop an agent from looping](/blog/agent-loop-design/).

- **The model and its settings.** Pin the exact model version and the temperature. A provider moving a model alias to a newer model changes every step at once.
- **The other parts of the harness.** No prompt edits, new tools or loop changes ship to either version while the test runs.
- **The systems behind the tools.** The CRM’s own matching rules can change. If email matching changes mid-test, stops at update them move for reasons unrelated to the change.
- **The traffic mix.** Both versions should see the same kinds of people and tasks. Assign people at random, so one version does not get all the enterprise accounts.
- **Prices.** Compare cost per task at the same token prices. Otherwise a price change looks like a harness change.

| Part | Hold it at | Why it matters here |
| --- | --- | --- |
| Model | The same pinned version on both | A model change moves all 3 steps |
| System prompt | The text from version 13 | Keeps the tool result as the only change |
| `find_contacts` and `log_activity` | Unchanged | Changes at the other 2 steps would mix in |
| Loop limits | The same maximum tool calls per task | A higher cap alone could let the agent retry |
| Assignment | By person, for the whole test | A person who sees both versions muddies both |

Sometimes something on this list has to change mid-test, such as an urgent fix to the CRM. Note it in the change log with when it shipped. Then compare the versions only on conversations from before it, or restart the test.

## How do you version an agent harness?

A version is a name for one complete harness: every part, as it stood. Each conversation carries the version that served it. Then any count can be split by version later, including counts nobody planned when the change shipped.

Version the whole harness, not each part. A number per tool and per prompt looks tidier, but a conversation is served by a combination of them. One number for the combination makes every comparison a single filter.

```json
{
  "version": 14,
  "previous": 13,
  "part": "tool result: update_contacts",
  "change": "Return skipped contacts with a reason; mark the step partial",
  "step": "update them",
  "hypothesis": "Fewer attempts stop at update them; log the activity holds its rate",
  "held_fixed": ["model", "system prompt", "find_contacts", "log_activity", "loop limits"],
  "pause_if": ["tool errors rise at update them", "cost per finished task rises", "friction turns rise"],
  "status": "live, small share"
}
```

- **Tag at the first turn.** Record the version when the conversation starts and keep it to the end, even if a new version ships meanwhile.
- **Keep the old version runnable.** Rolling back means switching which version serves new conversations. That only works if version 13 can still run.
- **Keep settings out of the deploy.** Prompts, tool descriptions and loop limits held as configuration can switch without a code release. Changes to tool code still need one.
- **Write the entry before the test.** The hypothesis and pause rules come first, so the result is read against them rather than fitted to them.

With the version on every conversation, stops at each step can be split by version. Cost and friction can be split the same way. abracadabra reads each conversation, labels its task, and shows the step where it stopped.

## How do you test a change on recorded conversations? (Stage 1)

The first test uses no live traffic. Take conversations that already happened, run the new version on them up to the step, and read what it does differently. It is cheap, and it catches a change that breaks something before anyone meets it. Turn each failure you find into an [eval](/blog/what-is-an-eval/) so it stays fixed.

Build the set from groups that answer different questions. Stopped attempts show whether the change helps. Finished attempts show whether it breaks anything that worked.

| Group | Taken from | What it checks |
| --- | --- | --- |
| Stopped at update them | The 528 attempts that stopped there | Does version 14 name the skipped contacts and offer a next move? |
| Finished the task | A sample of the 1,536 that finished, such as 211 | Does version 14 still finish them, with no new turns? |
| Stopped at log the activity | The 244 that stopped there | Does the change alter what reaches the next step? |

Replay has a limit. A recorded conversation holds the person’s replies to the old version. Once version 14 says something different at turn 7, the person’s turn 9 no longer follows from it. Replay is reliable up to the first turn that changes, and a guess after it.

- **Replay to the step, then stop.** Compare what each version says at the first turn where they differ. On the CRM agent that is turns 7 and 8.
- **Keep replays away from live data.** Run the tools against a copy of the CRM, or feed back recorded results. A replay must never write to real contacts.
- **Read before counting.** Open a few dozen replays by hand before computing any rate. A reply that names the 6 skipped contacts in a confusing way is not yet a fix.
- **Keep the set.** Stopped attempts that version 14 still fails become test cases for version 15.

Replay says whether the change does what the hypothesis says on known cases. It cannot say how people respond to the new reply. That takes live traffic.

## How do you test on a small share of live traffic? (Stage 2)

The second stage gives version 14 to a small share of people and keeps everyone else on version 13. Comparing the 2 over the same period is an A/B test. The guide to A/B tests covers sample sizes and how long a test needs to run. If you are not ready to show people the new version, run it as a [shadow test](/blog/shadow-testing-ai-agents/) first.

Assign by person, not by conversation. If a person meets version 14 on one task and version 13 on the next, they see 2 behaviours. Their turns then stop being evidence for either.

Start small. A first share such as 7% of people limits how many meet a bad change. It still shows tool errors and obvious breakage early, because those appear on almost every attempt that hits them.

Set pause rules before the share opens. A pause rule is a line that sends new conversations back to version 13 the moment it is crossed, without a meeting. For a harness change, watch the signals that show up fast.

- **Tool errors at the step.** Errors from `update_contacts` on version 14 above the rate on version 13.
- **Cost per task.** A lookup by name adds tool calls. A clear rise in cost per finished task pauses the test while someone reads why.
- **Friction.** Rephrasing, corrections, retries, and turns like “Where are the rest? Can you try that again?” A rise means the change confuses people, even if more tasks finish.
- **Stops at the next step.** If log the activity starts losing more attempts, the problem may have moved rather than gone.

The decision rests on the step first, then the task. Version 14 should stop fewer attempts at update them, and the finish rate should follow. As an example, not a measured result: halving the stops at update them, from 528 to 264, would take the task from 64% to 75%.

## How do you roll out a change, or roll it back? (Stage 3)

When version 14 holds its gain at the step and trips no pause rule, widen the share. A common path is a small share, then half of people, then everyone. Each widening can show a problem that only appears at volume, such as rate limits on a lookup by name.

Rolling back is the same switch in reverse. New conversations go to version 13 again, and conversations already running finish on the version they started with. Because both versions stayed runnable, a rollback is a settings change, not a release.

- **Close the entry.** Record the decision, the final numbers at the step, and anything that surprised the team.
- **Retire the old version later.** Keep version 13 runnable until version 14 has served everyone for a while with no pause.
- **Look at the next step.** More attempts now reach log the activity. Its stop rate is the next candidate for the loop.
- **Grow the replay set.** Conversations that still stop at update them under version 14 become cases for the next test.

A rollback is the process working. The change met real people, a number crossed its line, and nobody had to argue about what to do next.

## Who does what in harness engineering

Harness engineering crosses roles. The engineer owns the code. The product lead owns the decision about what people get. The loop runs best when each knows which steps are theirs.

| Step | Product lead | Engineer |
| --- | --- | --- |
| Find the step | Picks the step and reads stopped attempts | Pulls the conversations and tool logs |
| Hypothesis | Writes what should move | Names the part that can move it |
| Change | Reviews the new behaviour on examples | Builds the change and the new version |
| Recorded conversations | Reads replays at the turn that differs | Runs the replay away from live data |
| Live share | Sets the share and the pause rules | Wires assignment and version tags |
| Rollout | Widens the share or rolls back | Keeps old versions runnable |

Run one test per step at a time. 2 changes to the update step on overlapping people cannot be told apart. Changes to different steps can run side by side, but read the later step with care, since a fix earlier sends it more attempts.

## When is harness engineering overkill?

Harness engineering assumes the model can do the task once the code around it is right. That holds for many stops, not all of them.

- **The model cannot do the task.** If replays show the model misreading clear, complete results, no harness change fixes that. Try another model, and test the swap the same way.
- **The data is wrong.** On the CRM agent, 6 of 9 emails don’t match. If the trade-show list has typos, a better tool result reports the problem clearly but cannot make the contacts match. Fixing the data may matter more.
- **Traffic is too low.** A live test needs enough attempts at the step to tell versions apart. With few attempts a week, rely on replay and reading, and accept more doubt.
- **The fix is a plain bug.** A tool that crashes on a missing field needs fixing, not an experiment. Ship it, give it a version, and note it in the change log.
- **The question is a product decision.** Whether the agent should touch existing customers at all is a choice for the team, not a test result.
- **The reply is harmful.** A version that gives unsafe or wrong answers is rolled back first and studied afterwards.

## Common questions about harness engineering

### What is harness engineering?

Harness engineering is improving an AI agent by changing the code around the model rather than the model itself: the prompt, tools, tool results, loop, context, memory and checks. Each change is made one at a time, given a version, tested and rolled out like a product release.

### Is harness engineering the same as prompt engineering?

No. Prompt engineering changes the instructions the model reads, which is one part of the harness. Harness engineering covers every part around the model and adds versions, tests and staged rollouts.

### How do you test a change to an AI agent before release?

Run the new version on recorded conversations that reached the step it targets, including some that finished, and read what changes. Then give it to a small share of people, compare it with the current version, and widen the share if no pause rule is crossed.

### What should an agent harness version include?

One version number for the whole harness: prompt, tool descriptions and code, loop limits, context rules and checks as they stood. Tag every conversation with it at the first turn, and keep a change log entry with the part changed, the hypothesis and the pause rules.

### How do you roll back a change to an AI agent?

Switch new conversations back to the previous version and let running ones finish on the version they started with. This needs no release when the old version stays runnable and its prompts and settings live in configuration.

## Related guides

- [What is an agent harness? The parts you can change without retraining](https://tryabracadabra.com/blog/what-is-an-agent-harness/): The 7 parts this guide versions and tests, and which step each one touches.
- [A/B testing AI agents: how to compare two versions on live traffic](https://tryabracadabra.com/blog/ab-testing-ai-agents/): Splitting people between 2 versions, and how many attempts a test needs.
- [Shadow testing an AI agent: try a change on real traffic with nobody affected](https://tryabracadabra.com/blog/shadow-testing-ai-agents/): A step between replay and a live share: the new version on copies of live requests, writes stubbed.
- [What is an eval? AI evals explained for product managers](https://tryabracadabra.com/blog/what-is-an-eval/): Checking a change on fixed test cases before it meets live traffic.
- [How to measure AI agent performance in production](https://tryabracadabra.com/blog/how-to-measure-ai-agent-performance/): Counting where tasks stop, the number every harness test is read against.
- [Which part of the agent is failing? Symptom-to-harness map](https://tryabracadabra.com/blog/symptom-to-harness-component/): From the sentence in the chat to the one harness part a change should touch.
