The discipline of designing, tightening, and maintaining the scaffolding around an LLM that turns it into a working agent. The term was coined by Vasu Trivedy (@Vtrivedy10), then synthesised across the field in Addy Osmani’s article (May 2026), pulling together threads from HumanLayer, Dex Horthy, Birgitta Böckeler, and Anthropic’s engineering posts.
The one-line definition:
Agent = Model + Harness. If you’re not the model, you’re the harness. — Trivedy
Harness engineering is what you do to the harness every time the agent fails. It treats scaffolding as a living artifact, not a static config file.

Why the discipline has a name now
For two years the industry argued about models. Which is smartest, which writes cleaner React, which hallucinates least. That debate misses the other half of the system. The model is one input into a running agent. Everything else is the harness.
The empirical wedge:
A decent model with a great harness consistently beats a great model with a bad harness.
Performance benchmarks back this. A leading model running inside an off-the-shelf framework often scores drastically lower than the same model running in a custom, tightly-tuned harness. The gap between what today’s models can theoretically do and what you observe them doing is largely a harness gap.
This is the same observation Harness Engineering at OpenAI makes from production scale (1M LOC in 5 months, 0 manually-written), and the reason Coding Agent Harnesses - 2026 Landscape looks more like a competition between scaffoldings than between models.
The “skill issue” reframe
The default failure response in the industry is to blame the model and “wait for the next version.” Harness engineering rejects this default.
HumanLayer’s framing: “It’s not a model problem. It’s a configuration problem.”
When an agent does something nonsensical, the failure is usually legible:
| Symptom | Harness response |
|---|---|
| Agent ignored a project convention | Add it to AGENTS.md / CLAUDE.md |
| Agent ran a destructive command | Write a hook to block it |
| Agent got lost in a 40-step task | Split planner from executor |
| Agent ships broken code | Wire a typecheck back-pressure signal into the loop |
| Agent forgets prior decisions | Move state to disk; re-read on next turn |
Key
Failures are configuration, not capability. Moving a model into an environment with better codebase tools, tighter prompts, and sharper back-pressure can unlock capabilities the original setup hid.
This sits next to Agentic Coding - Risks and Discipline, which makes the same point from the user-discipline side: when agents drift, the answer is rarely “try harder” or “wait for a smarter model.” It is to fix the environment.
The Ratchet: every mistake becomes a permanent rule
The single most important habit in harness engineering is treating agent mistakes as permanent signals, not one-off flukes to retry and forget. This is important enough to live on its own page: The Ratchet - Every Mistake Becomes a Rule.
The compressed version:
Every line in a good system prompt should trace back to a specific, historical failure.
Constraints earn their way into the harness through observed failure. They earn their way out only when a more capable model renders them redundant. This makes harness engineering a discipline rather than a one-size-fits-all framework. The right harness for a codebase is shaped by its unique failure history.
This is the same mechanism behind Skillify - Meta-Skill Pattern (Garry Tan: every failure becomes a skill with evals) and Golden Principles and Garbage Collection (OpenAI: human taste captured once, enforced continuously).
The backward pass: train on transcripts, not anecdotes
Kun Chen makes the Ratchet operational in AGENTS.md as a Neural Net. Treat each session as a forward pass and the session transcript as the evidence for a backward pass. The update loop is deliberately conservative: score individual instruction units, batch evidence across sessions, make only a few edits, enforce a token budget, and require human approval before anything writes.
This adds two safeguards that a simple “every failure becomes a rule” slogan leaves implicit:
- Batching prevents overfitting. One strange failure may be noise, a bad task framing, or a model-specific stumble. A new permanent rule needs repeated evidence unless the failure is safety-critical.
- Budgeting forces trade-offs. An always-loaded rule costs context on every turn. Additions must be paid for by deletion, consolidation, or extraction into an on-demand skill.
The result is not automatic prompt optimization. Transcript frequency is not causal proof, and the model can misread both the failure and the proposed fix. The human gate is part of the harness because the question is not only “what rule would reduce this error?” but also “is this behavior one we want the project to institutionalize?”
Working backwards from behavior
The design heuristic that keeps a harness honest:
Behavior we want → harness component that delivers it. If you cannot name the specific behavior a component exists to deliver, remove it.

