Agent harness engineering·
Open Mind, Closed Loop: Measuring the Trade-offs of Decision Models in Agentic Systems
A little less speculation, a little more instrumentation.
712 graded runsA scripted graph beat the loop with plenty of turns and lost with few
Inside the graph it made no measurable difference whether the planner, a small decision model or a random pick made the choices. The one choice that mattered was not giving up on a package.
Large language models (LLMs) are next-word-guessing machines that can generate prose, or software code, in response to a prompt. But a single prompt, even with context, doesn’t empower the model to do very much. A model harness (“harness”) is the structure that gives the model a set of tools as well as guidance. The most common type of harness is a loop where one tool call is requested by the model, the result comes back, and the next call is chosen from that result.
You can think of the harness as the infrastructure around the model. The harness is a program that runs on your own machine or a server, and the model itself is usually called over the network. The goals are to protect the user and their system, to generate repeatable, quality output, and to perform tasks efficiently. Loop harnesses are not the only type of harness. Another type is a graph harness, where more of that sequence is fixed in advance. The steps the agent goes through (write the code, run the checks, repair what failed, review) are named ahead of time, with rules for which step comes next. I wanted to know whether it matters if the graph is scripted ahead of time or written by the model each turn, and whether it matters which component the choices inside the scripted graph are decided by.
This was my first fling into graph harness design, and many of the failures may come from how I set the experiments up and not from the designs themselves. In the main experiment the harness failed most often when the graph was written by the model. I expected that, since that setup has the most moving parts, but it also had fewer tools and was shown less of each result, so I can’t pin the loss on the graph. Inside the graph I scripted, I found no significant difference in score between choices decided by the model that writes the code, by a decision model or by random chance, as long as skipping part of the job was not one of the options. A random pick that could skip did clearly worse.
What I ran
Every run builds part of a press-release intake module for an existing business system. The module is split into seven work packages. A package is one stage of the module, such as cleaning a raw email or storing a release, with its own specification and its own tests. The package is the unit that gets graded: each one was later graded for its ability to pass functional tests and if it came through the linter and formatter cleanly, and every score in this study is the share of packages that passed. The seven are built in two groups. The intake group is the three packages that parse untrusted input, and the delivery group is the four that connect to other systems (Appendix B, Appendix D). The runs happen on a private network on Microsoft Azure, where model-written code has no path to the internet or to any key, and every model call is checked against a spending cap (Appendix A).
The main experiment was 328 runs with a small model as the planner, the model that writes the code. It compared three setups, called arms in the chapters: a loop, a graph written by the planner each turn, and a scripted graph. The scripted graph has a few points where a choice is made, such as repair or rewrite after a failed check, and review or stop after clean checks. The component a choice is decided by is called the decider here, and five deciders were tried (Appendix C).
The follow-up was 384 runs with a second small model as the planner, at about five to ten turns a package. It compared a loop with a harness that splits the work among parallel workers, in three forms: with a plan written by the planner, with a scripted plan, and with the planner’s plan and no re-planning.
A turn is one model call in the main experiment and one model reply, which may hold several tool calls, in the follow-up. I kept the turn budgets tight on purpose. With generous budgets or larger models every design passes nearly everything and nothing can be compared.
What held
In the diagram the decimals are shares of packages passing, or differences between two shares. The turn counts are turns for each package.
%%{init: {'theme': 'base', 'fontFamily': 'Inter, Helvetica Neue, Arial, sans-serif', 'themeVariables': {
'fontFamily': 'Inter, Helvetica Neue, Arial, sans-serif', 'fontSize': '15px',
'primaryColor': '#F4F6F8', 'primaryTextColor': '#0A2540', 'primaryBorderColor': '#0A2540',
'secondaryColor': '#FFFFFF', 'tertiaryColor': '#FFFFFF', 'lineColor': '#5B6B7F',
'textColor': '#0A2540', 'clusterBkg': '#FFFFFF', 'clusterBorder': '#C9D3DE',
'edgeLabelBackground': '#FFFFFF'
}, 'flowchart': {'wrappingWidth': 290, 'rankSpacing': 42}}}%%
flowchart TB
Q1["<b>Graph or loop?</b><br/>It depends on the turns<br/>each package gets"]
Q2["<b>Does the decider inside the graph matter?</b><br/>Only when skipping a package<br/>is an option"]
R1["<b>Plenty of turns: about 110</b><br/>Scripted graph ahead of the loop<br/>0.448 against 0.302"]:::good
R2["<b>Tight turns: about 28</b><br/>Scripted graph behind the loop<br/>0.552 against 0.677"]:::problem
R3["<b>Very tight turns: 5 to 10</b><br/>Parallel harness behind the loop<br/>by 0.20 to 0.24"]:::problem
D1["<b>Skipping excluded</b><br/>Planner 0.448, decision model 0.448,<br/>random pick 0.458"]:::good
D2["<b>Skipping allowed</b><br/>Rule 0.344,<br/>random pick 0.198"]:::problem
Q1 --> R1 & R2 & R3
Q2 --> D1 & D2
classDef problem fill:#FAF0EE,stroke:#BA4A38,stroke-width:2px,color:#0A2540;
classDef good fill:#EAF7EF,stroke:#3BB273,stroke-width:2px,color:#0A2540;
The scripted graph and the loop came out level, for opposite reasons
On the intake group, where each package had about 110 turns, 0.448 of the packages passed under the scripted graph and 0.302 under the loop. On the delivery group, where each package had about 28 turns, 0.552 passed under the scripted graph and 0.677 under the loop.
On the delivery group the scripted graph lost because it ran out of turns. It built the four packages in order, spent more than half the budget on the first, and never got the fourth to pass. The loop spread its turns across all four.
A graph written by the model did worse than both
Under the model-written graph, 0.26 fewer of the packages passed than under the loop, and 0.27 fewer than under the scripted graph. That setup also had fewer tools enabled and each result was cut shorter, so I can’t pin the loss on the graph alone.
Inside the scripted graph, the choice of decider made no visible difference
| Decider inside the scripted graph | Share of packages passing |
|---|---|
| The planner model | 0.448 (0.469 in a duplicate arm) |
| A small decision model | 0.448 |
| A random pick, skipping excluded | 0.458 |
| A rule written in code, under which a package is sometimes skipped | 0.344 |
| A random pick, skipping allowed | 0.198 |
The decision model returned the same option every time: “repair” at all 263 failed checks and “stop” at all 85 clean ones. So the thing that matched the score with the planner as decider was a fixed policy, and the decision-model runs took a quarter fewer turns and cost a quarter less. That is no evidence that the decision model’s judgement is as good as the planner’s. On this work the judging made no difference to the score.
Splitting a small budget among workers passed fewer packages than the loop
In the follow-up more packages passed under the loop than under every form of the parallel harness, by 0.20 to 0.24. Each worker started with an empty conversation and a median of 3 to 9 turns, and those turns went on reading. The parallel harness finished in two-thirds of the time, so a budget in seconds would have favoured it.
110 packages built by the parallel harness passed every hidden test and failed only on the linter or the formatter. The loop had 2. So part of the gap is lint. Counting hidden tests alone, the loop still led every form of the parallel harness, by 0.09 to 0.20.
Takeaway
Graph harnesses are neither clearly garbage nor clearly superior to loop harnesses. In these runs a graph I scripted came out level with the loop overall, ahead where turns were plentiful and behind where they were tight, and a graph the model wrote for itself did worse. Graph harnesses are worth further investigation.
What I can’t claim from this
This is one module of seven packages by one author, built with two small models, so none of it is evidence about graph harnesses in general. The hidden tests were written by the same author as the specifications, and a pass is a weak certificate of correct code. The setup was tuned on the same packages it is measured on, and the scripted graph got more tuning than the loop.
Six things the plan required were not done. They are listed in Appendix E, and every limit is in chapter 4.
The rest of the study
The report runs from the question through the main experiment and the follow-up to what it adds up to. The engineering is in four appendices: the Azure setup, the module and its contracts, the harness and grading. The pilot runs have an appendix of their own, Appendix E.