An agent harness, also known as agent scaffolding, is the software infrastructure surrounding a large language model (LLM) that enables it to operate as an AI agent. It manages tool use, prompts, memory, state persistence, permissions, error handling, execution environments and feedback loops, as opposed to the model's internal reasoning. In 2023, the UK's AI Security Institute described an AI agent as being formed by the model plus the scaffolding. The relationship can be expressed as agent = model + harness. The term came into common use in 2026 to describe middleware between an AI agent and its output, though defining exactly what is and isn't a harness can be difficult. The harness can help with understanding otherwise opaque models by seeing how they behave so that AI safety can be improved. Because a "base model" LLM is a stateless probabilistic function that maps input token sequences to output token sequences, the harness is what makes an agent out of a model, i.e. a thing that interfaces with external tools, inputs and outputs non-token data (such as images), and interacts with a task-environment coherently over many rounds. Rather than repeatedly re-reading an ever-growing transcript inside the context window, a harness can offload record-keeping into a structured software environment that manages the agent's state. A minimal harness is unnecessary for a single prompt-and-response exchange, but becomes more useful as tasks grow multi-step, tool-oriented, or long-running. Popular agent harnesses are focused on AI-assisted software development, including Anthropic's Claude Code, OpenAI's Codex, Google DeepMind's Antigravity, AWS's open-source Strands, OpenCode, Microsoft's MDASH, DeepSeek Harness, Cursor, and oh-my-pi.
Architecture Components commonly grouped under a harness include tool dispatch, memory and state persistence, an isolated sandbox or workspace, context management, and guardrails such as scoped permissions, approval tiers and monitoring. In a 2026 engineering write-up, Anthropic described a worked example built from an initialiser agent that prepares the environment and a coding agent that repeatedly selects the next unfinished task, commits, and updates a progress record before stopping. Birgitta Böckeler of Thoughtworks distinguishes an inner harness shipped by the model's builder (for example, an agent SDK or a coding tool, such as Cursor or Codex or Claude Code) from an outer harness that the user assembles on top, such as instruction files, Model Context Protocol servers, and custom skills. She further separates guides, which steer the agent before it acts, from sensors, which observe the result and let the agent self-correct; each may be computational (deterministic checks such as linters or tests) or inferential (semantic checks such as an "LLM as judge"). Agent harnesses use CPUs not GPUs.
History and terminology The term came into common use in 2026 to describe middleware between an AI agent and its output, though defining exactly what is and isn't a harness can be difficult. By mid-2026 the harness had become an object of academic study. Independent reporting described research such as Self-Harness, in which an agent iteratively mines its own failures to propose and validate changes to its harness, and Harness-1, an open-source search agent that improved retrieval accuracy chiefly by redesigning the software environment around the model rather than by enlarging the model.
Relationship to prompt and context engineering Harness engineering is often positioned as a broader layer than prompt engineering, which optimises a single interaction, or context engineering, which governs what information the model sees at a given moment; in this framing the harness designs the whole operational environment and contains the other two as parts. A distinguishing feature is that the component being wrapped is non-deterministic, so a harness is designed to recover gracefully when the model fabricates an action or reports a task as finished when it is not.
See also AI agent List of large language models Model Context Protocol Prompt engineering Reinforcement learning Software agent Test harness
References

