all posts

What is an agent harness? The parts you can change

An agent harness is the code around a model that turns it into an agent. This guide covers its 7 parts, how they run one task, which part each step of a real task depends on, and how to change one part at a time.

Guide 11 min read Updated
“Update these contacts from the trade-show list.”
Step that stopsupdate them: 528 of 2,308
Harness partHow the update_contacts result is read
One changeReturn skipped contacts with a reason

The model stays the same, and one part of the harness changes.

What an agent harness is

Most of what decides whether an agent finishes a task sits outside the model, and a team can change all of it without retraining anything.

An agent harness is everything around the model that turns it into an agent. It holds the instructions, the tools and their descriptions, and the loop that decides when to call a tool and when to stop. It also holds the way context is assembled and trimmed, memory between conversations, sub-agents, and the checks that run before and after each step. The model predicts the next piece of text. The harness decides what the model sees, what it can do, and when its work counts as done.

“Harness” here means the code around a model. Some people also use the word for command-line coding agents. That is a different thing, and this guide is not about it.

This guide covers how a harness runs one task, its 7 parts, and which part each step of a real task depends on. It explains why harness changes often move results more than model swaps, and how to change one part safely. It also covers how to tell whether it worked, and when the harness is the wrong place to look.

PartThe modelThe harness
Who builds itA model providerThe team that runs the agent
How it changesSwap it for another, or wait for a new releaseEdit code, prompts, tool definitions and settings
What a change touchesEvery step of every task at onceUsually one step, or one kind of step
What a change costsOften a different price per tokenEngineering time, and sometimes a few more tool calls
Who can read itNobody outside the providerAnyone on the team with access to the repo

How does a harness run one task?

The example agent for this guide lives inside a CRM. People on sales teams ask it to do things in the CRM for them. One common task is “update these contacts from the trade-show list”. It has 3 steps: find the contacts, update them, log the activity.

When the person says “Great, go ahead” at turn 5, the model does not touch the CRM. The harness does. Each pass through the loop looks like this:

  1. Assemble the context. The harness puts the instructions, the tool descriptions, the conversation so far and anything from memory into one request.
  2. Call the model. The model replies with text for the person, or with a request to call a tool such as update_contacts with 9 contacts.
  3. Run the tool. The harness calls the CRM, waits for the result, and decides how much of that result goes back to the model.
  4. Run the checks. Code the team wrote looks at the tool call, the result or the draft reply, and can block, change or flag it.
  5. Loop or stop. The harness decides whether to call the model again, ask the person something, or end the turn.

On this task the loop goes wrong at the third pass. update_contacts takes all 9 contacts in 1 call. It updates 3, skips the 6 whose emails don’t match, and returns success. At turn 7 the agent passes on the mismatch and carries on with the other 3. The result says success, so the loop treats the step as finished. At turn 8 the agent says “Done. 3 contacts updated and logged.” At turn 9 the person asks, “Where are the rest? Can you try that again?”

Nothing in that sequence is a model failure in the usual sense. The model did what the result told it. The harness decided that a partial update counted as success, that nothing needed checking, and that the loop could stop.

What are the seven parts of an agent harness?

Every harness has some version of these parts, whether a team wrote them by hand or took them from a framework. Some are a single line of configuration. Others are most of the codebase.

Harness partWhat it controlsExample change on the CRM agent
InstructionsWhat the agent is for, how it speaks, what it must never do“When an email doesn’t match, look the contact up by name before skipping it”
Tools and descriptionsWhat the agent can do, and when the model thinks each tool appliesupdate_contacts returns the skipped contacts with a reason, not just success
The loopHow many passes a task gets, and what ends itRetry a skipped write once before reporting back
ContextWhat the model sees on each pass, and what is cut when it gets longKeep the original 9-contact list in context until the task ends
MemoryWhat carries over between conversationsRemember which list the person imported last, so “the rest” has a meaning
Sub-agentsWhich pieces of work go to a separate model call with its own instructionsHand the name lookup for unmatched contacts to a small matching agent
ChecksCode that runs before and after each step and can stop itBefore the agent replies, compare contacts requested with contacts updated
  • Instructions. The system prompt and any rules added per task. They set behaviour the model cannot infer, such as asking whether “the trade-show list” means new leads only.
  • Tools and descriptions. A tool is a function the agent can call. Its description is the text the model reads to decide when to call it. Its result is what the model learns about the world. All 3 are harness, and the result is the one teams forget.
  • The loop. The control flow that alternates model calls and tool calls. It sets the stopping rule, the retry rule, and the most passes a task can take. How to choose those stops, and how to catch a repeated call, is covered in agent loop design.
  • Context. The assembly of each request. Long conversations need trimming or summarising, and whatever is cut is gone from the model’s view.
  • Memory. Anything stored outside a single conversation and loaded back in. It can be a few facts about the person or a searchable store.
  • Sub-agents. Separate model calls with narrower instructions and tools. They keep the main context small and give one hard step its own setup.
  • Checks. Middleware that inspects inputs, tool calls, results and replies. A check can block an action, rewrite a reply, or flag the conversation.