Each named component in a mature harness corresponds to a class of failures it was built to absorb. The Osmani synthesis lists what each piece is for:
| Component | Failure it absorbs |
|---|---|
| Filesystem + git | Models can only operate on what fits in context; filesystem is the workspace and the offload surface; git is free versioning and rollback |
| Bash + code execution | Pre-built tools cannot anticipate every action; bash lets the agent build what it needs on the fly (CLI Tools Pattern) |
| Sandboxes + default tooling | Bash is dangerous on the host; sandboxes isolate execution; pre-installed runtimes/test CLIs/headless browsers close the self-verification loop (Brain Hands Session Split) |
Memory files (AGENTS.md / CLAUDE.md) | Models have no knowledge beyond weights and current context; per-turn injection bridges the gap (Agent Harness > What Belongs in the Always-Attached Set) |
| Web search + MCP for live data | Real-time information is unreachable from training weights |
| Compaction | Models degrade as context fills (Curse of Instructions); summarise and offload older context |
| Tool-call offloading | Massive tool outputs (2,000-line logs) blow context; store in filesystem, keep only headers/footers in context |
| Progressive disclosure | Loading every tool/instruction at startup wastes context; reveal only when task requires it |
| Loops + planning + splits | Long-horizon work fails from early stopping and poor decomposition; intercept exits, force plan files, separate generators from evaluators |
| Hooks | The model has no enforcement layer; hooks bridge “requested an action” to “enforced the action” |
Key
Success is silent, failures are verbose. A passing typecheck produces no output. A failing one injects the error directly back into the loop for self-correction. This shape minimises the per-turn rent paid for noise.
These map cleanly onto the existing vault cluster: Tool Design for Agent Harnesses, Context Window Management Strategies, Streaming in Agent Harnesses, Session Observability and Replay, Provider Abstraction in Agent Harnesses.
Hooks as the enforcement layer
Hooks deserve their own line in the principle: they are the place where a request becomes enforced. They run at lifecycle points (before a tool call, after a file edit, before a commit) and are the only way to make the agent’s behaviour deterministic against rules the model itself ignores under load.
Concrete uses:
- Block destructive commands (
rm -rf,git push --force, dropping tables) - Auto-format code on save (saves tokens by avoiding a “fix the formatting” turn)
- Run typechecks/tests after edits and inject failures back as context
- Validate file structure (frontmatter present, conventions followed)
- Cap costs / iterations per task
This is the deterministic layer of the Latent vs Deterministic pair: latent space carries judgment, deterministic code carries trust.
The rulebook discipline
A flat markdown file at the repo root (AGENTS.md, CLAUDE.md) remains the highest-leverage configuration point a harness has. The discipline:
Treat it like a pilot’s checklist, not a style guide. Keep it short. Every rule earned through a past failure.
This is the same pattern AGENTS.md Six Core Areas documents from GitHub’s 2,500-file study, and the explicit reason Harness Engineering at OpenAI failed at “one big AGENTS.md” and pivoted to a table-of-contents pointing at structured docs/.
The same discipline applies to tools. Ten focused tools outperform fifty overlapping ones. And tool descriptions populate the prompt, so unverified MCP servers can inject prompts into the agent before it starts working — a real attack surface.
Harnesses don’t shrink, they move
A common assumption: “as models improve, scaffolding becomes obsolete.” Half-true.
What actually happens: better models raise the floor, but the ceiling rises with it. Tasks that were unreachable become tractable, bringing entirely new failure modes. The harness shifts to the new horizon.
Key
Every component in a harness encodes an assumption about what the model cannot do on its own. When the model improves, outdated scaffolding should be removed. New scaffolding must be built where the new failure modes live.
Concrete: as Claude 4.5 / GPT-5 / Sonnet 4.6 follow rules near-perfectly, “context-anxiety” mitigations have shrunk. But long-horizon execution, multi-agent orchestration, and self-trace analysis are now reachable problems with their own failure modes. The harness moves to those.
This is why Agent Harness’s “What Drives Harness Quality” (model 30%, harness 70%) keeps applying year after year — the contents of the 70% change, but its share doesn’t.
The training feedback loop
A subtle point Osmani surfaces: today’s models are post-trained with specific harnesses in the loop. This creates a degree of overfitting. The model gets exceptionally good at the actions the harness designers prioritised (filesystem ops, bash, subagent dispatch) — and weaker at actions a different harness might value.
Implications:
- The “best” harness is the one optimised for your tasks, not a universal one.
- Harness choice constrains which models work well; switching models can require harness retuning.
- This is a feedback loop, not a one-way arrow: harness designers and model trainers shape each other.
Companion to Provider Abstraction in Agent Harnesses: provider-agnostic harnesses still inherit per-model behavioural variance from how each model was trained.
What this looks like in production
The clearest public picture of a mature harness is Fareed Khan’s reverse-engineered breakdown of Claude Code’s architecture.

