<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://ozankabak.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://ozankabak.github.io/" rel="alternate" type="text/html" hreflang="en" /><updated>2026-12-01T14:14:28+00:00</updated><id>https://ozankabak.github.io/feed.xml</id><title type="html">Mehmet Ozan Kabak</title><subtitle>Writing about algorithms, math, AI or whatever else I&apos;m thinking about or learning these days.</subtitle><author><name>Mehmet Ozan Kabak</name><email></email></author><entry xml:lang="en"><title type="html">Agent Harness Design: Squeezing from Two Ends</title><link href="https://ozankabak.github.io/blog/2026/agent-harness-design/" rel="alternate" type="text/html" title="Agent Harness Design: Squeezing from Two Ends" /><published>2026-03-09T00:00:00+00:00</published><updated>2026-12-01T14:09:42+00:00</updated><id>https://ozankabak.github.io/blog/2026/agent-harness-design</id><content type="html" xml:base="https://ozankabak.github.io/blog/2026/agent-harness-design/"><![CDATA[<p>Building capable agents is a game played from two ends: better models generate sensible actions with higher probability; better harnesses induce corrective actions more effectively. This post is about the harness side — what it means to design one well, and what that looks like in practice.</p>

<h2 id="a-mental-picture-for-agent-harnesses">A Mental Picture for Agent Harnesses</h2>

<p>To understand what a harness is doing, it helps to be precise about what an LLM is doing. Three ideas frame this:</p>

<ol>
  <li>The LLM is a probabilistic generator of reasoning tokens and actions — tool calls, structured responses, free-form text — which ultimately receive “feedback” from the external world (tool return values, errors, user responses, rewards).</li>
  <li>That feedback takes many forms: syntactic errors from simple LLM mistakes, inconsistencies between new and previous results in a computational chain, rewards for achieving certain outcomes.</li>
  <li>The harness is an <a href="https://en.wikipedia.org/wiki/Finite-state_machine">FSM</a> that controls all feedback paths and formats that feedback to steer the LLM’s probabilistic generation toward desirable trajectories.</li>
</ol>

<p>If the harness can discourage undesirable trajectories more effectively than the underlying LLM’s propensity to produce them, the agent makes meaningful progress. This is the squeeze: every improvement to the harness buys capability independently of model quality, and the two compound.<sup id="fnref:swe-agent"><a href="#fn:swe-agent" class="footnote" rel="footnote" role="doc-noteref">1</a></sup></p>

<p>The harness designer has four levers to pull:</p>

<ul>
  <li><strong>FSM design</strong>: what states exist, what triggers transitions, and what the LLM sees at each state.</li>
  <li><strong>Schema design</strong>: how LLM responses are structured and constrained to extract reliable signal.</li>
  <li><strong>Error surfacing</strong>: how failures are detected, formatted, and fed back to steer recovery.</li>
  <li><strong>Reward design</strong> (where applicable): how outcomes are scored to shape long-horizon behavior.</li>
</ul>

<p>The rest of this post develops each of these in turn.</p>

<h2 id="fsm-design">FSM Design</h2>

<p>The FSM is the skeleton of the harness; it determines what states the agent can be in, what information is available at each state, and how the agent transitions between them. Two design decisions that pay off well in practice stand out:</p>
<ol>
  <li>The agent’s working memory must be rendered into context at every thinking step — this is passive feedback that shapes every LLM call, and its quality is easy to underestimate.</li>
  <li>Error recovery should be a first-class, well thought-out FSM state rather than an inline step in the main loop — the distinction keeps recovery logic clean and independently evolvable, and makes it easier to categorize exceptional cases to steer the LLM effectively.</li>
</ol>

