An agent harness is the runtime scaffolding that wraps a Large Language Model and turns it from a text predictor into a goal-directed actor that can perceive, decide, and affect the world. Without a harness, an LLM is just prompt → completion. With one, it becomes an agent.

If the LLM is the CPU, the harness is the operating system — memory, syscalls, drivers, and the loop that keeps the whole thing alive.

The Five Ingredients

A harness is the smallest amount of code that supplies these five things:

  1. The Loop — repeatedly: assemble context → call model → execute tool calls → feed results back → until the model stops calling tools. This is the core of AI Agents - How They Work.
  2. Tools — functions the model can invoke (read files, run shell, edit code, search the web). Quality matters more than quantity (Agent Tools - Design Principles).
  3. Context management — what enters the prompt this turn, how history is preserved or compacted, what files the agent loads. The primary lever for agent quality (Context Engineering).
  4. I/O surface — how a human (or another program) talks to the agent: TUI, print mode, JSON stream, RPC, SDK.
  5. Provider abstraction — swap models without rewriting the loop.

Strip any one of these and the agent collapses: no loop → single-shot chatbot; no tools → text generator; no context management → amnesia after every turn.

Why a Harness is Necessary

A raw model API gives you completions. To get an agent, somebody has to:

  • give the model tools the host environment trusts
  • run those tools safely with the user’s permissions
  • maintain conversational state across many turns and many tool calls
  • expose all of that to a human or upstream system

That “somebody” is the harness. No harness, no agent. This is the deeper reason Self-Extending Agents are possible at all — the harness is the substrate the agent extends itself into.

Pi as Reference Implementation

Pi (Coding Agent) is the harness used to build and maintain this vault. It is deliberately minimal, which makes it a clean specimen for studying what a harness is vs. what is merely fashionable in current tools.

Harness concernPi’s answer
LoopA small agent loop in pi-agent-core
ToolsFour built-ins: read, write, edit, bash
ContextSessions, compaction, AGENTS.md / CLAUDE.md context files
I/OInteractive TUI, -p print, --mode json, --mode rpc, SDK
ProvidersAnthropic, OpenAI, Gemini, xAI, Groq, Cerebras, OpenRouter, … via pi-ai
ExtensibilitySkills, Prompt Templates, TypeScript Extensions, Themes, Pi Packages
PersistenceSessions stored to disk; --continue, --resume, --fork, branching trees

Notice what is absent: MCP, plan mode, sub-agents, todos, permission popups, background bash. These are workflows Pi refuses to bake in so they don’t get imposed on every user. See the Pi (Coding Agent) “Deliberate Omissions” table for the full rationale.

Design tension every harness must resolve

Every built-in feature is a workflow imposed on every user. Every extension point is a workflow enabled but not imposed. Minimal harnesses (Pi) push almost everything into extensions. Maximal harnesses (Claude Code, Cursor agents) bake decisions in. Neither is wrong — they are different bets about who the user is.

Harness vs. Agent vs. Model

A common confusion. Keep these separate:

  • Model — the LLM weights behind an API. Generates tokens. Stateless.
  • Agent — a behavior that emerges when a model is wired into a loop with tools and goals. Not a thing — a pattern.
  • Harness — the code that produces that behavior. The thing you install, configure, and extend.

You can have one model serve many harnesses. You can have one harness drive many models. The agent is what happens between them.

Agent harness vs. evaluation harness

Two different things, same word. The agent harness is what runs in production (this page). The evaluation harness wraps around it to run tasks at scale, capture transcripts, and apply graders. When evaluating “an agent,” you’re always evaluating the harness and the model together. Change either and the eval scores can shift. See Evaluating AI Agents.

The Memory Illusion (read this first)

The single most important fact about how a harness works — and the one most people get wrong:

Key

A coding agent is a goldfish with a very expensive scribe.
The model forgets everything between turns. The harness re-reads the entire conversation aloud, plus all the rules, plus all the tool descriptions, before every single response. What looks like a thinking partner is actually a stateless function being repeatedly re-briefed at full cost.

