Back to Blog
AICodingTechnologyLearning
Read invien

What is an agent harness? Examples, flowcharts, and popular harnesses in 2026

The model is only the brain. The harness is the product: loop, tools, sandbox, verify, skills. A deep guide with flowcharts, comparisons of Cursor, Claude Code, Codex, OpenHands, and a minimal checklist for apply-AI builders.

·18 min read
Listen
1 / 47

What is an agent harness?

In 2023 everyone talked about prompt engineering. In 2025–26, teams shipping real agents talk about harness engineering.

Short formula:

Agent = Model + Harness

The model emits tokens. The harness connects the model to the world: the loop, tools, permissions, sandbox, context packing, verification, and human-in-the-loop (HITL).

For: apply-AI / fullstack builders — chatboxes, coding agents, internal agents — not people training base models.

Circuit board — the harness is infrastructure around the model

Takeaway: Swapping models rarely fixes a broken agent. Fixing the harness (tools + verify + permissions) does.

Related: MCP · Skill · Subagent · Learn → AI Roadmap (Agents + harness phase).


1 · A harness is not “an agent framework”

People confuse harnesses with LangChain / LangGraph. In practice (including 2026 source audits of ~11 production coding harnesses), most runtimes ship a hand-rolled async loop. Few import a generic agent framework.

PieceWhat it isExamples
ModelLLM APIClaude, GPT, Gemini, local
HarnessRuntime around the modelCursor Agent, Claude Code, Codex CLI, OpenHands
Outer harness (yours)Rules / skills / hooks / tests around a bought toolAGENTS.md, pre-commit, CI eval

Thoughtworks / Martin Fowler’s framing: your configuration layer around a coding agent is an outer harness — guides (steer before) + sensors (correct after).


2 · Flowchart 1 — one agent step

This is the spine of most coding agents (Claude Code, Cursor, Codex, OpenHands…):

                    ┌─────────────┐
                    │  User goal  │
                    └──────┬──────┘
                           ▼
              ┌────────────────────────┐
              │  Context pack          │
              │  system + rules +      │
              │  skills + file/RAG     │
              └────────────┬───────────┘
                           ▼
                 ┌──────────────────┐
            ┌───►│  LLM decide      │◄──────────────────────────┐
            │    │  (think / act)   │                           │
            │    └────────┬─────────┘                           │
            │             │                                     │
            │      ┌──────┴──────┐                              │
            │      ▼             ▼                              │
            │   Text reply    Tool call                         │
            │      │             │                              │
            │      │             ▼                              │
            │      │      ┌──────────────┐                      │
            │      │      │  Permission  │──deny──► explain     │
            │      │      │  allowlist   │                      │
            │      │      └──────┬───────┘                      │
            │      │             ▼                              │
            │      │      ┌──────────────┐                      │
            │      │      │  Sandbox /   │                      │
            │      │      │  workspace   │                      │
            │      │      └──────┬───────┘                      │
            │      │             ▼                              │
            │      │      ┌──────────────┐                      │
            │      │      │  Execute     │                      │
            │      │      │  (fs/shell)  │                      │
            │      │      └──────┬───────┘                      │
            │      │             ▼                              │
            │      │      ┌──────────────┐     fail             │
            │      │      │  Verify      │─────────────┐        │
            │      │      │  lint/test   │             │        │
            │      │      └──────┬───────┘             │        │
            │      │          ok │                     ▼        │
            │      │             │              tool result     │
            │      ▼             └───────────────────► append ──┘
            │   Done / HITL ask human
            └──

How to read it: “Done” is not the model announcing success — verify (tests/lint/scripts) or HITL is the gate.

Bright terminal — sandbox + shell are the harness’s hands


3 · Seven harness blocks (minimal → serious)

From production coding-harness anatomy:

#BlockMinimalSerious
1Loopwhile tool_callturn budgets, stop rules, parallel tools
2Toolsread/write/shellbrowser, MCP, LSP, subagents
3Permissionsask on every writepath / command / network allowlists
4Sandboxproject cwdDocker / worktree / VM
5Contexttruncate chatrules, skills, progressive disclosure, compact
6Verify“please self-check”hooks: lint, test, typecheck before Done
7Orchestrationone agentplanner/critic, subagents, handoffs

Apply-AI / SME: ship 1–6. Add 7 when you have a team or you’re selling an agent platform.


4 · Example 1 — support chatbox (not a coding agent)

Goal: FAQ widget for a shop; escalate when unsure.

User message
    │
    ▼
[Input guard] ── PII / injection? ──► refuse / sanitize
    │
    ▼
[Retrieve] FAQ chunks (RAG) + order policy
    │
    ▼
[LLM] draft answer + confidence
    │
    ├── low confidence ──► [HITL / human queue]
    │
    ▼
[Output guard] no invented prices / legal claims
    │
    ▼
Reply + trace log (Langfuse-style)

The harness here: guards + RAG + HITL + traces — not “clever prompts.” Models are swappable; those blocks are what you sell.