Those parts are listed from inside the harness. The other direction, from a sentence the person said back to the part, is the symptom-to-harness map.

Which part does each step depend on?

The trade-show update finishes in 1,536 of 2,400 attempts, 64%. The 864 attempts that stop are spread across the 3 steps unevenly, and each step leans on different parts of the harness.

StepStopped hereHarness parts it depends onWhere to look first
find the contacts92 of 2,400, 3.8%Instructions, find_contacts and its descriptionThe clarifying question at turn 2
update them528 of 2,308, 22.9%update_contacts, how its result is read, the loop, checksThe result at turn 7 that says success
log the activity244 of 1,780, 13.7%log_activity, checks on the final reply, instructionsThe reply at turn 8 that says done
  • find the contacts. This step works most of the time. It depends on the instructions telling the agent to ask whether existing customers count, which it does at turn 2. It also depends on find_contacts returning the 9 contacts at turn 4.
  • update them. This is the biggest count and the worst rate. It depends on update_contacts and on how its result is read. A result of success with 6 rows skipped tells the model the step is done. No instruction says to look the 6 up another way, and no loop rule or check catches the gap.
  • log the activity. This step depends on log_activity and on what the agent is allowed to say when it finishes. The reply at turn 8 reports 3 contacts as the whole job, so the person asks again at turn 9.

Pick a part below to see which steps and turns it touches. Most parts matter at one step. The tool result, the loop and the checks all meet at update them, which is why that step is the place to start.

  1. find the contacts92 of 2,400 stop

    find_contacts returns the 9 contacts.

  2. update them528 of 2,308 stop

    update_contacts skips 6 and still returns success.

  3. log the activity244 of 1,780 stop

    log_activity records the 3 that were updated, and nothing about the 6.

Turns
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  • Turn 4, agent “Found 9 contacts.”
  • Turn 7, agent “6 of the 9 emails didn’t match. Updating the other 3.”
  • Turn 8, agent “Done. 3 contacts updated and logged.”

Example changeupdate_contacts returns the skipped contacts with a reason, not just success.

The running example on this site. Stop counts are attempts reaching each step and stopping there.

Why change the harness before you switch models?

When an agent stops short, the first instinct is often a larger model. For most teams, the harness is the better first place to look. The reasons are about where failures come from, not about any one model. A model swap also changes your bill; see how AI API pricing works.

  • The model only knows what the harness shows it. At update them, the result says success while 6 of 9 contacts were skipped. A stronger model reads the same success. Until the result says the step is incomplete, and names the contacts, any model has reason to move on.
  • A harness change is local. Returning skipped contacts changes 1 step. A model swap changes every step of every task, including the ones that already work, such as find the contacts at 3.8% stops.
  • A harness change is cheap to undo. It is a commit, a prompt version or a setting. Rolling back a model swap can mean re-tuning prompts that were written for the old model.
  • A harness change names its own test. “Fewer stops on update them” is a test anyone can read. “The new model is better” has no step to check.
  • The harness is the part a team owns. Providers ship new models on their own schedule. The harness changes whenever the team decides it should.

A model swap is still the right move sometimes. If the agent misreads clear requests, picks the wrong tool when the descriptions are good, or fails at a skill such as a language, the model is the limit. The test is simple: if the right information was in front of the model and it still chose badly, look at the model. If the information was missing, look at the harness.

How do you change one part of a harness at a time?

A harness has many parts, and they interact. Changing 2 at once means a better result cannot say which one did it. One part, one step, one change. Try the new part first as a shadow test, so nobody sees its replies.

  1. Name the step. Start from where tasks stop. On the CRM agent that is update them, with 528 of 2,308 attempts stopping there.
  2. Read the conversations. Open a sample of attempts that stopped at that step and find the turn where each went wrong. Here it is turn 7, the skipped contacts.
  3. Name the part. Decide which harness part let that turn happen. Here it is the tool result, which said success.
  4. Make the smallest change. Change that part and nothing else. Keep the model, the instructions and the other tools the same.
  5. Give the harness a version. Record what changed and tag every conversation with the harness version that served it.
  6. Test it. Run the new version on recorded conversations first, then on a share of live traffic before everyone gets it.

For the CRM agent, the change is in what update_contacts hands back. The tool already knows which contacts it skipped. Its result never said the step was incomplete, or which contacts were left.

The update_contacts result, before and after

