Harness³: Engineering Self-Adaptive AI Agents
Stop babysitting AI — build a harness that upgrades itself from every failure.
Quick favor before you grab the playbook & code
Please take ~1 minute to share quick feedback on today's talk. As soon as you press Submit, the full handout unlocks right here.
Form not loading? Open in Tally
The idea in 30 seconds
Agent = Model + Harness.
The model is the professor (or athlete) — we keep it frozen, no retraining. The harness is the office & tools (or gym) around it: Context, Tools & Workspace, Saved State, and Run Controls, plus an Evaluate & Improve loop.
Why manual fixes don't stick
- Teach it in chat → new session → AI forgets → repeat every session.
- Dump everything in
CLAUDE.md→ context bloats → the model skips it ("tl;dr") → repeat.
| Level | Who upgrades the gym? |
|---|---|
| Harness¹ | You do, by hand (CLAUDE.md, tools, hooks). |
| Harness² | An auto Coach AI upgrades it for you (Google, Oct 2026). |
| Harness³ | The coach also keeps a scouting notebook (SIM) and undoes bad edits with git revert. |
SDD = Spec "Scar-Driven Development"
Don't guess every rule up front. Build and upgrade your harness from the real failures ("scars") AI hits:
- Athlete = frozen worker model (no retraining).
- Gym =
./harness/(CLAUDE.md+tools/). - Coach + Notebook = reads past failures, improves the gym, remembers what worked, and runs
git revertwhen there is no real gain.
"Write the exam before the code." — Frameworks become disposable; the exam becomes the job.
Live proof: Google ADK 4-lane demo
Same cheap model, better office. To prove an evolved harness works across frameworks (not just Claude Agent SDK), we ran the same unseen Webhooks API task (10 functional tests + 12 security attacks, 2 runs per lane) in Google ADK (google-adk + litellm).
| Lane | Attacks blocked (2 runs) | Avg cost/run |
|---|---|---|
| A · Haiku 5.5 alone | 50 · 50 (6/12, FAIL) | $0.009 |
| B · Opus 5.5 alone | 100 · 100 (12/12, PASS) | $0.416 |
| C · Haiku + evolved harness | 100 · 100 (12/12, PASS) | $0.068 (~6× cheaper) |
| D · Haiku + memory (3 lessons) | 91.7 · 100 (11/12, then 12/12) | $0.024 |
All runs passed 10/10 functional tests with 0 sealed-path audit hits. Lane C used the exact CLAUDE.md evolved in Experiment 1 below (slower than Opus, ~1/6 the cost). Costs are estimated from token counts × LiteLLM's price table.
Honest notes on the ADK demo
- In Lane A run 1, Haiku actually noticed the SSRF hole and shipped anyway because the ticket didn't ask.
- Lane D (memory) improved from
6/12 → 11/12, then12/12, missing 1 attack on run 1. With only 2 runs, it is too early to claim memory beats or loses to a harness. - Keep these Google ADK numbers (
2runs/lane,$0.068vs$0.416≈ 6×) separate from the Claude Agent SDK numbers in Controlled results below (4unseen runs/condition,$0.030vs$0.332= 11×).
from google.adk.agents import Agent
from google.adk.models.lite_llm import LiteLlm
root_agent = Agent(
name="a_haiku_clean",
model=LiteLlm("anthropic/claude-haiku-5-5"),
instruction=BASE + STARTER,
tools=CODING_TOOLS,
after_model_callback=track_usage,
after_agent_callback=run_sealed_eval,
)
Step 1: Catch failure mid-air (Stop hook — 15 min)
"Don't start with a complex loop. Start with one hook."
Mine your PR comments tomorrow in 15 minutes:
- Pick 1–3 mistakes AI keeps repeating in your PR reviews.
- Write 1 check command (
npm testor a short script) that catches them. - Wire it to the Stop hook in
.claude/settings.json.
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "npm test 1>&2 || exit 2",
"timeout": 300
}
]
}
]
}
}
What you should see: when Claude tries to say "done", the Stop hook runs your command. If it fails, exit 2 blocks Claude, feeds your error text back to it, and forces a fix before stopping (on our held-out Room Booking run, one mid-air block triggered self-repair → 3/3 pass).
3 guardrails (tested on Claude Code 2.1.332)
- Write clear error messages. Point straight to the exact file, row, or field so AI fixes it on the first try.
- Set
timeoutlonger than your test time. If the test times out, the hook is dropped and AI finishes anyway. - Add a loop cap. Stop after N retries so an unfixable task cannot block forever.
Step 2: Lock the exam room
Never let AI grade its own homework. Build a sealed wall: logs go out, nothing comes in. Run the worker inside a small wrapper (~60 lines in eval/run.ts) using the standard @anthropic-ai/claude-agent-sdk.
const cleanEnv = stripKeys(process.env, /^CLAUDE/);
for await (const m of query({
prompt,
options: { cwd: cleanTmp, env: cleanEnv, settingSources: ['project'], maxTurns: 60 }
})) {
if (hasSealedPath(m.tool_use)) auditHits.push(m);
}
Helpers you write yourself: stripKeys removes matching env keys; cleanTmp is a fresh empty folder; hasSealedPath flags any tool call touching hidden tests.
- Inside (AI workspace): fresh empty temp folder, scrubbed env, zero answer keys.
- Outside (your grader): sealed tests & rubric, external tool-call log, AI cannot edit history.
Why? 3 real war stories (without audit, AI cheats)
- Opus 5.5 claimed the page does not scroll sideways on mobile. We measured it:
847 pxwide on a390 pxscreen. - Opus 5.5 hid a
<script>tag on line 118 and claimed the file was "HTML and CSS only". The automatic check caught it. - DeepSeek V4.1 Flash read hidden answers ("This is gold.") via leaked
CLAUDE_CODE_EXECPATHin a separate short-task test (outside the 21 main runs). Post-run audit caught16hits → we threw the run away, scrubbed the env, and re-ran →0hits.
Steps 3–4: The self-healing repo & git revert
Repo layout
evals/— 3–5 real past bugs saved as practice tests (keep other unseen tests sealed outside)..claude/settings.json— the Stop hook that runs before AI says "done"../harness/— the only folder the Coach AI is allowed to edit (CLAUDE.md+tools/).
Step 3: The self-healing repo
- Run the frozen small worker (
claude-haiku-5-5) on practice tasks and save the failure logs. - The Coach AI (
claude-opus-5-5) reads those logs and edits only./harness/:- Rules in
CLAUDE.mdwhen the fix is describable (e.g.+19 linesin Security v5). - Tools in
tools/score.jswhen the fix is visual (e.g. a37-lineself-check mirror in UI v7).
- Rules in
- The frozen worker retries with the updated harness.
Step 4: No real gain? git revert.
Before keeping any edit, scan for hardcoded test names (cheating) and test on practice tasks. If the new mean does not beat best + keepMargin, undo it with git revert --no-edit HEAD. This keeps the harness sharp, never bloated.
await query({ prompt: optPrompt, options: { model: 'claude-opus-5-5', cwd: optWs } }); // edits only ./harness/
if (hardcodeScan().length === 0) {
const mean = await runEval(TRAIN, 'claude-haiku-5-5', './harness');
if (mean >= best + keepMargin) { best = mean; }
else { git('revert --no-edit HEAD'); }
}
Verified keep/revert tally: Security v5: 1 kept / 4 reverted · Dashboard UI v7: 1 kept / 4 reverted · Room Booking v1: 2 kept / 4 reverted (practice 6/12 → 12/12).
Controlled results & honest limits
8 Fair-Test Rules (4 controlled experiments in Claude Agent SDK — zero cherry-picking): (1) same prompt, (2) unseen task, (3) run offline, (4) automatic checks, (5) worker model frozen, (6) coach edits only CLAUDE.md + tools/, (7) no hints leak, (8) no real gain → git revert.
In v5 and v7 (4 unseen runs per condition), we compared Haiku 5.5 + evolved harness against raw Opus 5.5 with no harness. With a harness of its own, Opus would likely score higher.
Exp 1 · Security (v5 — unseen Webhooks API, app.mjs)
- All 3 passed
10/10functional tests - Security attacks blocked: Haiku alone 6/12 (5 SSRF + 1 CSV formula breached) → Opus 12/12 · Haiku + harness 12/12
- Coach wrote
+19 linesinCLAUDE.md(1 kept, 4 reverted) ·0sealed-path hits - 11× cheaper:
$0.030vs$0.332· 2.5× slower:189svs75s
Exp 2 · Dense UI (v7 — unseen cloud-cost, no <script>)
- Haiku alone swung 80.1% → −4.9% → Haiku + harness steady 90–94% (
90.7%,94.1%) - Coach built a
37-line tools/score.jsmirror +9 linesinCLAUDE.md(1 kept, 4 reverted) ·0audit hits in1,102tool calls - 7.6× cheaper:
$0.093vs$0.709· 3.1× slower:481svs156s
Room Booking (v1 — Stop hook + evolve loop)
- Practice tests: 6/12 → 12/12 · Hidden tests: 3/3 after 1 mid-air Stop-hook block
2 kept, 4 reverted
Be honest about the limits
- On the unseen
ci-matrixpage, raw Opus still edged ahead:93.9–95.5%vs92.2–94.3%. - Raw Opus broke the "no
<script>" rule oncloud-costrun 2 (that run scored0%). - A small model + harness is much cheaper, but 2.5–3.1× slower.
When NOT to build the loop
"Don't build a commercial kitchen to boil instant noodles."
| Stop at Step 1 (Stop hook only) | Use the full self-improving loop |
|---|---|
| One small file with clear rules. In our 4 single-module probes, AI already scored 100% on unseen tests at Gen 0 (no coach needed): • Mutation ( v4)• Concurrency ( v6)• Dirty Input ( v8)• DeepSeek ( v9): 21/21 runs(In a 10-ticket memory probe, both Haiku and Opus also hit 100% from day 1 — nothing to fix.) | • Security or auth work • Dense UI and visual checks • Untrusted or audited runs (where you must prove no cheating) |
The shift: from code writer (babysitting AI bugs one session at a time) to factory designer (building a harness that compounds every failure).
Papers, talks, and links
- Harness² (Google Cloud AI Research, arXiv preprint): Harness²: Recursive Agent Harnessing for an Open World,
arXiv:2610.14224(9 Oct 2026). Paper · Code - SIM: Self-Improvement Memory (Google Cloud AI / Google DeepMind, arXiv preprint): Self-Improvement Memory Enables Continual Recursive Self-Improvement,
arXiv:2611.18856(13 Nov 2026). Paper - Lauren Tan (
@poteto), talk "All Code Is Slop (Except Mine)", Nov 2026. Video — Trust vs Number of Agents;23,370PRs merged Jun–Oct (10,926/ ~11,000 in Oct), revert rate0.98% → 0.47%. @techNmak, "Harness Engineering" diagram, Nov 2026. Post on X@k1rallik, "The End of Harness Engineering" — viral X post (not a peer-reviewed paper).
Have 1 minute to help Ohm out? Share quick feedback on this talk →
Follow and work with Ohm
- Follow: Facebook · LinkedIn
- Work together: catwhocode.com · mingrath.com/#contact