Simple definition#
An agent harness is everything around the model that turns it into a working agent: the loop, tools, permissions, context management, memory files, sub-agents, skills, checkpoints and verification. Two agents using the same model can perform very differently because of their harnesses — which is why “harness engineering” became a discipline of its own in 2025–2026.
Why harnesses matter for long tasks#
A single context window cannot hold a multi-hour task: history grows, old tool results crowd out instructions, and quality decays (“context rot”). Long-running agents need a harness that keeps the window small, relevant and recoverable.
flowchart LR
M(("Model")) --- H["Harness"]
H --- L["Agent loop<br/>+ step budgets"]
H --- T["Tools<br/>files, shell, browser, MCP"]
H --- P["Permissions & hooks"]
H --- C["Context management<br/>compaction, clearing"]
H --- S["Skills<br/>loaded on demand"]
H --- SA["Sub-agents<br/>isolated contexts"]
H --- F["File-based memory<br/>progress notes, plans"]
H --- V["Verification<br/>tests, linters, evals"]
Inside one working session#
- Start session with a task and budget.
- Build context: instructions (system prompt, AGENTS.md), the progress notes from previous sessions, and only the skills relevant to the step.
- Compact when the window gets long: summarise older turns, clear stale tool output.
- The model decides the next step and proposes a tool call.
- The permission check allows, asks a human, or denies.
- Run the tool in a sandbox (shell, browser, MCP server).
- Verify the result with real signals — tests, linters, schema checks, evaluations.
- Save progress — commit work, update the progress file, checkpoint state — so a fresh session can resume.
Context engineering techniques#
| Technique | What it does |
|---|---|
| Compaction | Summarise the conversation when nearing the limit; continue with the summary plus recent turns |
| Tool-result clearing | Drop or shorten bulky outputs once they have been used |
| Just-in-time retrieval | Give the agent search/read tools rather than preloading files |
| Structured notes | The agent writes plans, decisions and progress to files it can re-read later |
| Sub-agents | Delegate exploration to a sub-agent with a fresh window; receive a short summary back |
| Progressive disclosure | Show only short descriptions of skills/tools; load details when needed |
| Stable prefix | Keep system prompt and tool definitions stable for prompt caching |
Patterns for long-running work#
Published guidance on long-running agents converges on a few patterns:
- Initializer + worker sessions. A first session sets up the environment: task list, progress file, test harness. Every later session reads the state from disk, picks one task, works, verifies, commits and updates the notes.
- State lives in files, not in the window. A fresh session must be able to resume from the repository and progress notes alone.
- Small, verifiable increments. One feature or fix per step, each with a test that proves it.
- Explicit definition of done. Acceptance tests written before work begins; the agent may not mark a task complete until they pass.
- Budgets and escalation. Step, token and time limits; escalate to a human when stuck.
Durable progress#
Checkpoints after every step make restarts cheap: a crashed pod, a deployment or a multi-day approval wait resumes from the last saved state instead of repeating work or side effects. Combine with idempotent tools (see memory and state).
Agent Skills in practice#
Skills package how your organisation does things so agents can do it the same way:
---
name: credit-memo
description: Write a credit memo for an SME loan application in the bank's standard format.
Use when asked to prepare, draft or review a credit memo.
---
# Credit memo
1. Collect: applicant, facility requested, financials (3 years), collateral.
2. Run `scripts/ratios.py` on the financials; never compute ratios by hand.
3. Fill `template.md` section by section. Keep the risk summary under 150 words.
4. Flag any covenant breach or ratio outside policy limits in **bold**.
5. Finish with the checklist in `checklist.md`.
- Progressive disclosure: only
nameanddescriptionsit in context until the skill is needed. - Deterministic helpers: scripts do calculations and transformations reliably.
- Governance: store skills in Git, review them like code, sign and version them, and install only trusted skills — a malicious skill is a supply-chain attack.
Coding agents in the enterprise#
Coding agents (CLI and IDE agents, cloud agents that open pull requests) are the most mature agentic use case. Architecture guidance:
| Concern | Practice |
|---|---|
| Sandbox | Containerised workspace; no production credentials; network egress allow-list |
| Permissions | Read freely; ask before shell commands outside an allow-list; never push to protected branches |
| Context | AGENTS.md per repo; skills for internal frameworks; MCP servers for issue trackers and docs |
| Verification | CI must pass; agent-written code reviewed by humans; security scanning |
| Audit | Agent identity on commits; traces of sessions |
| Metrics | Lead time, change failure rate, review load — not lines of code |
Common mistakes#
Review questions#
What is an agent harness? The runtime around the model — loop, tools, permissions, context management, memory files, sub-agents, skills, checkpoints and verification — that makes an agent reliable.
How do long-running agents cope with limited context windows? Compaction, tool-result clearing, just-in-time retrieval, structured notes in files, sub-agents with isolated contexts and progressive disclosure of skills.
What is progressive disclosure in Agent Skills? Only each skill’s short description is in context at first; the full instructions and resources load only when the agent decides the skill is relevant.
How do you make a multi-session agent resumable? Keep state in files and checkpoints (task list, progress notes, commits), make each session pick one task, verify it and save progress, and make tools idempotent.
Summary#
- The harness, not just the model, determines agent reliability.
- Keep context small: compaction, clearing, just-in-time retrieval, notes, sub-agents, skills.
- Long tasks: initializer + worker sessions, state in files, small verified increments, budgets.
- Skills package know-how with progressive disclosure; govern them like code.
References#
- Anthropic, Effective context engineering for AI agents, 2025.
- Anthropic, Effective harnesses for long-running agents, 2025.
- Anthropic, Equipping agents for the real world with Agent Skills, 2025.
- LangChain, Deep Agents.