The model alone only predicts text: it doesn't remember, can't see your files, can't act and can't check. The one doing the work in Claude Code and Codex is the harness, the program around the model. When the agent fails, the useful question is almost never "try again": it's which piece of the harness is missing. In this lesson you take inventory of yours.
1What the model does on its own and what it doesn't
2The five pieces of the harness and the loop that ties them together
3Where each piece lives in your Claude Code and your Codex
4Reading an agent failure as a missing piece
Goal: list the pieces of the harness on your machine (context, memory, tools, verification, permissions) and say which one holds back each failure.
01 · The model and what sits around it
Click each block: what the piece does and where it lives on your machine.
Lesson 201 · The model and what sits around itClick each block: what the piece does and where it lives on your machine.
1/7
Context
At the start of each session the model knows nothing about your project. The harness loads the rules (CLAUDE.md in Claude Code, AGENTS.md in Codex), the folder structure and what changed. You write it once; it reads it every session.
Scroll the page: each step below lights up its part of the diagram.
1/7
Context
At the start of each session the model knows nothing about your project. The harness loads the rules (CLAUDE.md in Claude Code, AGENTS.md in Codex), the folder structure and what changed. You write it once; it reads it every session.
2/7
Memory
The longer the session, the fuller the context window. The harness compacts: it keeps the goal and shrinks the old steps. Compacting too much loses detail; that's why long loops keep state in a file (lesson 5) and course 2 covers the context bands.
3/7
Tools
The model only produces text. When that text is a tool request (read a file, run a command, edit), the harness executes it and hands the result back to the model. MCP is the standard way to plug in tools from other systems.
4/7
Verification
Without verification, the model looks at the code and says "looks good." With it, the model runs the test and reads the result. A real result is worth more than the AI saying it's fine. This is the piece the loop needs most (lessons 1 and 6; course 1).
5/7
Permissions
The harness checks each action before running it: editing goes through, deleting asks. Hooks run your scripts before and after tools; the sandbox limits what a command can reach. In a loop with nobody watching, this is what holds back the blast radius (course 4).
6/7
Agent loop
Putting it all together: the model thinks and asks for a tool, the permission check looks at it, the harness runs it, the result comes back, and the cycle continues until the goal is met. The harness doesn't make the model smarter; it makes it more useful.
7/7
Failed? Find the piece
Forgot the project rule: context. Lost the thread after hours: memory. Couldn't do it: tools. Said it was done when it wasn't: verification. Did something it shouldn't have: permissions.
Claude Code and Codex are harnesses. The same model in different harnesses gives different results.
02 · Two lessons from people who build harnesses
From public engineering posts (research from 10/19/2026).
1. Ask what's missing
In the post "Harness engineering," the central lesson is this: when the agent fails, ask which capability, context, or structure is missing, instead of telling it to try harder.
In practice: the fix goes into the harness (a rule in AGENTS.md, a tool, a test), not into a more emphatic prompt.
2. Every piece is an assumption
In the post about the harness for long-running apps, the team needed context resets with handoff for a model that wrapped up early; in a later model the behavior went away and the resets were removed, leaving automatic compaction.
Lesson: every piece of the harness encodes an assumption about the model. Switching models means re-evaluating the pieces.
03 · Inventory of your harness
Read-only: nothing is changed. Run it on your machine and write down what shows up.
Terminal · context and memory
ls -la ~/.claude/CLAUDE.md ~/.codex/AGENTS.md 2>&1
wc -l ~/.claude/CLAUDE.md ~/.codex/AGENTS.md 2>/dev/null
ls CLAUDE.md AGENTS.md 2>&1 # in the current project
Terminal · tools (MCP) and skills
claude mcp list
ls ~/.claude/skills 2>/dev/null | wc -l
Terminal · Claude Code permissions and hooks (user and project; run in the project folder)
python3 - <<'PY'
import json, pathlib
for p in (pathlib.Path.home() / ".claude/settings.json", # user
pathlib.Path(".claude/settings.json"), # project (goes to git)
pathlib.Path(".claude/settings.local.json")): # project, only on this machine
if not p.exists():
print(f"{p}: não existe")
continue
d = json.loads(p.read_text())
perm = d.get("permissions", {})
print(f"{p}: hooks {sorted(d.get('hooks', {})) or 'nenhum'} · allow {len(perm.get('allow', []))} · deny {len(perm.get('deny', []))}")
PY
Terminal · Codex sandbox and approval
grep -nE '^(sandbox_mode|approval_policy)' ~/.codex/config.toml || echo "padrão do Codex (sem chave no config)"
harness.md · template to fill in
# My harness — <date>
contexto: <files with the rules the agent reads on startup>
memória: <how I keep what can't be lost: handoff, state files, nothing>
ferramentas: <MCP and skills I actually use>
verificação: <the command that proves it worked in my main project>
permissões: <hooks and allow/deny rules; Codex sandbox>
peça mais fraca: <which one and why>
04 · Video: the harness from the inside
Context, memory, tools, verification, permissions, and the agent loop, one piece per chapter (10/10/2026).
On your machine. Only move on to the next one when the "done when" is true.
E1 · Inventory
15 min
Run the four inventory blocks and fill in harness.md with what showed up, one line per piece. Write the markers at the start of each line exactly as they appear in the template: the "done when" grep looks for them.
Done when:grep -cE '^(contexto|memória|ferramentas|verificação|permissões):' harness.md → 5, and grep -c '<' harness.md → 0 (no template placeholder was left unfilled).
E2 · Is the context actually read?
10 min
Add an easy-to-check rule to the project's CLAUDE.md (or AGENTS.md), for example "every answer ends with the word CONFERIDO". Open a new session and ask for anything.
Done when: The new session's answer ends with CONFERIDO without you asking. Then delete the rule: grep -c CONFERIDO CLAUDE.md → 0.
E3 · One failure, one piece
10 min
Think of a real agent failure from the past few weeks. In harness.md, write the line "peça mais fraca:" with the piece that owns the failure and the fix that goes into the harness, not into the prompt.
Done when:grep '^peça mais fraca:' harness.md → one line that names one of the five pieces and a concrete file, command, or tool.
06 · Lesson quiz
Question 1 of 4
Every new session the agent forgets that the project uses pnpm and runs npm. Which harness piece fixes this?competency
Correct
It's project knowledge the model doesn't have at the start; the harness loads it through the rules file. Switching models doesn't fix it: no model guesses your project's convention.
Not that one
It's project knowledge the model doesn't have at the start; the harness loads it through the rules file. Switching models doesn't fix it: no model guesses your project's convention.Review: The model and what sits around it
Question 2 of 4
The agent said "I fixed the bug" and the bug is still there. Which piece was missing, and what's the harness fix?
Correct
Without verification, "I fixed it" is an opinion. A test that fails before and passes after turns opinion into proof. Explaining better helps, but it doesn't stop the agent from approving itself.
Not that one
Without verification, "I fixed it" is an opinion. A test that fails before and passes after turns opinion into proof. Explaining better helps, but it doesn't stop the agent from approving itself.Review: The model and what sits around it
Question 3 of 4
According to Anthropic's March 2026 engineering post, what should you do with the harness when you switch models?
Correct
Context resets existed because of one model's behavior; in the next model the behavior went away and the piece came out. A piece that's no longer needed only costs you.
Not that one
Context resets existed because of one model's behavior; in the next model the behavior went away and the piece came out. A piece that's no longer needed only costs you.Review: Two lessons from people who build harnesses
Question 4 of 4
Why does the same model give different results in Claude Code and in Codex?competency
Correct
Choosing the tool means choosing its harness. The model decides; the harness defines what it knows, what it can do, and how it checks.
Not that one
Choosing the tool means choosing its harness. The model decides; the harness defines what it knows, what it can do, and how it checks.Review: The model and what sits around it
Quiz complete
You got {a} of {n} right. Get them all right and the lesson is marked as complete.
Choose one answer. The explanation appears after you try.
07 · In three sentences
The model decides, the harness doesContext, memory, tools, verification, and permissions sit around the model, and the loop ties them together.
A failure has an ownerBefore trying again, ask which piece was missing and fix it in the harness.
Re-evaluate with each modelEach piece encodes an assumption about the model; a new model calls for a review.