Author’s note: put the same model into a different shell, and both what it can do and how much it costs will change. This article is about that shell.
If you’ve already gotten a minimal Agent up and running, you’ve probably hit this confusion: the model didn’t change, the prompt didn’t change much — you just swapped out the outer scheduling code, and the range of tasks it can complete shifted, with the end-of-month bill shifting right along with it. Someone says offhandedly, “just add a Harness and you’re set,” but when you open the docs you see the same handful of words — loop, tools, context, limits — and you can’t tell what any of them has to do with money.
This tutorial does exactly one thing: break the Agent Harness into four visible structures, each mapped to “what it lets your Agent accomplish” and “which line on the bill it moves.” This is not a framework comparison, and it won’t rehash the install steps of any specific product. By the end, you should walk away with one actionable move: open your own request logs and check whether the tool definitions are being fully resent every single round.
Core value: You’ll be able to explain Agent Harness to a colleague in one sentence, and independently judge which part of your own shell burns the most money.

What is an Agent Harness? Think of the model as the master, and the harness as the workshop
The easiest way to understand this is to think of the model as a highly skilled craftsman. The craftsman’s skill is fixed—it doesn’t change after training—but the workshop determines how much work he can actually get done today. The workshop decides which parts are laid out within reach, whether he can reach over and operate the machines himself, whether he needs to ask permission before doing so, and what time he has to wrap up. The same pair of hands in a different workshop produces completely different output.
The harness is that workshop. It’s the layer of software wrapped around the model, responsible for running the conversation loop, executing tools, managing context, and enforcing permissions and limits. The model itself does only one thing: it states clearly “which tool I want to call, and what the parameters are.” That statement is just an intent—the harness first checks whether it’s allowed, then actually executes the tool, then sends the result back to the model so it can see the result and decide the next step. The action happens in the harness, not in the model.
NN/g gave a very intuitive example in an article dated 2026-11-06: two scheduling assistants can share the same model—one can only help you polish the agenda text, while the other can check the calendar, find open slots, and send invitations directly. The gap between them isn’t the model; it’s what the outer shell allows them to do.
| What’s in the workshop | Corresponding Agent Harness component | What happens without it |
|---|---|---|
| Which parts are laid out within the craftsman’s reach | Context management | The model can’t see the tool results from the previous turn, so multi-step tasks can’t connect |
| Whether the craftsman can take action, and on which machine | Tool definition and tool execution | It can only chat and produces no side effects |
| What time to wrap up | Loop termination condition | It keeps re-confirming after the task is done, and the call count climbs for nothing |
| Which operations require asking permission first | Permissions and limits | A single mistaken operation requires manual rework, doubling the cost |
From this we can say: the ceiling on an Agent’s effectiveness is set by the model, but how far it can actually go—and how much it costs to get there—is set by the harness. You have to look at both layers; focusing on only one of them will lead you astray.
The Four Components of an Agent Harness: Each One Maps to a Line on the Bill
There are four: the loop, the tools, the context, and permissions and limits. The order below follows “first make it run, then give it hands, then give it memory, and finally add brakes” — which is also the order most people debug an Agent in when something goes wrong.
The Loop: The Agent Harness Decides When It Should Stop
What it makes possible: A single-turn Q&A only hands you a block of text. Once you add a loop, the model can see the tool result from the previous step and then decide what to look up or change next — only then does a coherent task like “read the file, then change the config, then verify it” become achievable.
Which line on the bill changes: The number of invocations. Every loop iteration is a full model invocation: the input is assembled from the system prompt, tool definitions, and conversation history, and the output is this step’s decision. The number of loop iterations multiplies directly into the number of invocations. If the Harness’s termination condition is written loosely — say, every step has to “confirm once more” before moving on — the bill grows linearly, in the most honest way possible.
Tools: The Agent Harness Determines How Far Its Hands Can Reach
What it enables: The tool list is everything the operator can reach. With only search and file reading, it can do research. Add file writing and command execution, and it can modify code. Add a ticket system, and it can actually close the loop on a problem.
Which line item on the bill changes: the fixed overhead of input tokens. Tool definitions take up input tokens, and the more tools there are, the longer that description becomes in every request round. There’s a common misconception here: many people think only tools that are actually invoked incur costs. In reality, tools that are merely listed in the request, even if never called, are also billed as input tokens. That’s exactly the entry point for the pricing numbers in the next section.
Context: The Agent Harness Determines Which Parts Are Laying on the Workbench
What it enables: The context strategy determines whether it can remember constraints from several rounds earlier. Passing everything in means long tasks are less likely to lose their settings midway. Compressing into a summary or switching to retrieved snippets can support longer tasks, but details may get erased.
Which line item on the bill changes: the rate at which input tokens grow. Historical conversation accumulates with each round, and each round has to resend the accumulated portion again. Whether the harness chooses “full resend” or “rolling summary” determines whether this growth is linear or nearly flat. This is the area most likely to look fine during testing and then suddenly get expensive three days after launch.
Permissions and Limits: The Agent Harness Decides When to Call It a Day
What it lets you build: permissions determine whether you dare to let go. Only when write operations can run automatically can the agent finish a whole workflow unattended; if it’s read-only, you’re permanently stuck at “here’s a recommendation for you.” Limits determine whether you can run things concurrently, and they also set the cost ceiling for a single task.
Which line item on the bill changes: the cost ceiling. Parameters like max output length, max turns, and concurrency caps don’t directly save money, but they decide just how bad the worst case can get. Permissions affect cost through a different path: when a write operation that needs human confirmation gets blocked, what you save isn’t tokens — it’s rework.
| Component | What it lets you build | Which line item on the bill changes | Action you can take right now |
|---|---|---|---|
| Loop | Turns single-turn answers into multi-step tasks | Number of calls | Give the loop an explicit completion check so it doesn’t waste turns re-confirming |
| Tools | Turns talk-only into hands-on | Fixed per-turn input token overhead | Ship tools grouped by task instead of always sending the full set |
| Context | Long tasks don’t lose their constraints | How fast input tokens grow with each turn | Summarize or retrieve long histories instead of resending everything each turn |
| Permissions and limits | Unattended operation with controllable cost | Per-task cost ceiling, rework cost | Set max turns and token caps first, then open up write permissions |

