Harness³: Engineering Self-Adaptive AI Agents

Stop babysitting AI — build a harness that upgrades itself from every failure.

Ohm Mingrath · AI for Developers Conference 2026 · MEGA AI Skills Fest · BITEC Bangna · 30 Nov 2026

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

LevelWho 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:

"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).

LaneAttacks blocked (2 runs)Avg cost/run
A · Haiku 5.5 alone50 · 50 (6/12, FAIL)$0.009
B · Opus 5.5 alone100 · 100 (12/12, PASS)$0.416
C · Haiku + evolved harness100 · 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, then 12/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 (2 runs/lane, $0.068 vs $0.416 ≈ 6×) separate from the Claude Agent SDK numbers in Controlled results below (4 unseen runs/condition, $0.030 vs $0.332 = 11×).
ADK lane wiring (reference snippet — demo repo not public yet)
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:

  1. Pick 1–3 mistakes AI keeps repeating in your PR reviews.
  2. Write 1 check command (npm test or a short script) that catches them.
  3. Wire it to the Stop hook in .claude/settings.json.
.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)

  1. Write clear error messages. Point straight to the exact file, row, or field so AI fixes it on the first try.
  2. Set timeout longer than your test time. If the test times out, the hook is dropped and AI finishes anyway.
  3. 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.

eval/run.ts (core wrapper)
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.

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 px wide on a 390 px screen.
  • 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_EXECPATH in a separate short-task test (outside the 21 main runs). Post-run audit caught 16 hits → we threw the run away, scrubbed the env, and re-ran → 0 hits.

Steps 3–4: The self-healing repo & git revert

Repo layout

Step 3: The self-healing repo

  1. Run the frozen small worker (claude-haiku-5-5) on practice tasks and save the failure logs.
  2. The Coach AI (claude-opus-5-5) reads those logs and edits only ./harness/:
    • Rules in CLAUDE.md when the fix is describable (e.g. +19 lines in Security v5).
    • Tools in tools/score.js when the fix is visual (e.g. a 37-line self-check mirror in UI v7).
  3. 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.

eval/evolve.ts (~120 lines core loop)
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/10 functional tests
  • Security attacks blocked: Haiku alone 6/12 (5 SSRF + 1 CSV formula breached) → Opus 12/12 · Haiku + harness 12/12
  • Coach wrote +19 lines in CLAUDE.md (1 kept, 4 reverted) · 0 sealed-path hits
  • 11× cheaper: $0.030 vs $0.332 · 2.5× slower: 189s vs 75s

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.js mirror + 9 lines in CLAUDE.md (1 kept, 4 reverted) · 0 audit hits in 1,102 tool calls
  • 7.6× cheaper: $0.093 vs $0.709 · 3.1× slower: 481s vs 156s

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-matrix page, raw Opus still edged ahead: 93.9–95.5% vs 92.2–94.3%.
  • Raw Opus broke the "no <script>" rule on cloud-cost run 2 (that run scored 0%).
  • 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).

Follow and work with Ohm