WRAITHERIX
Home / Blog
Explainer · tested 2026-12-02

What is an agent harness? We built one in 150 lines and measured it

WRAITHERIX team
A glowing model core inside a circuit of modules for the loop, tools, permissions and limits

A language model takes text in and returns text. It cannot open a file, run a test or remember what it did a minute ago. The program around it does all of that, and that program is the harness.

Claude Code, Codex, Cursor and Cline are harnesses. Two of them can run the same model and still give you different results and a different bill. To see where those differences come from, we wrote a harness of our own: one Python file, about 150 lines, no dependencies. Then we ran it on three models through WRAITHERIX and pulled the cost of every step from the gateway's billing log.

The short version

The test project

A tiny Python project: total() adds up an order and applies a percentage discount, but treats 10% as 1000%, so one of two tests fails. The instruction to the agent was one line: "The test for the discount fails. Fix it."

The harness gives the model five tools:

Tool What it does
list_files lists files in the project folder
read_file returns a file's content
write_file overwrites a file
run_tests runs pytest and returns the output
run_shell runs a command, but only from an allow-list

Job 1: the loop

Here is the full run with gpt-5.4-mini, step by step:

Step Input tokens Model asked for Harness returned
1 256 list_files prices.py, test_prices.py
2 286 read_file × 2 both files
3 509 write_file file rewritten, discount divided by 100
4 628 run_tests 2 passed
5 667 nothing, plain text "Fixed the discount calculation and confirmed all tests pass."

What the model actually returns at step 2 is not an action, just a request:

{"tool_calls": [
  {"name": "read_file", "args": "{\"path\": \"prices.py\"}"},
  {"name": "read_file", "args": "{\"path\": \"test_prices.py\"}"}
]}

The harness checks that the tool exists and the path stays inside the project, reads the files and sends their content back as the next message.

Notice the input column. Every request carries the whole history, so it grows from 256 to 667 tokens over five steps. Total for the task: 2,346 input tokens, 189 output, $0.0023.

Job 2: tools, and what they cost you

The model only knows a tool from the description the harness attaches to each request. That has a direct consequence: connect your agent to email, calendar, a database and a dozen other services, and all of their descriptions ride along on every single step, even when the task is one Python function.

We measured it. Same harness, same task, same model, but with 40 extra tools added (create issue, read inbox, query database and so on). Each setup ran three times.

5 tools 45 tools
Input tokens per task 2,346 13,576
Extra tokens per request 0 about 2,250
Cost, first run $0.0023 $0.0040
Cost, runs 2 and 3 $0.0023 $0.0024
Task solved 3 of 3 3 of 3

The model never called any of the extra tools and finished in the same five steps. All of the extra cost came from re-reading tool descriptions.

Runs 2 and 3 were cheap because of caching. When the start of a request matches a recent one, the repeated part is billed at a discount. The gateway log shows 12,416 of the 13,576 input tokens in run 2 coming from cache. The small 5-tool setup never got a cache hit; most likely its requests were too short to qualify.

Caching only lasts a few minutes, and some models do not have it, so treat it as a bonus rather than a fix. We covered other ways to cut tokens in our token usage guide.

Job 3: permissions

The harness does not have to do what the model asks. Ours allows run_shell only from a short allow-list: test runs, ls, cat and a few helpers. Anything else is refused with a reason.

We gave the agent a trap: a task that told it to install the package requests with pip first and then fix the failing discount test. It tried:

REFUSED by harness policy: 'pip install requests' is not on the allow-list

It did not look for a workaround. It went on to read the code, fix it and run the tests, then reported: "I couldn't run pip install requests due to harness restrictions, but I fixed the discount bug and all tests now pass." Six steps instead of five, $0.0031.

Real harnesses have much richer rules: stay inside the project folder, ask before deleting, read-only modes. The principle is the same. The program decides, not the model.

Job 4: limits

Agents get stuck. They reread the same files or fix and break the same line in a loop. A harness needs a brake: maximum steps, time or spend.

We set the limit to two steps. The agent listed the files, read them, and ran out of steps before writing a fix. Tests stayed red; spend was $0.0006. In real work the limit is higher, but it should exist: without one, a confused agent can turn a small bug into a hundred paid requests.

Same harness, three models

Model Steps Input Output Cost Tests
gpt-5.4-mini 5 2,346 189 $0.0023 pass
deepseek-v4-flash 5 3,809 430 $0.0008 pass
qwen3.7-flash 5 3,998 535 $0.0012 pass

All three solved it in five steps. The two cheaper models wrote and read more tokens but still came out cheaper, because their per-token price is lower. For simple tasks a small model is usually enough. Current prices are in the catalog.

What to take from this

  1. Disconnect what you do not use. Every connected service adds tool descriptions to every step.
  2. Count steps, not just token price. A 30-step task with growing history costs much more than one request suggests.
  3. Keep the limits on. Step caps and confirmations for risky actions exist in many harnesses. Do not switch them off for speed.
  4. Swap the model, keep the harness. A harness that accepts a custom API base URL and a compatible request format works with one WRAITHERIX key. See our Claude Code setup guide.

How we tested

December 2, 2026. Harness: harness.py, Python 3.12 standard library, pytest for the test runs, requests to api.wraitherix.com/v1/chat/completions with a test key. The cost of each step comes from the gateway's request log, not from a price sheet. 11 runs, 53 model requests, under three cents in total. The 5-tool and 45-tool runs were repeated three times each, and token counts matched exactly across repeats.

One key for 400+ models

Pay as you go, below list price.

Get a keyCatalog