The LLM never touches anything

When you ask Pi to “read notes.md and summarize it,” the LLM does not read the file. The LLM cannot read files — it is a text-in/text-out function. What actually happens:

  1. Pi sends your message to the model along with a system prompt that advertises the available tools (read, write, edit, bash) and their argument schemas.
  2. The model emits text of the form: “I want to call read with path: notes.md.”
  3. Pi — not the model — executes fs.readFile("notes.md") locally.
  4. Pi sends a second API call containing the original message + the model’s tool-call request + the file contents as a “tool result.”
  5. Now the model has the file in its context and generates a summary.

The LLM only ever produced text. Every action that touched the world was performed by the harness, on the model’s behalf, in response to text the model emitted. Agency is an illusion the harness creates by parsing the model’s text for tool-call intent and executing it.

The API is stateless — “memory” is re-sent every turn

There is no server-side session. Every API call is a pure function:

response = api.call({
  system:   buildSystemPrompt(),       // ← rebuilt every turn
  tools:    [read, write, edit, bash], // ← schemas re-sent every turn
  messages: [...fullHistory, newMsg],  // ← entire transcript every turn
});

What feels like memory is actually the harness paying for it in tokens, every turn:

What feels like memoryWhat’s actually happening
”The model remembers my project structure”Harness re-sends CLAUDE.md / AGENTS.md every turn
”The model remembers we’re working on auth.py”Harness re-sends the entire conversation every turn
”The model remembers the file it just read”The tool result is in the transcript, which is re-sent every turn
”The agent remembers its plan”Either (a) the plan is in the transcript, or (b) the agent wrote it to PLAN.md and re-reads it when needed

This is why coding agents cost roughly quadratically in long sessions: turn N re-pays for turns 1…N−1 every time. It is also why Pi (Coding Agent) rejects MCP, built-in todos, and bloated tool sets — every byte in the system prompt is rent paid on every single turn for the entire session.

Corollary: attaching is permanent, reading is transient

A direct consequence of the stateless API: anything that enters the transcript stays in the transcript until the session ends, gets compacted, or gets branched away. This radically changes how you should think about file attachments.

When you attach 3 PDFs to a message:

  1. The harness converts them to text (or document/image blocks) and inserts them into your user message.
  2. That message joins the transcript.
  3. The transcript is re-sent on every subsequent turn.
  4. The PDFs are now glued to every future API call until the session ends.

A worked example: attach three 30k-token PDFs on turn 1. By turn 20 you are paying ~120k tokens per turn — already past the 50% degradation point in a 200k window, and most of that cost is re-paying for documents the current turn doesn’t need.

Contrast this with the Pi-style read-on-demand pattern: keep the PDFs on disk, let the model call read("docs/a.pdf", offset, limit) only when relevant. The file contents live in one tool-result message, contain only the relevant pages, and can be compacted away later when no longer needed.

Key

Attaching is a permanent cost. Reading is a transient cost.
Attach only what every turn will need (small spec files, the question itself). Put everything else on disk and let the agent read it on demand.

By this rule, CLAUDE.md / AGENTS.md is the one file you have explicitly chosen to attach to every turn forever — a choice that should be earned, not casual.

This is the same principle as the file-as-state pattern in Pi (Coding Agent): large data lives on disk, enters context only when needed, leaves context when it isn’t. It is also why Pi’s design centers on the read tool rather than upfront attachments — attachments are a UX convenience that hides a per-turn tax.

Where to see it yourself

Pi’s system-prompt assembly lives in dist/core/system-prompt.js (source: src/core/system-prompt.ts) inside the pi-coding-agent package. The function buildSystemPrompt() constructs, on every turn, a prompt that contains:

  1. Pi boilerplate (“You are an expert coding assistant operating inside pi…”)
  2. The tools list with one-line descriptions
  3. Guidelines (concise responses, show file paths, etc.)
  4. Pi documentation pointers
  5. # Project Context — your CLAUDE.md (or AGENTS.md) inlined verbatim
  6. Skills section (if any are loaded)
  7. Current date and working directory

