---
title: "What Is an Agent Harness?"
description: "An agent harness is the scaffolding around an AI model that runs the loop, manages context, dispatches tool calls and enforces safety so the model can act."
type: "glossary"
locale: "en"
term: "Agent Harness"
canonical: "https://agenticschool.dev/glossary/agent-harness"
dateModified: "2026-06-13"
---

# What Is an Agent Harness?

- Definition: Agent Harness
- Updated: 2026-06-13
- Keywords: agent harness, what is an agent harness, agent harness definition, agent scaffolding, coding agent harness
- Canonical URL: https://agenticschool.dev/glossary/agent-harness
- Locale: en

> An agent harness is the scaffolding around an AI model that runs the loop, manages context, dispatches tool calls and enforces safety so the model can act.

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.

## FAQ

### What is an agent harness in simple terms?

It is the code around an AI model that makes it act like an agent: it runs the loop, gives the model tools, executes the tool calls, manages context and enforces safety. The model reasons; the harness lets it actually do work.

### What is the difference between an agent harness and the model?

The model is the reasoning engine that predicts text and decides actions. The harness is the surrounding software that runs the loop, dispatches tools, manages context and applies guardrails. The same model in a better harness behaves more reliably.

### Is Claude Code an agent harness?

Yes. Claude Code, like Codex CLI, Cursor, Aider and Cline, is an agent harness: it wraps a model in a loop with tools, context management and safety controls so it can read and edit your code and run commands.

### Why does the harness matter more than the model sometimes?

Because the harness decides how context is managed, which tools are available and how safety is enforced, it shapes how well the model performs on real, long-running tasks. A great model in a weak harness can still behave poorly.