<figure class="diagram"><div class="scroll"><svg class="figure-svg" viewBox="0 0 720 400" role="img" aria-labelledby="fsm-title fsm-desc" xmlns="http://www.w3.org/2000/svg">
  <title id="fsm-title">The agent harness as a finite state machine</title>
  <desc id="fsm-desc">Four states: THINKING, TOOL_EXECUTION, ERROR_RECOVERY and SUSPENDED. The agent's state (notes, artifacts, chat log, storage) is rendered into THINKING's context at every step. THINKING sends tool calls to TOOL_EXECUTION, which returns results. LLM errors, invalid storage keys and tool failures go to ERROR_RECOVERY, which either feeds the error back to THINKING or aborts to SUSPENDED. THINKING suspends when it finishes, gives up or asks the user.</desc>
  <defs>
    <marker id="fsm-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
      <path d="M0,0 L10,5 L0,10 z" style="fill: var(--muted)" />
    </marker>
    <marker id="fsm-arrow-accent" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
      <path d="M0,0 L10,5 L0,10 z" style="fill: var(--accent)" />
    </marker>
  </defs>
  <style>
    .figure-svg { font-family: var(--font); }
    .figure-svg text { fill: var(--text); }
    .fsm-state { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
    .fsm-main { fill: var(--accent-soft); stroke: var(--accent); }
    .figure-svg .fsm-name { font: 600 13px var(--mono); letter-spacing: .02em; }
    .fsm-edge { fill: none; stroke: var(--muted); stroke-width: 1.5; marker-end: url(#fsm-arrow); }
    .fsm-render { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; marker-end: url(#fsm-arrow-accent); }
    .fsm-label { font-size: 12.5px; }
    .figure-svg .fsm-label { fill: var(--muted); }
    .fsm-panel { fill: none; stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 4 4; }
    .figure-svg .fsm-panel-title { font-size: 12px; font-weight: 600; letter-spacing: .08em; fill: var(--muted); }
    .fsm-item { font-size: 13px; }
  </style>

  <!-- Agent state, rendered into context -->
  <rect class="fsm-panel" x="20" y="28" width="160" height="128" rx="10" />
  <text class="fsm-panel-title" x="36" y="52">AGENT STATE</text>
  <text class="fsm-item" x="36" y="78">Notes</text>
  <text class="fsm-item" x="36" y="100">Artifacts</text>
  <text class="fsm-item" x="36" y="122">Chat log</text>
  <text class="fsm-item" x="36" y="144">Storage (keys)</text>
  <path class="fsm-render" d="M180,92 L246,92" />
  <text class="fsm-label" x="186" y="82">rendered</text>
  <text class="fsm-label" x="186" y="112">each step</text>

  <!-- States -->
  <rect class="fsm-state fsm-main" x="250" y="66" width="150" height="52" rx="10" />
  <text class="fsm-name" x="325" y="97" text-anchor="middle">THINKING</text>
  <rect class="fsm-state" x="520" y="66" width="180" height="52" rx="10" />
  <text class="fsm-name" x="610" y="97" text-anchor="middle">TOOL_EXECUTION</text>
  <rect class="fsm-state" x="400" y="276" width="180" height="52" rx="10" />
  <text class="fsm-name" x="490" y="307" text-anchor="middle">ERROR_RECOVERY</text>
  <rect class="fsm-state" x="110" y="276" width="150" height="52" rx="10" />
  <text class="fsm-name" x="185" y="307" text-anchor="middle">SUSPENDED</text>

  <!-- Entry -->
  <path class="fsm-edge" d="M325,16 L325,62" />
  <text class="fsm-label" x="333" y="38">user message</text>

  <!-- THINKING <-> TOOL_EXECUTION -->
  <path class="fsm-edge" d="M400,82 L516,82" />
  <text class="fsm-label" x="458" y="74" text-anchor="middle">tool calls</text>
  <path class="fsm-edge" d="M520,104 L404,104" />
  <text class="fsm-label" x="462" y="124" text-anchor="middle">results</text>

  <!-- Into ERROR_RECOVERY -->
  <path class="fsm-edge" d="M610,118 L536,272" />
  <text class="fsm-label" x="590" y="184">invalid key,</text>
  <text class="fsm-label" x="590" y="200">tool failure</text>
  <path class="fsm-edge" d="M355,118 L460,272" />
  <text class="fsm-label" x="412" y="168">LLM error</text>

  <!-- Out of ERROR_RECOVERY -->
  <path class="fsm-edge" d="M430,276 L328,122" />
  <text class="fsm-label" x="390" y="226" text-anchor="end">error fed back,</text>
  <text class="fsm-label" x="390" y="242" text-anchor="end">retry</text>
  <path class="fsm-edge" d="M400,302 L264,302" />
  <text class="fsm-label" x="332" y="294" text-anchor="middle">abort</text>
  <text class="fsm-label" x="332" y="346" text-anchor="middle">(unrecoverable or too many errors)</text>

  <!-- THINKING -> SUSPENDED -->
  <path class="fsm-edge" d="M285,118 L205,272" />
  <text class="fsm-label" x="62" y="210">finish, give up</text>
  <text class="fsm-label" x="62" y="226">or ask the user</text></svg>
</div>
<figcaption>A harness as an FSM. The state names are arbitrary, chosen for illustration. Errors never loop back inline: they pass through a dedicated recovery state, which either feeds them back to the LLM or stops.</figcaption></figure>

<h3 id="state-rendering">State Rendering</h3>

<p>Feedback flows not just through error messages but through the LLM’s view of its own working memory. At each thinking step, the harness renders the agent’s state — notes, stored objects (more on this later), artifacts, … — into the context window. How one structures, orders or compacts that state directly influences the LLM’s next action.</p>

<p>This is a feedback design decision that is easy to overlook. A state render that buries the most relevant information deep in a wall of text,<sup id="fnref:lost"><a href="#fn:lost" class="footnote" rel="footnote" role="doc-noteref">2</a></sup> or that uses inconsistent formatting across sections, degrades the LLM’s ability to reference its own work correctly. Conversely, a well-structured state render — clear section boundaries, consistent representations, eviction/compaction policies that preserve recency — functions as passive feedback that continuously orients the LLM. This is the FSM design lever operating quietly in the background of every thinking step.</p>

<h3 id="error-recovery-as-a-first-class-fsm-state">Error Recovery as a First-Class FSM State</h3>

<p>When validation or execution fails, the simplest response is to append the error to the conversation and re-prompt. This works, but it conflates two distinct concerns: the main agentic loop (think, act, observe)<sup id="fnref:react"><a href="#fn:react" class="footnote" rel="footnote" role="doc-noteref">3</a></sup> and the recovery logic (decide how to respond to failure). Inline handling becomes hard to reason about and extend as recovery logic grows more complex: Different error types warrant different responses, some failures should escalate to the user, others should cause the agent to give up gracefully.</p>

<p>A cleaner design promotes error recovery to a dedicated FSM state. When a failure occurs, the FSM transitions to the recovery state, which formats the error, applies recovery-specific logic (retry, escalate, or abort), and transitions back to the appropriate next state. The main thinking loop stays clean, and recovery strategies can be evolved independently. The failure modes that matter in practice — tool errors, LLM refusals, dependency failures, unrecoverable state — each get a well-defined path rather than ad-hoc branching in the middle of the main loop.</p>

<p>A dedicated recovery state is also the natural place to detect loops. The characteristic failure of a naive retry policy is an agent issuing the same broken call over and over, receiving the same error each time. Keeping separate error budgets per error type, and treating a repeated identical failure as a signal to change strategy or escalate rather than to retry, turns recovery from a blind loop into a decision.</p>

<h2 id="schema-design">Schema Design</h2>

<p>Schema design is the harness designer’s primary tool for expressing behavioral expectations. A well-designed schema eliminates entire error classes before any validation code runs, exposes the right abstractions to the LLM, and encodes contracts the LLM cannot violate structurally. Two aspects are worth developing: making interpreter memory a first-class schema concept to eliminate object conversion errors, and using schema constraints to enforce multi-state behavioral contracts precisely.</p>

<h3 id="interpreter-agents-native-environment">Interpreter: Agent’s Native Environment</h3>

<p>Making interpreter memory the agent’s native environment has two equally important benefits.<sup id="fnref:python"><a href="#fn:python" class="footnote" rel="footnote" role="doc-noteref">4</a></sup></p>

<p>The first is eliminating <em>object conversion</em> errors. Tool functions take arguments as JSON — strings, numbers, nested objects — which the harness must convert into actual Python objects before calling the function, then serialize the return value back to JSON for the LLM. Each round trip is an opportunity for mistakes: the wrong type, a nested structure the LLM mis-specifies, a value that serializes differently than the LLM expects. The solution is to assign each stored object a string key and let tool arguments reference those keys directly — the LLM manipulates Python objects via <a href="https://en.wikipedia.org/wiki/Handle_(computing)">symbolic handles</a>, never touching their serialized form. This <em>structured pointer</em> pattern sits between raw JSON arguments and full code generation on the complexity spectrum: the LLM doesn’t write code, yet it doesn’t serialize everything just to call a function.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Tools are plain Python functions; type hints become the JSON schema.
</span><span class="k">def</span> <span class="nf">load_table</span><span class="p">(</span><span class="n">path</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">DataFrame</span><span class="p">:</span> <span class="bp">...</span>
<span class="k">def</span> <span class="nf">summarize</span><span class="p">(</span><span class="n">table</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">by</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">DataFrame</span><span class="p">:</span> <span class="bp">...</span>

<span class="c1"># Without storage keys, the LLM must spell the table out as JSON:
</span><span class="p">{</span><span class="sh">"</span><span class="s">name</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">summarize</span><span class="sh">"</span><span class="p">,</span>
 <span class="sh">"</span><span class="s">arguments</span><span class="sh">"</span><span class="p">:</span> <span class="p">{</span><span class="sh">"</span><span class="s">by</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">region</span><span class="sh">"</span><span class="p">,</span>
               <span class="sh">"</span><span class="s">table</span><span class="sh">"</span><span class="p">:</span> <span class="p">[{</span><span class="sh">"</span><span class="s">region</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">EMEA</span><span class="sh">"</span><span class="p">,</span> <span class="sh">"</span><span class="s">q3</span><span class="sh">"</span><span class="p">:</span> <span class="mi">1204331</span><span class="p">},</span> <span class="p">...]}}</span>

<span class="c1"># With storage keys, results stay in interpreter memory
# and the LLM passes handles instead:
</span><span class="p">{</span><span class="sh">"</span><span class="s">name</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">load_table</span><span class="sh">"</span><span class="p">,</span>
 <span class="sh">"</span><span class="s">arguments</span><span class="sh">"</span><span class="p">:</span> <span class="p">{</span><span class="sh">"</span><span class="s">path</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">sales/q3.parquet</span><span class="sh">"</span><span class="p">,</span> <span class="sh">"</span><span class="s">save_as</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">sales</span><span class="sh">"</span><span class="p">}}</span>
<span class="p">{</span><span class="sh">"</span><span class="s">name</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">summarize</span><span class="sh">"</span><span class="p">,</span>
 <span class="sh">"</span><span class="s">arguments</span><span class="sh">"</span><span class="p">:</span> <span class="p">{</span><span class="sh">"</span><span class="s">by</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">region</span><span class="sh">"</span><span class="p">,</span> <span class="sh">"</span><span class="s">substitutions</span><span class="sh">"</span><span class="p">:</span> <span class="p">{</span><span class="sh">"</span><span class="s">table</span><span class="sh">"</span><span class="p">:</span> <span class="sh">"</span><span class="s">sales</span><span class="sh">"</span><span class="p">}}}</span>

<span class="c1"># A bad handle is caught before any tool runs:
# Storage key 'sales' not found for parameter 'table' in tool 'summarize'
</span></code></pre></div></div>

<p>The second benefit is that it unlocks non-serializable objects as first-class values. Many useful Python objects — dataframes, model weights, database cursors, compiled graphs — cannot be round-tripped through JSON at all. With interpreter memory as the native environment, the LLM can receive, store, pass between tools, and compose these objects freely, limited only by what the tools themselves can do. This significantly expands the range of tasks an agent can handle without requiring the harness to flatten everything into a JSON-compatible representation.</p>

<p>Both benefits compound over long-horizon tasks: conversion mistakes and representational limitations accumulate with every step, so eliminating both classes early keeps the agent on track. Making this work cleanly is a schema design problem; the harness must expose storage references in the tool schema so the LLM knows they exist and how to use them.</p>

<h3 id="schema-as-behavioral-contract">Schema as Behavioral Contract</h3>

<p>Schema design is not a mechanical step — it is the harness designer’s primary tool for expressing behavioral expectations. A schema that is too permissive passes the burden of correctness onto later validation layers; one that is precise eliminates error classes before any validation code runs.</p>

<p>A key principle here is that schema states should be <em>structurally</em> distinct, not conventionally distinct. Whenever a field has multiple meaningful states, the first instinct is often to overload a single type — say, using an empty string as a <a href="https://en.wikipedia.org/wiki/Sentinel_value">sentinel</a> for “no value.” But this forces the LLM to learn and respect a convention rather than encoding the distinction in the schema itself. A better design gives each state its own structural form<sup id="fnref:tagged"><a href="#fn:tagged" class="footnote" rel="footnote" role="doc-noteref">5</a></sup> so that the schema can reject violations without any custom validation code, and the LLM can express intent precisely.</p>

<p>Schema expressiveness and model compatibility are often in tension. More expressive schemas — disjunctive types, per-value descriptions, rich constraints — give the LLM better guidance but may not be supported uniformly across providers (<a href="https://json-schema.org/understanding-json-schema/reference/combining"><code class="language-plaintext highlighter-rouge">oneOf</code></a> is a good example). Simpler, flatter schemas are more portable but shift the burden of disambiguation onto the LLM’s training. The right balance depends on the models you target and how much precision you can encode elsewhere.</p>

<p>Finally, an agent harness has more than one schema surface: the LLM’s structured reasoning response (what action it intends to take) and its tool call arguments are separate channels with separate validation concerns. Treating them as one problem leads to recovery logic that handles both failures the same way — a mistake, since a malformed reasoning response and a bad tool argument are fundamentally different error modes that warrant different responses.</p>

<h2 id="error-surfacing">Error Surfacing</h2>

<p>Error surfacing is where the harness does most of its active steering work. The goal is to catch failures as early as possible, with messages targeted enough to point the LLM toward a correction rather than merely reporting that something went wrong. Three distinct strategies contribute: exploiting the natural error output of code execution, layering validation across multiple phases before any tool runs, and enforcing tool scheduling/dependency constraints to prevent illegal execution orderings before they produce silent failures.</p>

<h3 id="code-generation">Code Generation</h3>

<p>Whether due to inherent predictable structure, the abundance of training data, or some other fundamental reason, LLMs are <em>great</em> at generating code.<sup id="fnref:codeact"><a href="#fn:codeact" class="footnote" rel="footnote" role="doc-noteref">6</a></sup> More importantly for harness design, running code almost always produces concrete, actionable errors on failure — even a syntax error tells the LLM exactly what went wrong and where. This makes code execution one of the most effective error surfacing strategies available.</p>

<p>Strictly speaking, choosing code over discrete tool calls is as much an <em>action space</em> decision as an error surfacing one: it changes what the LLM can express in a single step, and how many tools it needs at all. But its biggest payoff for the harness designer is on the error side.</p>

<p>We already see a reduction (but not elimination) in tool variety as frameworks adopt code-generation approaches (<a href="https://vercel.com/blog/we-removed-80-percent-of-our-agents-tools">Vercel’s blog post on this</a>, <a href="https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling">Anthropic’s programmatic tool calling</a>).</p>

<h3 id="layered-validation">Layered Validation</h3>

<p>Schema constraints are the first line of defense, but they cannot catch everything — particularly semantic errors that are contextually wrong but structurally fine. A simple example is the presence of a tool argument that references a key that does not yet exist. A well-designed harness adds validation in layers, each catching a different error class at the earliest possible moment:</p>

<ol>
  <li><strong>Schema enforcement</strong>: structurally invalid responses should be rejected immediately, before any processing.</li>
  <li><strong>Parse-time checks</strong>: values that are individually schema-valid but mutually contradictory — cross-field constraints that the schema cannot express — are caught when the response is parsed as a whole.</li>
  <li><strong>Pre-execution validation</strong>: before any tool runs, the harness checks that arguments are consistent with the current execution context; e.g., whether storage keys exist or will be created by a preceding call, required parameters are present, dependencies are acyclic.</li>
  <li><strong>Type coercion and argument validation</strong>: tool arguments are converted from JSON to the expected Python types, with mismatches caught and reported.</li>
</ol>

<p>Increasingly, there is a layer zero as well: <a href="https://arxiv.org/abs/2307.09702">constrained decoding</a>. When a provider’s strict structured-output mode masks invalid tokens during generation, schema violations cannot occur at all, and the first layer becomes a guarantee rather than a check. This is also where the expressiveness tension from the previous section bites hardest: strict modes support only a subset of JSON Schema,<sup id="fnref:strict"><a href="#fn:strict" class="footnote" rel="footnote" role="doc-noteref">7</a></sup> and constructs like <code class="language-plaintext highlighter-rouge">oneOf</code> are often outside it.</p>

<p>Catching errors early matters because tool calls may be expensive or have side effects: an error caught in pre-execution validation avoids running one or more tools only to fail partway through. More importantly, each layer can produce a precisely targeted error message — <em>“storage key ‘result’ not found”</em> is more corrective than <em>“tool call failed.”</em> The harness gets multiple opportunities to steer the LLM back toward a valid trajectory before anything expensive happens.</p>

<h3 id="tool-scheduling-and-concurrency">Tool Scheduling and Concurrency</h3>

<p>LLMs often issue bursts of tool calls in a single turn. If those calls are independent, running them concurrently reduces cycle time significantly; if they have dependencies, the harness must serialize them correctly or detect invalid orderings. Functional programming offers a useful lens here: if each tool declares whether it is <a href="https://en.wikipedia.org/wiki/Pure_function">pure</a> (no side effects, result depends only on inputs) and whether it writes to shared state, the harness can determine a valid execution order automatically.<sup id="fnref:topo"><a href="#fn:topo" class="footnote" rel="footnote" role="doc-noteref">8</a></sup> Where the LLM has requested an ambiguous ordering — say, two tools that both write to the same storage key without a dependency between them<sup id="fnref:waw"><a href="#fn:waw" class="footnote" rel="footnote" role="doc-noteref">9</a></sup> — the harness can generate a precise, corrective error rather than silently producing a wrong result.</p>

<figure class="diagram"><div class="scroll"><svg class="figure-svg" viewBox="0 0 720 356" role="img" aria-labelledby="dep-title dep-desc" xmlns="http://www.w3.org/2000/svg">
  <title id="dep-title">Scheduling three tool calls from their data flow</title>
  <desc id="dep-desc">Calls 1 and 2 each load a table and save it under a storage key, sales and targets. They share no keys, so they run in parallel. Call 3 reads both keys through substitutions, so it waits for both. If calls 1 and 2 both saved to the same key with no dependency between them, the harness rejects the batch before running anything.</desc>
  <defs>
    <marker id="dep-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
      <path d="M0,0 L10,5 L0,10 z" style="fill: var(--accent)" />
    </marker>
  </defs>
  <style>
    .figure-svg { font-family: var(--font); }
    .figure-svg text { fill: var(--text); }
    .dep-call { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
    .figure-svg .dep-name { font: 600 13.5px var(--mono); }
    .figure-svg .dep-arg { font: 12px var(--mono); }
    .figure-svg .dep-key { fill: var(--accent); }
    .figure-svg .dep-head { font-size: 12px; font-weight: 600; letter-spacing: .08em; fill: var(--muted); }
    .dep-edge { fill: none; stroke: var(--accent); stroke-width: 1.5; marker-end: url(#dep-arrow); }
    .figure-svg .dep-edge-label { font: 12px var(--mono); fill: var(--accent); }
    .dep-band { fill: var(--accent-soft); }
    .dep-bad { fill: none; stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 4 4; }
    .figure-svg .dep-muted { fill: var(--muted); font-size: 12.5px; }
  </style>

  <text class="dep-head" x="20" y="22">WAVE 1 · RUN IN PARALLEL</text>
  <text class="dep-head" x="430" y="22">WAVE 2 · WAITS FOR BOTH</text>

  <!-- Call 1 -->
  <rect class="dep-call" x="20" y="36" width="300" height="76" rx="10" />
  <text class="dep-name" x="36" y="62">1 · load_table</text>
  <text class="dep-arg" x="36" y="83">path="sales/q3.parquet"</text>
  <text class="dep-arg" x="36" y="101">save_as=<tspan class="dep-key">"sales"</tspan></text>

  <!-- Call 2 -->
  <rect class="dep-call" x="20" y="132" width="300" height="76" rx="10" />
  <text class="dep-name" x="36" y="158">2 · load_table</text>
  <text class="dep-arg" x="36" y="179">path="targets/q3.csv"</text>
  <text class="dep-arg" x="36" y="197">save_as=<tspan class="dep-key">"targets"</tspan></text>

  <!-- Call 3 -->
  <rect class="dep-call" x="430" y="74" width="270" height="96" rx="10" />
  <text class="dep-name" x="446" y="100">3 · compare</text>
  <text class="dep-arg" x="446" y="121">actual ← <tspan class="dep-key">"sales"</tspan></text>
  <text class="dep-arg" x="446" y="139">target ← <tspan class="dep-key">"targets"</tspan></text>
  <text class="dep-arg" x="446" y="157">save_as="gap"</text>

  <!-- Data flow -->
  <path class="dep-edge" d="M320,74 C370,74 380,110 426,110" />
  <text class="dep-edge-label" x="350" y="68">sales</text>
  <path class="dep-edge" d="M320,170 C370,170 380,134 426,134" />
  <text class="dep-edge-label" x="344" y="186">targets</text>

  <!-- Rejected variant -->
  <rect class="dep-bad" x="20" y="236" width="680" height="104" rx="10" />
  <text class="dep-head" x="36" y="261">REJECTED BEFORE ANYTHING RUNS</text>
  <text class="dep-muted" x="36" y="284">If calls 1 and 2 both used save_as="sales", nothing orders them, so the result would</text>
  <text class="dep-muted" x="36" y="302">depend on which finished last. The harness returns a precise error instead:</text>
  <text class="dep-arg" x="36" y="326">calls 1 and 2 both write storage key 'sales' with no dependency between them</text></svg>
</div>
<figcaption>Three tool calls from one turn (names chosen for illustration). Calls 1 and 2 share no storage keys, so they run in parallel; call 3 reads both keys, so it waits.</figcaption></figure>

<p>This is the error surfacing lever applied at the scheduling layer: the harness understands tool semantics well enough to catch a class of LLM mistakes before they cause silent failures downstream.</p>

<h2 id="reward-design">Reward Design</h2>

<p>Reward design — how outcomes are scored to shape long-horizon behavior — is the fourth lever. It is most visible in <a href="https://en.wikipedia.org/wiki/Reinforcement_learning">reinforcement learning</a> settings, where the harness must define what constitutes progress and encode that as a signal the training process can act on. But it is not confined to training: verifiers, test suites and LLM judges score outcomes at inference time too, and a harness can use those scores to choose between candidate attempts or to trigger self-correction. A thorough treatment deserves its own post and is outside the scope of this one; the three levers above apply regardless.</p>

<h2 id="where-this-leaves-us">Where This Leaves Us</h2>

<p>The four levers compound. A more precise schema reduces the error rate before validation runs; layered validation catches what the schema misses; a dedicated recovery state handles what validation misses; and good state rendering maintains LLM orientation throughout. Each improvement is independent of model quality, and together they multiply the effect of model improvements.</p>

<p>Not every harness gain is permanent, though. The <a href="http://www.incompleteideas.net/IncIdeas/BitterLesson.html">bitter lesson</a> applies here too: scaffolding that compensates for a specific model weakness (heavy validation of outputs that a newer model rarely gets wrong, for instance) tends to be absorbed as models improve. The levers that last are the ones that shape the agent’s <em>environment</em> rather than patch its mistakes: what state it sees, how its actions are typed and scheduled, and how failures are routed.</p>

<p>The current trend toward code generation is, through this lens, a shift in which levers matter most: code execution produces such high-quality error feedback that it partly compensates for weaker schema and validation design. But it doesn’t eliminate the other levers — state rendering, FSM structure, and scheduling remain relevant regardless of whether the LLM is calling tools or writing code.</p>

<p>Both ends of the squeeze have plenty of room to improve: models will keep getting more capable, and harness design is still a relatively young “discipline” with open problems. As the two advance together, agents will be able to take on tasks of greater scope, duration,<sup id="fnref:metr"><a href="#fn:metr" class="footnote" rel="footnote" role="doc-noteref">10</a></sup> and consequence — and make a proportionally larger impact on the real world.</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:swe-agent">
      <p>SWE-agent is a clean demonstration: with the model held fixed, redesigning only the agent–computer interface (its commands, feedback format and guardrails) substantially improved results on software engineering tasks. Yang et al., <a href="https://arxiv.org/abs/2405.15793">SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering</a>, NeurIPS 2024. <a href="#fnref:swe-agent" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:lost">
      <p>Models are measurably worse at using information placed in the middle of a long context than at its beginning or end. Liu et al., <a href="https://arxiv.org/abs/2307.03172">Lost in the Middle: How Language Models Use Long Contexts</a>, TACL 2024. <a href="#fnref:lost" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:react">
      <p>This interleaving of reasoning and acting was popularized by Yao et al., <a href="https://arxiv.org/abs/2210.03629">ReAct: Synergizing Reasoning and Acting in Language Models</a>, ICLR 2023. <a href="#fnref:react" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:python">
      <p>This post focuses on Python-based agents, but the pattern applies broadly. <a href="#fnref:python" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:tagged">
      <p>In type-system terms, a <a href="https://en.wikipedia.org/wiki/Tagged_union">tagged union</a> (sum type). The same principle is often summarized as “make illegal states unrepresentable”: Yaron Minsky, <a href="https://blog.janestreet.com/effective-ml/">Effective ML</a>. <a href="#fnref:tagged" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:codeact">
      <p>Wang et al., <a href="https://arxiv.org/abs/2402.01030">Executable Code Actions Elicit Better LLM Agents</a>, ICML 2024, finds that letting agents act through executable Python outperforms JSON or text tool calls. <a href="#fnref:codeact" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:strict">
      <p>For example, OpenAI documents the subset of JSON Schema its strict mode supports in its <a href="https://developers.openai.com/api/docs/guides/structured-outputs">structured outputs guide</a>. <a href="#fnref:strict" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:topo">
      <p>Given declared dependencies, any <a href="https://en.wikipedia.org/wiki/Topological_sorting">topological ordering</a> of the call graph is valid, and calls with no path between them can run concurrently. <a href="#fnref:topo" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:waw">
      <p>Processor designers know this as a write-after-write <a href="https://en.wikipedia.org/wiki/Hazard_(computer_architecture)">hazard</a>. <a href="#fnref:waw" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:metr">
      <p>METR tracks this directly: the length of software tasks (measured by how long they take humans) that frontier agents can complete has been growing exponentially. Kwa et al., <a href="https://arxiv.org/abs/2503.14499">Measuring AI Ability to Complete Long Software Tasks</a>, 2025. <a href="#fnref:metr" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Mehmet Ozan Kabak</name></author><category term="harness" /><category term="agents" /><category term="ai" /><category term="llm" /><summary type="html"><![CDATA[Better models generate sensible actions with higher probability; better harnesses induce corrective actions more effectively. This post is about the harness side.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://ozankabak.github.io/assets/images/posts/agent-harness-design/cover.png" /><media:content medium="image" url="https://ozankabak.github.io/assets/images/posts/agent-harness-design/cover.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>