To inspect raw payloads on the wire, use claude-trace or Pi’s session export. Once you’ve seen it once, the “memory illusion” goes away forever.

What Belongs in the Always-Attached Set

A direct corollary of the per-turn cost model: the system prompt and any context files (CLAUDE.md, AGENTS.md) form an always-attached set — every byte in them is rent paid on every API call for the entire session. Choosing what goes in that set is the most consequential design decision in any project that uses an agent harness.

The “every turn” test

Before adding anything to a context file, apply this test:

“Is this still relevant on a turn where the user asks about something completely unrelated to it?”

  • Yes → it belongs in the always-attached set (it is a per-turn invariant; the rent is earned)
  • No → it belongs on disk, loaded only when the task matches (skill files, READMEs, source files the agent reads via read)

The three-layer rule

Applied to a project like this vault, the test produces a clean hierarchy that mirrors WikiLLM’s own three-layer architecture:

LayerWhat lives hereCost modelExamples
CLAUDE.md (always-attached)Identity + invariants that apply to every turnPer-turn, forever”Use [[wikilinks]]”, “frontmatter must include created:”, “never modify Sources/”
Skills / READMEs (on-demand)Procedures that apply to some turnsPer-use, when needed”How to ingest a YouTube video”, “How to handle a PDF source”, “How to lint the vault”
Wiki pages (content)Facts, ideas, summariesPer-read, when relevant”Pulp Fiction (1994)”, “Agent Harness”, “Mario Zechner”

Key

CLAUDE.md answers “who am I and what rules always apply?”
Skills answer “how do I do X when X comes up?”
Wiki pages answer “what do I know?”

Confusing these three layers is the most common cause of bloated context files, ineffective agents, and rising API costs.

How harnesses implement on-demand loading

Pi and Claude Code both implement the on-demand layer via a skills mechanism: each skill is a markdown file on disk, but only its name and one-line description (~30 tokens) appear in the always-attached set. The full procedure is read into context only when the task matches. This is the architecture in miniature: a tiny advertisement in the always-attached set, full instructions on disk, lazy-loaded on demand.

See Pi’s docs/skills.md for the implementation, and ~/.pi/agent/skills/ for the skills currently registered on this machine.

What context files actually do to model behavior

A common misconception: that CLAUDE.md makes the LLM “deterministic.” It doesn’t. LLMs sample tokens from a probability distribution, and that sampling stays stochastic regardless of how detailed the system prompt is. What context files actually do is redirect where the variability lives.

Two kinds of variability matter:

KindDescriptionAffected by CLAUDE.md?
Structural conformanceFile naming, frontmatter schema, link syntax, folder placement, required fieldsYes — explicit rules collapse the distribution to ~99% conformance with frontier models
Surface variabilityWord choice, ordering, phrasing, judgment calls (which tags, which aliases, how to summarize)No — remains wide, by design

Worked example — “Create a wiki page for The Matrix (1999)” run three times:

  • Without CLAUDE.md: three different filenames (the-matrix.md, The Matrix (1999).md, matrix-1999.md), three incompatible frontmatter schemas, three different opening structures. The vault becomes incoherent within a week.
  • With CLAUDE.md: all three runs produce the same filename and the same frontmatter schema. The variation moves into which tags, which aliases, how to phrase the opening — i.e., the substance, not the form.

Key

CLAUDE.md does not eliminate randomness — it redirects it.
Explicit rules collapse variability in the dimensions you constrain (form, structure, conventions). Variability remains in the dimensions you leave open (word choice, judgment, synthesis). This is the right trade-off: stable containers holding fresh content.

If output is drifting unpredictably, the answer is almost always “add a more explicit rule.” If prose feels templated and lifeless, you’ve over-constrained — pull back and let the model think.

