Senior engineer and above · 15 minutes · Prerequisite: familiarity with LLM APIs
Slides 03 · Teaching Document 01 · Diagrams 02 · Lab 07
…you are almost always describing the harness, not the model.
Everything else — the loop, the tools, the retries, the permission gates, the safety — is the harness.
MBZUAI study, May 2026. Four independently-built production agents converged on the same harness patterns. The interesting differences live in the 98.4%.
More precisely — the code, config, and runtime scaffolding that:
Miss any one of the three → it's a prompt, not a harness.
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.
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.
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.
2025–2026. Four teams, no coordination, one architecture:
| Team | System | Loop | Tools | Safety |
|---|---|---|---|---|
| Anthropic | Claude Code / Pi | ReAct | registry | 40 flags |
| OpenAI | Codex CLI / Agents SDK | function-calling | registry | 7 sandbox providers |
| Gemini CLI | tool-use loop | registry | auto-approve | |
| OSS | Aider, oh-my-opencode | ReAct | registry | git / role-gated |
Not a quality axis. A design decision. Both ends are correct for their use case.
| Harness | Tools | System prompt | Permission model |
|---|---|---|---|
| Pi | 4 | <1k tokens | trust-the-model |
| Aider | ~8 | ~2k | git-gated |
| Codex CLI | ~10 | ~3k | 3-tier |
| OpenCode | ~15 | ~5k | session-scoped |
| oh-my-opencode | ~20 (meta) | ~8k | role-based |
| Claude Code | 40+ | ~40k | 40 flags |
| NemoClaw | 40+ + governance | ~40k | external 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.
A typical production session. Where the context actually goes:
Tool outputs
Tool definitions
History + rest
System prompt
Model decision logic
Six steps. Same method for every harness in this course.
| # | Find | Search for |
|---|---|---|
| 1 | Entry point | package.json → main |
| 2 | The loop | while around model.complete() |
| 3 | Tool registry | JSON schemas with name + input_schema |
| 4 | Safety layer | permission checks, approval prompts, sandbox calls |
| 5 | Context manager | token counting, truncation, compaction |
| 6 | Write the verdict | loop 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.
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
Next: Module 0.2 — The Ecosystem. Then Module 1 — the loop, in depth.