Lesson 1 of 5 · 4 min read
Anatomy of an Agent Harness
In this lesson
TL;DR: The model proposes; the harness does everything else. It runs the loop, executes tools for files, shells and the web, decides through permissions which proposed calls actually run, keeps an append-only session log from which every model request can be rebuilt, manages context so long runs stay coherent, spawns subagents for isolated work, loads skills that package procedures, fires hooks at fixed events, and confines execution in a sandbox. A framework gives you parts to assemble a harness; a harness is the assembled, opinionated whole. Swap the harness and the same model gets better or worse, which is why harness engineering became its own discipline in 2026.
After this lesson, you should be able to name the components of a harness and what each decides, distinguish a harness from a framework and from the model, explain why an append-only log is the harness's backbone, and say which component to change for a given failure.
Before you read
Commit to an answer now. The lesson that follows explains it, and having guessed first, even wrongly, makes the explanation easier to remember.
1Two teams run the same model on the same coding benchmark and report scores ten points apart. Neither fine-tuned anything. Where would you look first?
The parts
Loop
turns and steps
- Call the model, run tools, repeat
- Named exits and budgets
Tools
files, shell, search, web
- Descriptions the model reads
- Errors as observations
Permissions
which calls run
- Allow, deny, ask
- Checked in code, per call
Session log
append-only
- Every model request rebuildable
- Resume, fork, audit
Context management
what the model sees
- Clear old tool results
- Compact, keep notes
Subagents
isolated work
- Own context and budget
- Return a summary
Skills and hooks
procedures and events
- Packaged instructions and scripts
- Code at fixed events
Sandbox
where commands run
- Filesystem and network limits
- No secrets inside
| Component | Decides | Typical failure when it is weak |
|---|---|---|
| Loop | When to call the model, when to stop | Runs that never end, or end on "I'm done" without verification |
| Tools | What the agent can do and how it reads results | Wrong tool chosen from a vague description; errors that read as success |
| Permissions | Which proposed calls actually execute | A destructive command runs because nothing asked |
| Session log | What happened, reconstructably | A failure nobody can replay or explain |
| Context management | What the model sees on long runs | Quality drops as old tool output crowds the window |
| Subagents | Where exploratory work happens | The main context fills with search results |
| Skills and hooks | Reusable procedures; policy at events | The same procedure re-explained in every prompt; policy only in prose |
| Sandbox | The blast radius of a command | A test script reads credentials or reaches production |
Harness, framework, model
The model produces the next message given what it sees. A framework offers parts and patterns for building agents: state graphs, handoffs, checkpointers. A harness is an assembled runtime with opinions about every component above, usually shipped as a product (a coding agent, an agent SDK that wraps one, an open harness you run yourself). Packaged harnesses in 2026 include the Claude Agent SDK, which runs Claude Code's harness as a library; LangChain's Deep Agents; AWS's Strands harness; and DeepSeek Harness, built so that every component is a replaceable plugin.
The log is the backbone
The single most useful design rule for a harness comes from DeepSeek Harness's architecture notes: model-visible means logged. Every model request must be reconstructable from an append-only log of events. That one property gives you replay for debugging, resume after a crash, forks for trying an alternative, audits for what the agent saw before it acted, and evaluation on recorded runs.
import json
log = [] # append-only session log
def record(kind, **data):
log.append({"seq": len(log), "kind": kind, **data})
def derive_messages(events, upto):
"""Rebuild exactly what the model saw at a given point, from the log alone."""
msgs = []
for e in events[:upto]:
if e["kind"] == "user":
msgs.append({"role": "user", "content": e["text"]})
elif e["kind"] == "tool_result":
msgs.append({"role": "tool", "content": e["result"]})
elif e["kind"] == "assistant":
msgs.append({"role": "assistant", "content": e["text"]})
elif e["kind"] == "compaction":
msgs = [{"role": "user", "content": "Summary so far: " + e["summary"]}]
return msgs
record("user", text="Fix the failing test in billing/")
record("tool_result", result="FAILED test_refund_rounding")
record("assistant", text="Rounding uses float; switching to Decimal.")
record("compaction", summary="test_refund_rounding fails on float rounding")
record("tool_result", result="1 passed")
request_at_step_5 = derive_messages(log, 5)
print(len(log), json.dumps(request_at_step_5[0]["content"]))
# => 5 "Summary so far: test_refund_rounding fails on float rounding"
Because compaction is itself an event, the log shows not only what the model was told after compaction but also what it was no longer told. That is the question you need answered when a long run goes wrong after a summary dropped a detail.
Which part to change
- The agent chooses the wrong tool: tool descriptions and the tool set for this task.
- It degrades late in long runs: context management (clearing, compaction, notes, subagents).
- It does something it should not: permissions and the sandbox, never the prompt alone.
- It ends without finishing: the loop's exits and a verification step.
- Nobody can explain a failure: the session log and its trace export.
Research in 2026 made this explicit: Google's Harness² improved agents on several benchmarks by editing prompts, tool guidance, memory, skills, subagents and middleware, with the model weights frozen. The lesson is not that one harness is best, but that the harness is a large, tunable part of the system's quality.
Say it in 30 seconds
"A harness is the runtime around the model: the loop, tools for files and shells, a permission layer that decides which calls run, an append-only session log, context management, subagents, skills, hooks and a sandbox. A framework gives you parts; a harness is the assembled whole, like the Claude Agent SDK, Deep Agents or DeepSeek Harness. Its backbone is the rule that anything the model saw is logged, so every request can be rebuilt for replay, resume, forks and audits. When an agent fails I ask which component decided the failure, because the same model behaves very differently in different harnesses."
Check yourself
Answer aloud or on paper before revealing. Producing the explanation unaided is exactly what a panel listens for.
1What does 'model-visible means logged' require, and what does it give you?
2An agent's quality drops after two hours of work on a large task. Which harness component do you look at first?
3How is a harness different from a framework?