Two caveats:

  • Temperature (the API’s sampling-randomness parameter, 0–1+) is the dial behind this. Pi defaults to model-appropriate values; you rarely touch it directly. Lower temp = less surface variability across runs.
  • Frontier models follow rules dramatically better than older ones. Claude Sonnet 4.5 and GPT-5 obey explicit system-prompt rules ~95–99% of the time. Older models drifted even with explicit instructions. Minimal harnesses like Pi work now in part because instruction-following capability finally matured.

What happens when two rules in the always-attached set contradict each other is a separate problem with its own discipline — see Writing Conflict-Free Instructions. What happens when the always-attached set plus the transcript starts approaching the model’s context window is yet another problem — see Context Window Management Strategies.

What the Harness Does Per Turn

┌─────────────────────────────────────────────────┐
│                  AGENT HARNESS                  │
│                                                 │
│   ┌──────────┐   ┌──────────┐   ┌───────────┐   │
│   │ Context  │──▶│   LLM    │──▶│   Tools   │   │
│   │ Assembly │   │ (remote) │   │ (local fs,│   │
│   └────▲─────┘   └──────────┘   │  shell)   │   │
│        │                        └─────┬─────┘   │
│        └────── tool results ──────────┘         │
│                                                 │
│   Extensions │ Skills │ Prompts │ Sessions      │
└─────────────────────────────────────────────────┘
        ▲                                ▲
        │ user (TUI / CLI / RPC / SDK)   │ filesystem
  1. Before the call — assemble system prompt + context files (e.g. this vault’s CLAUDE.md) + session history + new user message.
  2. During the call — stream tokens, detect tool-use blocks.
  3. After the call — execute tool calls locally, capture stdout/stderr/files-read, append everything to the transcript, loop.

The harness’s quality is mostly determined by step 1 (what makes it into context) and the affordances of step 3 (which tools, how observable, how reversible).

The Loop: Who Drives, Who Executes

A single turn is straightforward. Multi-turn loops — where the agent reads files, runs commands, edits code, and only eventually returns control to you — are where most confusion about agents lives. Two questions matter: what stops the loop? and who is actually steering it?

What the stop condition actually is

Tool-calling APIs return responses as a list of content blocks. Each block is either a text block or a tool_use block:

{
  "stop_reason": "...",
  "content": [
    { "type": "text",     "text": "Reading auth.py..." },
    { "type": "tool_use", "name": "read", "input": { "path": "auth.py" } }
  ]
}

The harness’s loop is brutally simple:

while (response.content has any tool_use blocks) {
    execute each tool_use
    append tool_result blocks to history
    response = api.call(history)   // next turn
}
// Exit: response had only text blocks. Show it to user.

Equivalent shorthand using the API’s stop_reason field:

  • stop_reason === "tool_use" → loop continues
  • stop_reason === "end_turn" → loop exits, control returns to the user

There is no “task complete” signal. The model has no way to send one (it only emits text — see “The Memory Illusion”). The loop simply ends when the model’s response contains no tool calls.

Safeguards the harness must implement

The model has no awareness of being in a loop. It has no counter, no “retry limit,” no way to detect repetition unless the prior repetitions are visible in the transcript and pattern-match strongly enough to influence the next emission. Every safeguard is the harness’s job:

SafeguardPurposePi’s implementation
Iteration capHard limit on tool calls per user turnConfigurable; aborts loop with an error
Token budgetPer-call max_tokens, optional session capStandard API parameter
Context window checkRefuse the call if transcript would exceed windowTriggers compaction or errors
User interruptImmediately halt the loopEsc / Ctrl+C
Tool-level timeoutsEach tool call has its own time limitbash accepts a timeout argument
Loop / repeat detectionSpot identical tool calls repeatingSophisticated harnesses; Pi: minimal
Cost limitsHalt if running cost exceeds a capPi displays running cost; some harnesses enforce hard caps