// Before: success, with a count. The agent mentions the 6 and moves on.
{"status": "success", "updated": 3, "unmatched": 6}

// After: the step is marked incomplete, with each skipped contact and why.
{
  "status": "partial",
  "updated": 3,
  "skipped": [
    {"email": "lead1@example.com", "reason": "no contact with this email"},
    {"email": "lead2@example.com", "reason": "no contact with this email"}
  ]
}

A check can back the change up. Before the agent replies, it compares the contacts the person asked for with the contacts that were updated or skipped. If they do not add up, or anything was skipped, the agent says so instead of reporting the job as done.

A check that runs before the agent replies

def check_update(requested: list[dict], result: dict) -> str | None:
    """Return a note for the model, or None if the update is complete."""
    skipped = result.get("skipped", [])
    if len(requested) != result["updated"] + len(skipped):
        return "The counts don't add up. Tell the person the update is incomplete."
    if skipped:
        return (
            f"{len(skipped)} of {len(requested)} contacts were skipped. "
            "Name them, give the reason, and offer to look them up by name."
        )
    return None

Tag the conversation with the version as metadata, such as harness_version: 14, with a one-line change note kept in the repo. Every later count can then be split by version, including counts nobody planned. Testing the new version on live traffic is an A/B test. The guide to A/B testing AI agents covers how to split people and how many attempts it takes.

How do you know a harness change worked?

Measure the step the change was aimed at, then the task. A change to update_contacts should move stops on update them first. If it does, the finish rate for the whole task should follow. An eval built from a real failure is the fastest check. Compare the task completion rate for the same task before and after the change.

Here is a worked example, not a measured result. Suppose the new result and the check halve the stops on update them, from 528 to 264. Then 264 more attempts finish, and the task moves from 64% to 75%.

Harness versionAttemptsStopped on update themFinishedRate
Current2,4005281,53664%
Skipped contacts returned2,4002641,80075%
  • The targeted step. Stops on update them, as a count and as a rate of attempts that reach it.
  • The next step. With fewer stops at update them, more attempts arrive at log the activity. If its stop rate rises, the fix moved the problem down the line.
  • Turns per task. A lookup by name adds a turn or a tool call. Check the task still takes a reasonable number of turns.
  • Cost per task. Extra tool calls and longer context cost money. Compare cost per finished task, not per conversation.
  • Dissatisfaction turns. Complaints like the one at turn 9 should fall. If they do not, read why.

A rate says whether the change helped. The conversations say why, and whether the reason will hold. Open some attempts that still stop on update them under the new version. If the stops are now a new kind, such as the wrong contact matched by name, that is the next change. Here, abracadabra reads each conversation, labels its task, and shows the step where it stopped.

When is the harness not the problem?

  • The model lacks the skill. If the right information was in context and the model still chose badly, a harness change can only work around it. Test a different model on the same step.
  • The data is wrong. If the trade-show list has misspelt emails, a name lookup helps, but the cause sits upstream. Fix the import, not only the agent.
  • The harness is not yours. On a hosted agent platform, the loop, context handling and memory may belong to the provider. The parts left to change are usually instructions, tools and checks.
  • Too few attempts to tell. A step that sees 37 attempts a month will not show a reliable change in its rate. Read every conversation instead, and accept weaker evidence.
  • Several changes at once. A release that changes instructions, a tool and the loop together can improve the rate while nobody knows why. The next regression will be just as hard to trace.
  • Checks that hide problems. A check that rewrites every bad reply into a polite one makes the conversation look fine and the task no closer to done. Checks should stop or flag, not paper over.

Common questions about agent harnesses

What is an agent harness?

It is the code a team wraps around a model so the model can act on a task. It covers everything from the prompt and tool descriptions to the stop rule. Each piece can change without retraining the model, and the section on the parts of a harness above takes them one at a time.

What is the difference between an agent harness and an agent framework?

A framework is a library for building harnesses, with ready-made loops, tool interfaces and memory stores. The harness is the specific assembly a team runs for one agent: its prompts, its tools, its rules. Two teams on the same framework have different harnesses.

Is the system prompt part of the harness?

Yes. The system prompt is one part of the harness, alongside tools, the loop, context, memory, sub-agents and checks. Prompt changes are the most common harness change, but often not the one a failing step needs.

Do you need to retrain a model to improve an agent?

Usually not. Most fixes change what the model sees or what the harness does with its output. Examples are a clearer tool result, a retry rule, or a check before the reply. Retraining is worth it only when the model lacks a skill the harness cannot supply.

What is harness engineering?

Harness engineering is improving an agent by changing its harness rather than its model, one part at a time. Each change is tested and measured like a product release, on the step it was meant to fix.

all posts

Read how a harness change affects each task.

Abracadabra shows which tasks finish after the change and the turns where the rest stop.