The Agent Harness’s Tool-Definition Cost: A Checklist You Can Run Yourself
Back to the most concrete line item: are tool definitions stuffed in full on every turn?
OpenRouter ran a small test in an article from 2026-12-01. This is their own small-sample observation, not our measured data: with caching off, adding roughly 40 unused tools raised the median cost of a single Haiku session from $0.00082 to $0.00277; with caching on, the median for the 44-tool configuration was $0.00071.
| Configuration | Median cost per session (USD) | What varies |
|---|---|---|
| Few tools, caching off | 0.00082 | Baseline |
| About 40 unused tools added, caching off | 0.00277 | Only the tool definitions get longer |
| 44 tools, caching on | 0.00071 | Repeated content hits the cache |
These numbers point to a direction, not a law. You can’t extrapolate them into “every model costs 3x more when you add 40 tools”—the sample size, the model, and the task length are all specific to their setup. But the direction is worth remembering: tools that never get called still get billed, and tool definitions that repeat still get billed.
Let’s ground this in specific models. Among the models currently listed on APIYI apiyi.com, deepseek-v4-flash has an input price of $0.44 per million tokens and a cache read of $0.01408 per million tokens, and the docs state it uses implicit caching with no configuration needed. 0.01408 versus 0.44—cache reads are about 3% of the input price, more than an order of magnitude cheaper. That means if the same block of tool definitions can hit the cache, the repeated portion gets billed at the cache-read rate, and the input line item shrinks considerably; if it can’t, it’s billed honestly at 0.44.
Put another way, whether the harness organizes tool definitions into a “verbatim-stable, reusable” form is something that converts directly into money. This isn’t an APIYI product feature—it’s a matter of how you construct requests in your own wrapper layer. What APIYI apiyi.com provides is just a unified interface and a checkable pricing basis, so you can work out that difference yourself.
| Model | Input (USD per million tokens) | Cache read (USD per million tokens) | Output (USD per million tokens) | Notes |
|---|---|---|---|---|
| deepseek-v4-flash | 0.44 | 0.01408 | 1.32 | Implicit caching, no configuration |
| glm-5.3 | 1.4 | 0.259 | 4.396 | Text in, text out; context window 1,000,000 |
| claude-opus-5-5 | 4 | 0.2 | 20 | Endpoints split between chat and messages |
Prices and specs were verified on 2026-12-02; refer to the model description pages on APIYI apiyi.com for the latest, since price changes and delistings can happen. One easy pitfall: when switching models, don’t just change the model field—first confirm whether that model uses the chat endpoint or the messages endpoint, or the request will fail at the parameter-validation stage. The master table is at docs.apiyi.com/models.md, and each model has its own separate description page.