Without these, a confused model can burn through a context window in seconds, run up large bills, or oscillate forever between competing edits. The user’s Esc key is the most important safeguard a harness ships — it is the only one guaranteed to work when the model itself is the source of the problem.

The reactive-executor principle

The most important and least-discussed fact about agent harnesses:

Key

The harness is reactive infrastructure. The model is the driver.
The harness doesn’t decide what the agent does next — it only decides whether to let the agent do what the model asked for. The agent’s entire trajectory (which files to read, which edits to make, when to stop) is determined turn-by-turn by the model’s tool-emit pattern. The harness’s role is to (a) faithfully execute those requests, (b) feed the results back, and (c) enforce safety limits. That’s it.

This is a strange architecture if you come from traditional software:

  • In a normal program, you write the control flow and call libraries.
  • In an agent, the model writes the control flow at runtime by emitting tool calls. The harness is the library.

The model is your runtime control flow — a probabilistic, non-deterministic control flow you cannot unit test, single-step, or formally verify.

Three consequences

1. Reliability is leverage at the edges, not at the center.
You cannot reach into the model’s reasoning. The only places you have leverage are:

You cannot make an agent reliable by telling it to be reliable. You make it reliable by constraining what it can see, what it can do, and how long it can do it for.

2. Observability is non-negotiable.
If the model is driving and you can’t see the steering wheel, you’ve lost the loop. This is the deep reason behind Pi (Coding Agent)‘s deliberate omissions:

  • No background bash → every command runs visibly
  • No sub-agents by default → no opaque inner loops
  • No plan mode → plans live in PLAN.md where you can read them
  • Session trees & branching → the model’s trajectory is a versioned, browseable artifact
  • Per-turn token + cost display → you see the meter run

Maximal harnesses (Claude Code Internals) hide loop behavior in conveniences — auto-compaction, hidden quota checks, sub-agent dispatch. Each of those is a place where the model is driving and you can no longer watch.

3. Booboo compounding is structural, not a model bug.
Every turn’s input is the previous turn’s output. If the model misreads a file on turn 3 and forms a wrong belief, turn 4 acts on that wrong belief, turn 5 acts on the wrong action’s results, and so on. The harness has no way to detect “the model went off the rails three turns ago” — it just keeps executing. By turn 15 you have a confidently-wrong agent that has edited 8 files based on a misread on turn 3. This is why Agentic Coding - Risks and Discipline emphasizes slowing down: the harness amplifies early errors rather than dampening them.

The unifying principle

Key

An agent harness is a faithful executor of model intentions, not a controller of model behavior.
The model emits the agent’s trajectory turn by turn through its choice of tool calls. The harness’s job is execution, observation, and bounded safety — not steering. Reliability comes from shaping the model’s inputs (tools, context, constraints), never from overriding its outputs.

This is why agents feel weird: you are not “programming” them. You are configuring an environment where their probabilistic decisions tend to produce useful work. When agents fail, the failure is rarely “the harness did the wrong thing” — it is almost always “the model emitted tool calls that, when executed faithfully, produced bad results.”

What a Real API Trace Looks Like

Everything above is abstract until you see the literal JSON. This section walks through a 3-turn loop on Anthropic’s Messages API — the actual format Pi sends and receives — so the abstractions collapse into something concrete.

Scenario: User says “Read auth.py and tell me what it imports.” Pi has tools read, write, edit, bash registered.

Turn-by-turn sequence diagram