5 · Example 2 — mini coding agent (Roadmap harness project)

Goal: “Fix bug X in the repo; only mark Done when tests pass.”

Goal: fix failing test auth.spec.ts
    │
    ▼
[Skill: ship-check] load playbook
    │
    ▼
Agent: read failing test + source
    │
    ▼
Agent: edit files (allowlist src/** only)
    │
    ▼
Harness hook: pnpm test auth.spec.ts
    │
    ├── fail ──► append output ──► agent retry (max 3)
    │
    ▼
pass → summarize diff → human merge

No test hook → agents hallucinate Done. That’s why Flo-style platform diagrams always draw Agent Sandboxes + Evaluation.

Checklist on a desk — verify is the cheapest sensor


6 · Guides vs sensors (outer harness)

Thoughtworks framing:

Guide (steer before)Sensor (correct after)
Computationalcodegen templates, codemodslint, tsc, unit tests, ArchUnit
InferentialAGENTS.md, Skills, system promptLLM-as-judge, AI code review

Rule of thumb: computational sensors on every agent edit (cheap). Inferential sensors on PR / nightly (expensive).

Human steering loop:

  1. Agent repeats a mistake →
  2. Add a short guide or a sensor that catches it →
  3. Next time, less manual review.

7 · Popular harnesses in 2026

Product-feel table — not a lab leaderboard:

HarnessShapeStrengthsCommon pain
Cursor AgentIDE + cloud/local agentUX, rules/skills, MCP, subagentsContext bloat without tight rules
Claude CodeCLI / IDE agentStrong tool loop, permissions, skillsNeeds sandbox discipline; cost if unbound
OpenAI Codex CLI / CodexCLI + internal App ServerWorktree isolation, subagent config, harness-as-platformRepo-convention learning curve
Gemini CLICLI agentGoogle stack fitSkills/MCP ecosystem less even
OpenHandsOpen-source agent platformSelf-host, research + productHeavier ops than “install an IDE”
AiderGit-centric CLIClear diff/commit workflowLess “platform” than Cursor
Mini-SWE-Agent / SWE-agent familyResearch → practicalBenchmark-oriented loopsNot a full IDE product
Your product harnessWhite-label / internalFits ICP, billing, auditYou own verify + tenancy

Cross-cutting note from community source audits: skills and MCP are widespread; coding harnesses often use deterministic retrieval (grep/paths), not “vector everything.”

Agent architecture — many layers around the model


8 · Flowchart 2 — which harness? (apply AI)

What do you need?
    │
    ├── Daily code edits in a repo
    │       └── Cursor or Claude Code / Codex
    │             + outer harness (rules + tests)
    │
    ├── Customer-facing agent (chatbox / RAG / tools)
    │       └── Build a thin harness:
    │             tool allowlist + HITL + 30 eval cases
    │
    ├── Corp “ChatGPT for company data”
    │       └── Platform (Open WebUI / Dify / custom)
    │             + audit + quota + tool registry
    │
    └── Research / agent benchmarks
            └── OpenHands / SWE-agent stack

Don’t clone a full Flo diagram (multi-frontier + RL) as a one-person team. Clone the pattern: sandbox + tools + eval.


9 · Minimal harness checklist (ship this week)

Paste into Notion / HARNESS.md:

  1. Clear goal — one Done sentence (e.g. “test X green”).
  2. Tool allowlist — read; write src/**; shell only pnpm test / lint.
  3. Sandbox — no .env, no rm -rf /.
  4. Verify hook — failing tests ≠ Done.
  5. HITL — merge, deploy, email customer = ask a human.
  6. Trace — log tool calls + tokens (even a JSON file).
  7. Small eval — 10–30 golden cases; re-run when prompts/skills change.
  8. 1–3 Skills — repeat playbooks (review, ship-check, incident).

That’s the spirit of Phases 4–5 on this site’s AI Roadmap.

Workspace desk — a good harness means fewer merge surprises


10 · Anti-patterns

  1. Buy a stronger model when the real bug is a missing test hook.
  2. Fill settings with MCP but no skills/playbooks → many hands, no procedure.
  3. Trust “Done” without verification.
  4. Sandbox = raw laptop with admin rights.
  5. Eval by vibes (“answers felt fine today”) — no golden set.
  6. 50-page outer harness — agents don’t read novels; keep guides short and sensors executable.

Closing

Harness isn’t a buzzword replacing prompts. It’s product discipline: models aren’t trustworthy alone; you wrap them with permissions, environment, and quality gates.

Three lines to keep:

  1. Agent = Model + Harness.
  2. Done = verify (or HITL), not model prose.
  3. Outer harness (rules/skills/tests) is what apply-AI can still control while models churn monthly.

Next step: open the Roadmap “Agents + harness” phase and ship a mini coding agent with a test hook. One demo repo beats one architecture slide.

Join the conversation

Comments

No comments yet

0 / 1000

No comments yet. Be the first to leave a note.

My Little World | Tam Vo