What Is an Agent Harness? Definition, Components and Examples

What Is an Agent Harness? Definition, Components and Examples

An agent harness is the software around an AI model that turns it into an agent. The model decides what to do next. The harness does everything else: it runs the loop, gives the model its tools, assembles the context it sees, keeps track of state, handles errors, and decides when the job is done.

A useful way to think about it: agent = model + your data + harness. The model decides what to do. Your data, meaning the documents, records and systems it can reach through tools, gives it something real to work on. The harness runs the loop that connects the two. The same model can power a chatbot, a coding agent or a sales assistant. What makes each one different is the data it can reach and the harness around it.

Why does an AI model need a harness?

A language model on its own only turns text into text. It can't run code, call an API or remember what happened three steps ago. When a model "calls a tool", it actually writes out a request, such as query_database(table="customers"). Something else has to read that request, run it with the right credentials, and pass the result back. That something is the harness.

The gap widens as tasks get longer. To "find customers we haven't contacted in 30 days and draft emails to them", the harness has to:

  • Break the work into steps, because 1,000 customers won't fit in one prompt.
  • Keep track of progress across many model calls.
  • Recover when an API times out or the model returns malformed output.
  • Recognise when the task is finished, because the model can't reliably judge that on its own.

Without a harness, you have a model. Put a harness around it and connect it to your data, and you have an agent.

Model vs agent vs harness vs runtime vs framework

These terms get mixed up, often because one product ships several of them together. Here's how they differ:

  • Model: the language model, for example Claude or GPT. It decides what to do next, one turn at a time. Think of it as the brain.
  • Your data: the documents, records and systems the agent works with, usually reached through tools such as MCP servers. It grounds the agent in real facts and sets what it can see and change. Think of it as the files and systems on the agent's desk.
  • Harness: the application code around the model. It runs the loop, tools, context, state, retries and stopping conditions. Think of it as the nervous system that connects the brain to everything else.
  • Agent: model + your data + harness, working on a goal. It completes a task across many steps. Think of it as the whole worker.
  • Runtime: the infrastructure the agent executes in. It handles isolation, sandboxing, resource limits, and network and credential controls. Think of it as the office the agent works in.
  • Framework: a library for building harnesses, for example LangGraph. It gives developers building blocks so they don't write the harness from scratch. Think of it as the toolkit.

Agent harness vs agent runtime: the harness decides what the agent should do next. The runtime decides where that happens and under what constraints. For a deeper comparison, see Agent Harness vs Agent Runtime.

Agent harness vs framework: a framework is a set of parts. A harness is the assembled thing that runs your agent. You might build a harness with a framework, or use a product that ships one ready-made.

Agent harness vs scaffolding: the terms overlap and aren't yet standardised. A common distinction, used in Hugging Face's agent glossary, is that scaffolding is what the model works from (its instructions, tool definitions and output format), while the harness is the code that runs the loop, calls the tools and decides when to stop. Many people use "scaffolding" loosely for both.

Agent harness vs evaluation harness: an evaluation harness tests models or agents against a set of tasks and scores the results. EleutherAI's open-source LM Evaluation Harness is a well-known example. An agent harness runs the agent on real work. Agent evaluations often run the agent inside its own harness, so they measure the whole system rather than the model alone.

What does an agent harness do? The 8 core components

Every agent harness, from a coding agent to a customer support bot, handles the same core jobs:

  1. The agent loop. It repeatedly sends the model the current situation, reads what the model wants to do, does it, and feeds the result back. Common patterns include ReAct (alternating reasoning and action steps), plan-then-execute, and graph-based workflows.
  2. Context assembly. It decides what goes into each prompt: instructions, relevant documents, prior results and tool descriptions. Good context engineering is one of the biggest differences between an agent that works and one that doesn't.
  3. Tools and data access. It tells the model which tools exist, runs the tool calls the model asks for, and returns the results. This is how the agent reaches your data. Today it's increasingly done through MCP (Model Context Protocol) servers.
  4. State and memory. It keeps track of what has happened in the run, and what should persist between runs, outside the model's limited context window.
  5. Output checking and retries. It validates the model's output against the expected format, and asks the model to try again when it's wrong.
  6. Error handling and fallbacks. When a tool fails or a service times out, it retries, switches tools or models, or hands off to a person.
  7. Stopping conditions. It decides when the task is done, or when to stop because the agent is looping, stuck or over budget.
  8. Sub-agents. For larger jobs, it starts helper agents with a narrower task and focused context, then merges their results.

Agent harness examples