User            Harness (Pi)              LLM API               Filesystem
  │                  │                       │                       │
  │  "Read auth.py"  │                       │                       │
  ├───────────────▶│                       │                       │
  │                  │                       │                       │
  │                  │  TURN 1 REQUEST       │                       │
  │                  │  system + tools +     │                       │
  │                  │  [user msg]           │                       │
  │                  ├─────────────────────▶│                       │
  │                  │                       │                       │
  │                  │  TURN 1 RESPONSE      │                       │
  │                  │  content: [text,      │                       │
  │                  │           tool_use],  │                       │
  │                  │  stop: "tool_use"     │                       │
  │                  │◀─────────────────────┤                       │
  │                  │                       │                       │
  │                  │        fs.readFile("auth.py")                 │
  │                  ├──────────────────────────────────────────▶│
  │                  │        "from flask import Flask..."           │
  │                  │◀─────────────────────────────────────────┤
  │                  │                       │                       │
  │                  │  TURN 2 REQUEST       │                       │
  │                  │  system + tools +     │  ◀─ system, tools,    │
  │                  │  [user msg,           │     and prior turns   │
  │                  │   assistant msg,      │     RE-SENT every     │
  │                  │   tool_result]        │     turn (stateless)  │
  │                  ├─────────────────────▶│                       │
  │                  │                       │                       │
  │                  │  TURN 2 RESPONSE      │                       │
  │                  │  content: [text],     │                       │
  │                  │  stop: "end_turn"     │  ◀─ no tool_use blocks │
  │                  │◀─────────────────────┤     → loop exits       │
  │                  │                       │                       │
  │  "auth.py imports│                       │                       │
  │   Flask, jwt..." │                       │                       │
  │◀─────────────────┤                       │                       │
  ▼                  ▼                       ▼                       ▼

Turn 1 — the LLM’s literal response

This is the actual JSON body that comes back from POST /v1/messages:

{
  "id": "msg_01Aq3kf8x9LpVw7...",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-5-20250929",
  "content": [
    { "type": "text", "text": "I'll read auth.py to see its imports." },
    {
      "type": "tool_use",
      "id": "toolu_01Bv8mP3qR2sN4...",
      "name": "read",
      "input": { "path": "auth.py" }
    }
  ],
  "stop_reason": "tool_use",
  "usage": { "input_tokens": 2543, "output_tokens": 64 }
}

Observe:

  • content is an array of blocks, not a string. The model can mix text and tool_use in one response.
  • tool_use.id must be echoed back so the model can match the result to the request.
  • stop_reason: "tool_use" is the API’s signal: “continue the loop.”
  • input_tokens: 2543 for an 8-word user message — the other ~2,500 tokens are the system prompt + tool schemas + CLAUDE.md, re-sent on this turn and every turn afterward. The per-turn rent made concrete.

Turn 2 — Pi sends the result back

Note the tool_result is wrapped in a user-role message (the harness simulating the world’s response on the model’s behalf — a quirk worth knowing):

{
  "role": "user",
  "content": [
    {
      "type": "tool_result",
      "tool_use_id": "toolu_01Bv8mP3qR2sN4...",
      "content": "from flask import Flask, request, session\nfrom werkzeug.security import check_password_hash\nimport jwt\n..."
    }
  ]
}

Turn 2 — the LLM responds, loop exits

{
  "id": "msg_02Lm9pQ4xT8wK6...",
  "role": "assistant",
  "content": [
    { "type": "text", "text": "auth.py imports Flask, request, session, check_password_hash, jwt, and os..." }
  ],
  "stop_reason": "end_turn",
  "usage": { "input_tokens": 2891, "output_tokens": 67 }
}

Loop exit conditions visible in this single response:

  • content contains only text blocks. No tool_use.
  • stop_reason: "end_turn".

Pi’s while loop sees zero tool calls, exits, and prints the text to the terminal. Control returns to the user.

OpenAI’s equivalent (one note)

OpenAI’s Chat Completions API uses a parallel tool_calls array on the assistant message and role: "tool" for results, with finish_reason: "tool_calls" instead of stop_reason: "tool_use". Same idea, different wrapping. Pi’s pi-ai package abstracts over both formats so the rest of the harness doesn’t care which provider it’s talking to.

What this trace makes obvious

