---
title: "Agent Harness"
description: "An agent harness is the runtime software that turns a Large Language Model (LLM) into an executable AI agent. It owns the loop that prepares model input, receives model output, executes approved actions, updates state, and decides whether another model turn is needed."
canonical_url: "https://promptmetheus.com/resources/llm-knowledge-base/agent-harness"
---

> Index of every page on this site: [llms.txt](https://promptmetheus.com/llms.txt)

An agent harness is the runtime software that turns a [Large Language Model (LLM)](https://promptmetheus.com/resources/llm-knowledge-base/large-language-model-llm) into an executable [AI agent](https://promptmetheus.com/resources/llm-knowledge-base/ai-agent). It owns the loop that prepares model input, receives model output, executes approved actions, updates state, and decides whether another model turn is needed.

The harness is distinct from the model. Two products can use the same underlying model but behave differently because their harnesses expose different tools, state, permissions, retry logic, and user interaction patterns.

Common harness responsibilities include:

- assembling context from instructions, memory, retrieved data, and tool results;
- presenting available [tool calls](https://promptmetheus.com/resources/llm-knowledge-base/tool-calling-function-calling) and dispatching them to real implementations;
- validating [structured output](https://promptmetheus.com/resources/llm-knowledge-base/structured-output);
- enforcing [agent guardrails](https://promptmetheus.com/resources/llm-knowledge-base/agent-guardrail);
- managing retries, errors, approvals, and step limits;
- emitting [agent traces](https://promptmetheus.com/resources/llm-knowledge-base/agent-trace-observability); and
- saving state for a [resumable agent run](https://promptmetheus.com/resources/llm-knowledge-base/resumable-agent-run).

The harness works together with [agent scaffolding](https://promptmetheus.com/resources/llm-knowledge-base/agent-scaffolding). Scaffolding shapes what the model sees and how it should behave; the harness executes the surrounding control flow.

Harness design is often more important than model choice for production reliability. A strong model inside a weak harness may loop, misuse tools, lose state, or take unauthorized actions. A carefully designed harness can make a smaller or cheaper model useful by constraining the task, validating outputs, and routing difficult cases elsewhere.

The [OpenAI Agents SDK running-agents documentation](https://openai.github.io/openai-agents-python/running_agents/) describes a representative harness loop with final outputs, handoffs, tool calls, turn limits, and state management.

## Sitemap

See the full [sitemap](https://promptmetheus.com/sitemap.md) for all pages.