You've probably used an agent harness already, even if it wasn't called that:

  • Coding agents. Claude Code, OpenAI's Codex and Cursor's agent mode each wrap a model in a harness that can read and edit files, run commands, and loop until the change works. Anthropic describes its Claude Agent SDK as the harness that powers Claude Code, and OpenAI has open-sourced the harness behind Codex. This is why the same model can feel very different in different coding tools.
  • Agent frameworks. Toolkits like LangGraph and the OpenAI Agents SDK give developers building blocks for their own harness: loops, tool calling, handoffs and state.
  • Managed agent platforms. Enterprise platforms provide a ready-made harness already connected to company systems, so teams configure agents instead of building the loop, integrations and error handling themselves.

What does an enterprise agent harness need?

A harness that works for one developer often breaks in a company. It isn't the loop that breaks. It's the connection to your data: which systems the agent can reach, as whom, and under what rules. Enterprise agent harnesses need:

  • Per-user permissions. The agent should only see and change what the person it acts for is allowed to. That means inheriting permissions from source systems like Google Drive and Salesforce, not using one shared admin key.
  • Scoped tools. Agents perform better and more safely with the few tools they need than with every tool a system exposes. A focused tool set means fewer wrong choices and less wasted context.
  • Rules the model can't talk its way around. Limits on what an agent can change, such as which records, which regions or which stages, enforced outside the model.
  • Human approval for sensitive actions, before they run.
  • A complete audit trail of every model call and tool call, tied to the person or agent behind it.
  • Evaluations and safe rollout. Testing an agent against real cases before it's published, versioning it, and rolling it back when something breaks.
  • Model flexibility. Switching between models without rebuilding the agent.

For a deeper look at these requirements, see What Makes a Great Agent Harness?

Should you build your own agent harness or use a platform?

Build your own harness when the agent is your product, you need full control over the loop, and you have engineers to maintain it as models and protocols change. Frameworks make the first version fast. The ongoing work is integrations, permissions, error handling and evaluation.

Use a platform when you're building internal agents for many teams. In that case most of the effort isn't the loop. It's connecting company systems safely, keeping permissions right, and giving IT one place to see and control every agent.

Many companies do both. Product teams build custom harnesses, and a shared platform governs the tools and data those harnesses can reach. For a comparison of options, see Best Agent Harness Platforms.

How Credal fits

This section describes Credal's product.

Credal is the MCP gateway and agent builder for enterprise AI. It supports both approaches:

  • As a managed harness, connected to your data: teams describe an agent in plain language, or build it with no code or the API. Credal handles prompt assembly, tool calling, message tracking and retries, and connects the agent to company systems through governed MCP servers, with permissions inherited from each source. It adds evaluations, version history, one-step rollback, two-person approval and budgets. Agents can run on a schedule, start from Slack, Salesforce or Asana events, and work in Slack, Claude and the Credal web app.
  • Alongside your own harness: teams that build their own harness, or use AI tools like Claude, ChatGPT and Cursor, connect to Credal's governed MCP servers. Every tool call then carries the user's identity and inherited permissions, follows team-level and value-level rules, and lands in one audit log.

The result is one place to see and control every agent and tool call, whichever harness the agent runs in.

Frequently asked questions

What is an agent harness?

An agent harness is the software around an AI model that turns it into an agent. It runs the loop, provides tools, assembles context, tracks state, handles errors and decides when the task is complete.

What is the difference between an agent and a harness?

The harness is part of the agent. An agent is a model, connected to your data, run by a harness toward a goal. The model makes decisions, and the harness carries them out and manages everything around them.

What is the difference between a model, an agent and a harness?

The model is the language model that decides what to do. The harness is the code that runs the model in a loop with tools, memory and guardrails, and connects it to your data. The agent is all of them together: model + your data + harness.

Is an agent harness the same as an agent framework?

No. A framework is a toolkit for building harnesses. A harness is the working system that runs a specific agent.

What is the difference between an agent harness and an agent runtime?

The harness decides what the agent does next. The runtime is the infrastructure where it runs, with sandboxing, resource limits and network and credential controls.

What is the difference between an agent harness and an evaluation harness?

An agent harness runs an agent on real tasks. An evaluation harness runs a set of test tasks and scores the agent's performance.

Is Claude Code an agent harness?

Claude Code is an agent built on a harness. Anthropic describes the Claude Agent SDK as the harness that powers Claude Code: the loop, built-in tools and context management. Other coding tools, such as OpenAI's Codex and Cursor's agent mode, are built on harnesses too.

What makes a good enterprise agent harness?

Per-user permissions inherited from source systems, scoped tools, rules enforced outside the model, human approvals for sensitive actions, a complete audit trail, evaluations before rollout, and the freedom to switch models.

The bottom line

Models keep getting smarter, but the harness and the data it connects to decide whether that intelligence turns into reliable work. For one developer, the hard part is the loop. For an enterprise, it's the data: making sure every agent can reach exactly what it should, as the right person, under the right rules.

See how Credal builds and governs agents →

Give every team access to governed MCPs

One platform for all agents. Full visibility for admins, full access for teams.

Ready to dive in?

Get a demo