Three things click into place once you see real JSON:

  1. The “agent” is just JSON ping-pong over HTTP. Each turn is one round-trip. There is no hidden state, no daemon, no “thinking in the background.”
  2. “I want to call a tool” and “I’m done” are structurally indistinguishable in the model’s output — the only difference is whether tool_use blocks are present. That’s the entire loop condition.
  3. The per-turn tax is visible in usage.input_tokens. Every turn pays for the system prompt, tool schemas, and full transcript history, regardless of how short the user’s actual message was.

How to see your own traces

Don’t take this on faith — inspect a real session yourself. Do this at least once:

  • claude-trace — Mario Zechner’s tool that intercepts LLM API traffic and logs every request/response payload to disk
  • pi --export <session-id> trace.html — produces a browsable HTML view of every turn including raw payloads
  • Provider dashboards — the Anthropic Console and OpenAI logs page show recent API calls with full bodies

Once you’ve stared at one real trace, every section of this page becomes physically visible — the per-turn cost, the re-sent system prompt, the tool_use blocks, the stop-reason loop condition. The abstraction collapses into mechanics.

The Cluster, Compressed

This page launched a six-page deep-dive on harness architecture. Each companion page applies the same underlying rule to a different concern:

PageConcernApplication of the rule
Context Window Management StrategiesContextDon’t let the model silently rewrite its own past (auto-compaction); keep the user able to edit history visibly (branch, file-as-state, rewind)
Streaming in Agent HarnessesInterrupts and sub-agentsStreaming is the only mechanism that lets the user supervise an LLM in flight; sub-agents are scoped auto-compaction and inherit its failure modes
Tool Design for Agent HarnessesToolsBurden of proof is on first-class tools; minimal toolsets concentrate model probability on well-trained pathways and stay out of the way for everything else
Self-Extending AgentsExtensibilityMinimal toolset and the extension substrate (filesystem) share a substrate, so reliability and extensibility are the same property
Session Observability and ReplayHistoryCapture both actions and the conditions under which the actions occurred, or the record is internally consistent but externally meaningless
Provider Abstraction in Agent HarnessesProvidersHide what’s different where it doesn’t matter; surface what’s different where it does; cross-provider replay is what you get when every other ingredient is right

Key

A good harness enforces what the model can’t enforce on itself, preserves what the user can’t reconstruct on their own, and stays out of the way for everything else.
Tools, context, sub-agents, extensions, sessions, providers — every architectural decision in the cluster is an application of this rule. Pi’s minimalism is a strategy, not an aesthetic: minimal pieces compose, maximal pieces don’t, and the value of a harness is exactly the value of its ingredients composing.

Why “Harness” is the Right Word

The term comes from test harnesses and embedded systems: a fixture that holds a component in place, supplies it with inputs, captures its outputs, and lets a human reason about its behavior. An LLM dropped into a coding loop is exactly that — a powerful but unbounded component that needs to be held, fed, observed, and constrained.

A good harness:

  • constrains — the model can only do what its tools allow
  • observes — every tool call, every result, is visible and replayable
  • reversesibly extends — you can add capabilities without rewriting internals (see Self-Extending Agents)
  • stays out of the way — it doesn’t impose workflows the user didn’t ask for

What Drives Harness Quality

A common question once people understand what a harness is: which parts actually make agents good? The “model vs harness” framing (roughly 30% model, 70% harness) is too coarse to act on. Decomposed, the picture is sharper.

These numbers are directional, not science. They reflect the working consensus across Anthropic’s Building Effective Agents and ACI work, OpenAI’s harness-engineering writeups, the Vercel “removed 80% of tools, got better results” anecdote, and practitioner reports from Manus, LangChain, and Cursor.