Agent Harness Quick Start: Three Steps to Audit Your Tool Definitions
You don’t need to switch frameworks first — just get a clear look at the requests you’re already sending.
Step 1: Split a single round’s input into three parts
Capture a request body you actually sent, mark out the system prompt, the conversation history, and the tools field inside the messages field, and see how many characters each one accounts for. In most cases the tools share is higher than you’d expect, because it’s inherently long and has nothing to do with the task content.
Step 2: Confirm whether the tool definition is byte-for-byte stable
Compare the tools field across two consecutive rounds and check whether they’re character-for-character identical. Only when they’re identical do you meet the precondition for hitting the implicit cache; if even one field order, description string, or default value changes, the cache misses and that block keeps getting billed at the input price.
Step 3: Run the math under both assumptions
Walk through a hypothetical: the tool definition is 2,000 tokens per round, a task runs 20 rounds, so that block totals 40,000 tokens. On a miss, at the input price of $0.44 per million tokens, that’s about $0.0176; on a hit, at the cache-read price of $0.01408 per million tokens, about $0.00056. Neither number is a precise prediction, but the size of the gap is enough to make the point.
Once you’ve done all three steps, you’ll have a pretty good idea whether what needs changing is your tool grouping, your cache friendliness, or your loop’s termination condition. The API base URL is uniformly https://api.apiyi.com/v1; switching models only means changing the model field — but confirm the endpoint type first.
Suggestion: Change just one thing, then test. APIYI (apiyi.com) gives new users free test credits — take the same tool definition, run it on a few models, line up the two numbers “tool definition share” and “cache hit behavior”, and only then decide whether the harness needs a rebuild.
| Check | How to measure | What hitting the cache tells you |
|---|---|---|
tools field share |
character count / total request character count | If it stays above 30% long-term, your tool set needs to be split by task |
| Is the tool definition byte-for-byte stable | compare two consecutive rounds character by character | If it’s unstable, the cache can’t hit, and the repeated portion is all billed at the input price |
| Does the loop have a clear completion condition | count the actual rounds a task takes | If the round count clearly exceeds the necessary steps, you’re paying for spinning in place |
| Is there a max-round and token cap | check request parameters and scheduler config | Without a cap, a single task’s cost has no ceiling |

