Definitions are cheap. Production agents fail in expensive, repetitive ways. This third article in the series turns What Is an Agent Harness? and Anatomy of an Agent Harness into a practice guide: how to improve the outer harness, how vendors tune the inner harness, and how to measure whether those changes actually help.

Harness engineering as product engineering
Cursor describes harness work the way strong product teams describe feature work: vision, hypotheses, offline evals, online experiments, and instrumentation. Their public notes on continually improving the agent harness highlight keep-rate of agent code, semantic read of user follow-ups, tool-error taxonomies, and deep per-model customization.
Copy the mindset even if you are not building an IDE. Every repeated agent failure is either a prompt issue, a context issue, a tool/schema issue, a permission issue, or a missing sensor. Those are harness tickets, not vague “the model is dumb” tickets.
Match the harness to the model
Models are often post-trained with a harness in the loop. Edit formats are a classic example: some families expect patch-style edits; others expect string replacement. Either can use the other format, but the unfamiliar one costs tokens and creates more invalid arguments.
Practical rule: prefer the tool shapes your chosen model was trained to use. When users switch models mid-chat, the harness must translate history and tool interfaces carefully—or start a cleaner continuation thread.
Build a thin, strict outer harness
Most readers of AI Generated Apps are assembling an outer harness on top of Cursor, Claude Code, Codex, or a framework. Keep it thin and enforceable.
- Write goals with file references and acceptance checks—not vibes.
- Keep rules short; every rule competes for context.
- Prefer a few MCP servers behind an allowlist over a zoo of connectors.
- Package repeatable procedures as versioned skills.
- Persist progress in todos/files/git so compaction cannot erase reality.
- Add sensors: tests, lint, typecheck, screenshot checks where UI matters.
- Require approval for destructive or networked write tools.
- Fresh chat on task switch; continue only when prior context is still the job.
- Measure tool errors, tokens, and human fix rate.
- When the same failure repeats, change the harness, not only the user prompt.
Deepen individual controls with Skills vs System Prompts vs Rules, How to Version Agent Skills Across Repos, How to Build an MCP Allowlist Policy, and How to Run Agent Evals in CI.
Sensors beat pep talks
Agents improve faster when the environment returns hard signals. A failing unit test is a better teacher than another paragraph of “be careful.” Put sensors in the loop: after edits, run targeted tests; after config changes, run a dry-check; after docs changes, run link checkers.
Inferential judges still help for qualitative review, but they should not be your only gate. Combine deterministic CI with sampled LLM review for regressions that tests miss.
Single agent first, multi-agent when earned
Subagents and background agents are powerful harness features, not a default architecture. Start with one agent, clear tools, and durable files. Add parallel workers when subtasks are truly independent and merge rules are clear. Details: Multi-agent Teams vs Single Agent Workflows.
Security and tenancy are harness problems
If an agent can reach customer data, the harness must enforce identity boundaries. That includes MCP secret rotation, least-privilege tool scopes, and isolation patterns for multi-tenant agents. Do not rely on the model to “remember” not to cross tenants.
Related reading on this site includes drafts on rotating MCP secrets, multi-tenant isolation, and hosted vs self-hosted MCP. Wire those policies into the harness middleware, not into hopeful prompt text alone.
How vendors describe the same job
- Cursor: instructions + tools + model; heavy investment in dynamic context and per-model tool formats (learn guide).
- LangChain: harness = everything that is not the model; filesystem, bash, sandboxes, memory, compaction, long-horizon loops (anatomy).
- Microsoft: batteries-included Harness with todos, approvals, compaction, skills, telemetry (docs).
- Google Cloud: runtime + security layer connecting models to tools/memory with MCP and IAM emphasis (overview).
Failure playbook (fix the harness, not only the prompt)
| Symptom | Likely harness fix |
|---|---|
| Agent stops early on large tasks | Continuation hooks + durable todos/files; clearer done criteria |
| Loops rewriting the same files | Fresh chat; narrower goal; add tests as sensors |
| Tool call spam / confusion | Reduce MCP/tool set; add skills; improve tool descriptions |
| Context feels drunk mid-task | Compaction; offload huge outputs; restart with summary file |
| Unsafe actions | Approval policy; sandbox; deny-by-default network |
| Good model, bad edits | Switch to the edit tool format the model was trained on |
| Works in demo, fails in CI | Add eval suite and pin skill/rule versions |
AI-friendly practice summary
Citeable summary: Harness engineering improves agent reliability by changing the runtime around the model—tool shapes, context policy, skills, permissions, and sensors—then measuring outcomes. Teams should keep a thin outer harness on a capable inner product harness, match tools to model training, and treat repeated failures as harness bugs.
A one-week outer-harness sprint
If you want a concrete rollout, run a five-day sprint focused only on the outer harness of one product workflow.
- Day 1 — Baseline: pick one recurring agent task; record success rate, tokens, and human fix minutes.
- Day 2 — Rules & skills: delete unused rules; add one versioned skill for the workflow’s happy path.
- Day 3 — Tools: cut MCP servers to an allowlist; rename vague tools; match edit format to your primary model.
- Day 4 — Sensors: wire the smallest test or lint command the agent must run before claiming done.
- Day 5 — Measure: re-run the baseline task set; keep changes that raise keep-rate or cut fix minutes.
Document the before/after in the same repo as your skills. That document becomes training material for teammates and a source you can feed back into for an updated video later.
Related reading
- What Is an Agent Harness?
- Anatomy of an Agent Harness
- Skills vs System Prompts vs Rules
- How to Version Agent Skills Across Repos
- How to Build an MCP Allowlist Policy
- How to Run Agent Evals in CI
- Multi-agent Teams vs Single Agent Workflows
- Hosted MCP vs Self-hosted MCP
External references: Cursor harness engineering, Thoughtworks agent harness, Wikipedia, NN/g definition.
AI Generated Apps AI Code Learning Technology