ComponentRough shareWhat sits here
Model~30%The LLM weights. You select; you cannot tune. The 1 to 3 point benchmark gap between frontier models is not where wins live.
Tool design~25%Which tools exist, how few, how sharp, how their descriptions read. Tool descriptions are prompts the model reads on every turn. Anthropic doubled performance on some tasks just by rewriting them. See Agent Tools - Design Principles, Tool Design for Agent Harnesses, Agent-Computer Interface (ACI).
Context management~25%What enters the prompt this turn. CLAUDE.md / AGENTS.md, on-demand retrieval, compaction strategy, what stays on disk, attach-vs-read. The biggest source of quiet failures. See Context Engineering, Context Window Management Strategies.
Prompting~15%The always-attached system prompt, the project context file, the per-turn user prompt. Real leverage, smaller than people think. See Writing Conflict-Free Instructions.
Loop, safeguards, observability~5%Iteration caps, plan mode, hooks, permissions, session trees, interrupt UX, replay. Mostly invisible until something breaks. See Session Observability and Replay.

Key

Model 30, harness 70. Of the harness 70, prompting is roughly a third. The other two thirds are tool design and context management.
The instinct to “fix the prompt” is the cheapest move and the smallest lever. Senior practitioners stop talking about prompts because they have already moved on to tools and context.

Where “prompting” actually lives

What people call prompting usually bundles three different things, only one of which is the per-turn user prompt:

  1. The user prompt (what you type today). High variance, low ceiling. A great user prompt on a bad harness still fails.
  2. The system prompt + context files (always-attached, see What Belongs in the Always-Attached Set above). Real leverage, but written once and amortised over thousands of turns. Closer to harness configuration than prompting.
  3. Tool descriptions (per registered tool). The model reads these to decide which tool to use and how. Counts as prompting in spirit but lives inside the tool layer.

If you collapse all three into “prompting”, the share rises to roughly 40 to 45%. That’s only because the relabelling absorbed tool design and context engineering. The decomposition above keeps them separate because the disciplines are separate: rewriting a CLAUDE.md is not the same skill as designing a tool surface.

Order of leverage

Where to spend effort, ranked by yield:

  1. Pick a good model. Free 30%. Do not fight a weak model with a clever prompt.
  2. Fix tool design. Fewer tools, sharper tools, descriptions written like docstrings. The Vercel “remove 80% of tools” pattern is the canonical example.
  3. Curate context. Apply the “every turn” test (see What Belongs in the Always-Attached Set). Decide what lives in CLAUDE.md vs on disk vs loaded on demand.
  4. Write conflict-free instructions. Conditional rules, explicit precedence, no contradictions (Writing Conflict-Free Instructions).
  5. Improve per-turn prompts. The smallest lever. Helps, but will not save a bad harness.
  6. Add loop and safety controls. Important for production trust, marginal for output quality on simple tasks.

The reason the industry talks about prompting first is that it is the most visible. The reason Anthropic spent more time on tool descriptions than the system prompt when building Claude Code is that tools and context dominate the variance.

Choosing or Building a Harness

Questions to ask:

  • What tools does it ship, and can I see the source? (Agent Tools - Practical Starter Kit is a useful baseline.)
  • How is context assembled each turn? Is the system prompt visible? Can I add my own context files? (Context Engineering)
  • What does it refuse to do, and why? Refusals reveal design taste.
  • How do I add capability without forking? Skills, extensions, plugins, MCP — what’s the extension model?
  • Can I observe and replay? Session storage, branching, export.
  • Can I drive it from another program? RPC / SDK / JSON mode.
  • Cost and provider lock-in? Single-provider harnesses age badly.

For most personal use, picking a minimal harness (Pi (Coding Agent)) and extending it beats fighting a maximal one.

Open Questions

  • Where is the boundary between “harness feature” and “skill/extension”? Pi pushes almost everything outward; Claude Code pulls almost everything inward. Is there a principled rule, or is it taste?
  • What’s the minimum harness that still produces a useful coding agent? (Pi is one data point; could it be smaller?)
  • How should harnesses handle long-horizon tasks where context exceeds even compacted history? File-as-state (Pi (Coding Agent)‘s pattern) vs. memory systems (Agent Memory) — when does each win?