FAQ
Q1: What exactly is an Agent Harness?
It’s the software layer wrapped around the model, responsible for running the conversation loop, executing tool calls, managing context, and enforcing permissions and quotas. The model only says which tool to call and with what arguments — the actual checks and execution happen inside the Harness.
Q2: Is an Agent Harness the same thing as an Agent framework?
No, they’re not concepts at the same level. A Harness describes “the responsibilities of this layer outside the model,” while a framework is one specific implementation of those responsibilities. Claude Code, Codex, and Hermes Agent can all be treated as examples of Harnesses. It’s also not a product name from APIYI — APIYI apiyi.com provides a unified interface for model access, and the Harness is handled by your own code layer or the tool you choose.
Q3: Which part is most likely to push costs up?
Usually it’s the combination of tools and context. Tool definitions create a fixed input cost every round, and the context strategy determines how much of the history gets resent each round. Loop control governs the multiplier, while tools and context govern the base. When the base is large and you multiply it by the multiplier, the bill doesn’t look pretty.
Q4: Does giving it more tools always make the Agent better?
Not necessarily. More tools do widen the boundary of what it can do, but the description block in each request also gets longer, so the model has to pick from a longer list — and both the chance of picking wrong and the input cost go up. A more common approach is to deliver tools in groups by task stage instead of laying out all of them at once.
Q5: How can I quickly compare costs across different models on APIYI?
Send the same system prompt, the same tool definitions, and the same task to several models. The API root address is always `https://api.apiyi.com/v1` — you only change the model field. Once the runs finish, multiply the input, cache-read, and output figures by their respective unit prices, and you can see how the cost structure of the same Harness differs across models. APIYI apiyi.com supports OpenAI-compatible interfaces, so one Key lets you call multiple mainstream models — perfect for this kind of side-by-side comparison.
Q6: What’s the easiest thing to overlook when switching models?
The endpoint type. Some models go through chat, others through messages — if you only change the model field, you’ll fail outright at the parameter validation stage. The safe approach is to confirm the endpoint on the model description page at APIYI apiyi.com first, then change the code; the full table of all models is available at docs.apiyi.com/models.md.
Q7: What are some easily underestimated limitations of an Agent Harness?
First, caching isn’t a magic bullet — if the content isn’t byte-for-byte identical, it won’t hit. Second, quotas only cap the upper bound; they don’t optimize what happens in the middle. Third, tightening permissions reduces rework, but it also turns “unattended” into “waiting for someone to confirm.” None of these three are bugs — they’re design tradeoffs, and you need to decide based on the shape of your task.
Agent Harness Key Takeaways
- Definition: The harness is the software layer wrapped around the model. The model only produces intent; actions happen inside that shell.
- Loop: Determines when the agent stops, directly affecting the multiplier on invocation count.
- Tools: Determines how far the agent can reach; the tool definitions included in each round’s input are billed by token.
- Context: Determines whether long tasks stay memorable, and also determines how fast input tokens grow.
- Permissions and quotas: Determine whether you dare let go, and where the cost ceiling for a single task lies.
- Checks you can verify: Whether tool definitions are resent in full every round, and whether they’re stable verbatim enough to hit the cache.
- Getting started: First use APIYI apiyi.com’s free quota to compare several models side by side on the same tool definition, then decide whether to refactor the shell.
Summary
The core takeaways of Agent Harness can be boiled down to three points:
- Results are decided jointly by the model and the harness: The model sets the ceiling; the harness determines how far you actually get.
- Cost is decided jointly by four knobs: The loop provides the multiplier, tools provide fixed overhead per round, context provides the growth rate, and quotas provide the upper bound.
- The one thing most worth checking first: Whether tool definitions are stuffed in every round, and whether they’re stable verbatim enough to hit the cache.
If all you have right now is a vague sense that “the bill got more expensive,” starting with tool definitions is the fastest way to see an effect—it’s quantifiable, comparable, and requires the smallest change. I recommend using APIYI apiyi.com to run the same tool definition across several models, calculate the difference clearly, and then make changes.
References
-
OpenRouter – What is an agent harness: Definition of a harness and a small-sample test on how tool count affects cost
- Link:
openrouter.ai/blog/insights/what-is-an-agent-harness/ - Note: This test reflects OpenRouter’s own observations, not a hands-on measurement for this article, and the sample size is limited
- Link:
-
NN/g – Agent harness: Caleb Sponheim, 2026-11-06, a case study of capability differences of the same model under different harnesses
- Link:
www.nngroup.com/articles/agent-harness/ - Note: Uses a side-by-side calendar assistant example to illustrate harness boundaries
- Link:
-
APIYI Model Description – deepseek-v4-flash: Input 0.44, cache read 0.01408, output 1.32, implicit caching with zero configuration
- Link:
docs.apiyi.com/models/deepseek-v4-flash.md - Note: The original source for verifying the price gap between cache reads and regular input
- Link:
-
APIYI Model Description – glm-5.3: Input 1.4, cache read 0.259, output 4.396, context 1,000,000
- Link:
docs.apiyi.com/models/glm-5-3.md - Note: The pricing basis for long-context scenarios
- Link:
-
APIYI Model Directory: Pricing and endpoint information for claude-opus-5-5 and other models
- Link:
docs.apiyi.com/models.md - Note: Confirm whether to route through chat or messages before switching models
- Link:
Author: APIYI Technical Team
Technical discussion: Feel free to reach out to us via the APIYI website homepage; for more resources, visit the docs.apiyi.com documentation center
