AI glossary

What Is an Agent Harness?

Term3 min readUpdated June 13, 2026

In short

An agent harness is the software scaffolding wrapped around an AI model that turns it into a working agent: it runs the loop that calls the model, handles the model tool calls, manages context and memory, enforces safety, and decides when to stop. The model itself only predicts the next tokens; the harness is everything around it that lets it perceive, act and iterate toward a goal. A practical truth in 2026 is that the harness often matters as much as the model, because two tools running the same model can behave very differently depending on how well their harness is built.

What the harness does

The harness is the runtime that orchestrates a whole agent run. It builds the prompt, exposes the available tools, executes the tool calls the model requests, feeds results back, compacts or trims context as it fills up, persists state across turns, and applies guardrails like permission checks and stop conditions.

  • Runs the loop: call model, run requested tools, feed results back, repeat.
  • Manages context: assembles the prompt, compacts history, handles the context window.
  • Enforces safety: permissions, approvals for risky actions, and when to stop.

Harness vs scaffolding vs model

These terms get blurred, so it helps to separate them. Scaffolding is the setup done before the first prompt (defining tools, system prompt, configuration). The harness is everything that happens after: dispatching tools, compacting context, enforcing rules, persisting state across turns. The model is the reasoning engine inside. Claude Code, Codex CLI, Cursor, Aider and Cline are all examples of agent harnesses, and their patterns are converging.

Why it matters when choosing a tool

Because the harness controls context management, tool access and safety, picking an AI coding tool is largely a choice of harness, not just of model. A strong harness keeps the model on track on long tasks, avoids burning the context window, and stops before it does something destructive. When people say a coding agent "feels smarter", they often mean its harness is better engineered.

Frequently asked questions

Next step

Ready to put AI to work as a real workflow?

Start with the foundations course, keep your progress locally and sync everything to your free account whenever you like.