Almost every concept above appears as a named component:
- Context injection = the knowledge layer (what enters the prompt)
- Memory store + worktree isolator = loop state
- Permission gate = destructive-action hooks
- Multi-agent layer = subagent context firewalls
- Tool dispatch registry = the layer where MCP servers and bash both plug in
Key
Claude Code’s trajectory is about the harness at least as much as about the model underneath it. The same is true of Cursor, Codex, Aider, and Cline.
See Claude Code Internals for the dissection of what claude-trace revealed inside Claude Code, and Coding Agent Harnesses - 2026 Landscape for the comparative view.
Harness-as-a-Service (HaaS)
The industry shift Osmani names: building on LLM APIs (which provide completions) is giving way to building on Harness APIs (which provide a runtime). SDKs now ship the loop, tools, context management, hooks, and sandboxes out of the box.
Consequences:
- The default for a new agent project is no longer “build orchestration from scratch” but “select a harness framework, configure its core pillars, focus on domain-specific prompt and tool design.”
- Troubleshooting becomes scalable because you are tuning a well-factored configuration surface, not reinventing the agent architecture.
- “Harness lock-in” is a real risk that pairs with Provider Abstraction in Agent Harnesses’s “model lock-in” concern.
Examples in the wild: Anthropic’s Claude Agent SDK, OpenAI’s Agents SDK, the Vercel AI SDK, and Fred Schott’s Flue (named in the Osmani post as inspired by an earlier draft of the same article).
The convergence observation
Osmani’s closing observation is worth its own line:
Today’s top coding agents look more like each other than their underlying models do.
Models differ. Harness patterns are converging. The industry is identifying the load-bearing scaffolding required to turn generative text into shippable software, and that scaffolding is the same regardless of which model sits in the middle.
The implication for someone choosing or building: the right question stops being “which model?” and becomes “which harness configuration?” — and the harness configuration is what you can actually shape.
Where the discipline is going
The open frontier from Osmani’s view (and consistent with the rest of the vault):
- Multi-agent orchestration in parallel (Multi-Agent Systems, Multi-Agent Research System - Production Lessons)
- Agents analysing their own traces to fix harness-level failures — self-reflective harness engineering
- Just-in-time tool assembly — environments that compose tools as the task arrives, rather than registering them upfront (Self-Extending Agents)
- Harnesses as compilers — the phase where harnesses stop being static config files and start acting more like compilers that take intent and produce execution
Harness across the SDLC
Google’s May 2026 whitepaper (co-authored by Osmani) maps harness responsibility onto SDLC phase directly — a framing this page didn’t have before:
| SDLC phase | Harness role | What that looks like |
|---|---|---|
| Requirements, Planning, Architecture | Configure | Write AGENTS.md, define tool access, set the rules the agent cannot break — before any production code exists |
| Implementation | Run | Sandboxes, execution environments, and tools bound what the model can actually do while it works |
| Testing & QA | Feedback loop | Orchestration captures a failing test’s output and routes it back to the model automatically — the “think → act → observe” loop made deterministic |
| Code Review, Deployment, Maintenance | Observe | Hooks block bad commits deterministically (e.g. a hard-coded secret); observability tracks cost, latency, and drift so a human can audit why the agent made a given call |
The paper’s framing of the vibe-coding/agentic-engineering split (see Vibe Coding) in harness terms: the same agent, the same model, can be used either way — the difference is entirely how deliberately the harness is configured and applied, not which tool is in front of the developer.
Related Concepts
-
Agent Harness — the noun; the runtime scaffolding itself, including the five ingredients and the per-turn cost model
-
The Ratchet - Every Mistake Becomes a Rule — the discipline’s central practice
-
Harness Engineering at OpenAI — the empirical case study; 1M LOC, 0 hand-written; six load-bearing patterns
-
Coding Agent Harnesses - 2026 Landscape — comparative survey of the major commercial harnesses
-
Tool Design for Agent Harnesses — what makes the tool layer good
-
Context Window Management Strategies — the strategies for handling transcript growth
-
Streaming in Agent Harnesses — interrupt semantics and live supervision
-
Session Observability and Replay — the post-hoc completion of the observability thread
-
Provider Abstraction in Agent Harnesses — the fifth ingredient as a deep-dive
-
Self-Extending Agents — the philosophy that complements a minimal harness
-
Skillify - Meta-Skill Pattern — the personal-AI version of the Ratchet
-
Golden Principles and Garbage Collection — the OpenAI version of the Ratchet
-
Latent vs Deterministic — why hooks live in the deterministic half
-
Agentic Coding - Risks and Discipline — what goes wrong when the harness is loose
-
AGENTS.md Six Core Areas — the rulebook discipline applied
-
AGENTS.md as a Neural Net — the transcript-based backward pass for training project instruction files
-
Curse of Instructions — why “more rules” is not the answer past a point
-
PRINCE - Production Agentic RAG at Bayer — harness engineering in a regulated production system: LangGraph as the control layer, node-level state persistence + resume, layered retries, cross-provider LLM fallbacks; “harnesses don’t shrink, they move” stated explicitly
-
12-Factor Agents — HumanLayer’s twelve principles; the most concrete artifact of this discipline, and the source Osmani cites secondhand
Open Questions
- Where is the boundary between the harness’s responsibility and the model’s? As models internalise more of what hooks currently enforce, which constraints become redundant first?
- Is there a universal “minimum harness” below which agents cannot work, or is the minimum task-specific?
- What does self-reflective harness engineering (agents fixing their own harness from observed traces) look like at production scale?
- How does the HaaS layer compete or compose with foundation-model-vendor SDKs over the next 12 months?