What Is a Harness?

Module 0.1 · The Landscape · Master Course — Harness Engineering

Senior engineer and above · 15 minutes · Prerequisite: familiarity with LLM APIs

Slides 03 · Teaching Document 01 · Diagrams 02 · Lab 07

When you say "the AI did X"…

…you are almost always describing the harness, not the model.

The model is a function. Tokens in, tokens out. No memory across calls. No code execution. No retries. No sense of time. No permission to ask before deleting a file.

Everything else — the loop, the tools, the retries, the permission gates, the safety — is the harness.

The model is 1.6% of the system

98.4%
harness — infrastructure around the model
1.6%
AI decision logic — the model itself

MBZUAI study, May 2026. Four independently-built production agents converged on the same harness patterns. The interesting differences live in the 98.4%.

Definition

A harness is the infrastructure layer that wraps a language model and gives it the capability to act repeatedly in the world until a task is complete.

More precisely — the code, config, and runtime scaffolding that:

  • LOOP runs the model repeatedly until a stop condition
  • TOOLS provides named, schema-validated functions
  • SAFETY enforces permission and blast-radius boundaries

Miss any one of the three → it's a prompt, not a harness.

The three jobs

JOB 1 — LOOP

The model is stateless. One complete() call produces one response and terminates. The loop turns it into an agent.

while (true) {
  const r = await model.complete(messages);
  if (r.stopReason === "end_turn") return r.content;
  if (r.toolUse) {
    const out = await executeTool(r.toolUse);
    messages.push({ role: "tool", content: out });
  }
  messages.push({ role: "assistant", content: r.content });
}

JOB 2 — TOOLS

A tool = name + description + input schema + implementation + result. The model never executes; it emits a request the harness intercepts.

Pi: 4 tools. Claude Code: 40+. Tool count is the most consequential design decision in harness engineering.

JOB 3 — SAFETY

Permission flags · approval gates · sandboxing · stop conditions · trust boundaries. Safety is a dimension of every architectural decision, not a feature you bolt on.

The loop, as a runnable n8n workflow

Per the course's visual stack: n8n first, then Mermaid, then code. This is the same loop as the TypeScript on the previous slide, in node-graph form — importable as JSON.

       Manual Trigger
            │
            ▼
   Assemble Context ── system prompt + history + tool defs
            │
   ┌────────▼─────────┐
   │      Loop        │  ◀───────┐  stop #1: iteration cap (8)
   │  (maxIter: 8)    │          │
   └────────┬─────────┘          │
            │                    │
            ▼                    │
      Call Model ── tools: read_file, write_file, bash
            │                    │
            ▼                    │
     Stop?  ── yes ──▶ Output (done)
            │ no (tool_use)      │
            ▼                    │
     Route ─▶ read│write│bash    │
            │                    │
            ▼                    │
   Append Tool Result to History ┘  ← ONE TURN per traversal

The model is one node of seven. The turn boundary is the back-edge into Loop — the single most important concept in the course, made visible.

What a harness is not

A fine-tuned model. The model is general-purpose. The harness shapes behavior.

A system prompt. One small input among many.

A framework. LangChain / Agents SDK help build harnesses. The harness is what you build.

An agent. "Agent" = goal-directed behavior of the combined system. The harness is the machinery.

Convergent evolution

2025–2026. Four teams, no coordination, one architecture:

TeamSystemLoopToolsSafety
AnthropicClaude Code / PiReActregistry40 flags
OpenAICodex CLI / Agents SDKfunction-callingregistry7 sandbox providers
GoogleGemini CLItool-use loopregistryauto-approve
OSSAider, oh-my-opencodeReActregistrygit / role-gated
The three-layer structure is the invariant. Thickness is the variable. Learn the invariant → every harness becomes legible.

The thickness spectrum

Not a quality axis. A design decision. Both ends are correct for their use case.

HarnessToolsSystem promptPermission model
Pi4<1k tokenstrust-the-model
Aider~8~2kgit-gated
Codex CLI~10~3k3-tier
OpenCode~15~5ksession-scoped
oh-my-opencode~20 (meta)~8krole-based
Claude Code40+~40k40 flags
NemoClaw40+ + governance~40kexternal governance

Every layer of thickness adds: capability, safety, observability — and also: code to maintain, failure modes, attack surface. The senior skill is defending where on the spectrum a design belongs.

The 1.6% / 67.6% trap

A typical production session. Where the context actually goes:

Tool outputs

Tool definitions

History + rest

System prompt

Model decision logic

If you iterate on the system prompt (3.4%) while ignoring tool-output formatting (67.6%), you are optimizing 3% and neglecting 68%. Modules 2, 3, and 11 harvest this.

Reading a harness from the outside in

Six steps. Same method for every harness in this course.

#FindSearch for
1Entry pointpackage.jsonmain
2The loopwhile around model.complete()
3Tool registryJSON schemas with name + input_schema
4Safety layerpermission checks, approval prompts, sandbox calls
5Context managertoken counting, truncation, compaction
6Write the verdictloop arch · tool count · permission model · spectrum position · why

Lab (artifact 07): run this against Pi's source in 30 minutes — but first see the loop run in n8n.

The map ahead

Module 0.1 introduced the three-layer architecture. The next 12 modules each go deep on one layer or cross-cutting concern:

LAYER DEPTH

1 — Execution Loop
2 — Tool Design & Tool Contract
3 — Context Management
4 — Memory Architecture
5 — Sandboxing & Isolation
6 — Permission, Approval & Safety

CROSS-CUTTING

7 — Error Handling & Recovery
8 — State & Checkpointing
9 — Verification & Feedback
10 — Observability & Debugging
11 — Security Engineering
12 — Capstone: build a production harness

Takeaways

  • The harness is the product. The model is a component.
  • Three jobs: loop tools safety. Miss any one → it's a prompt.
  • Thickness is a design decision, not a quality score.
  • The structure converged. The variation is in thickness.
  • Read any harness in six steps, outside-in.

Next: Module 0.2 — The Ecosystem. Then Module 1 — the loop, in depth.