# Agent harness

> Canonical: https://skillalmanac.com/glossary/agent-harness | Last verified: 2026-11-25 | Index status: index-eligible

An LLM agent harness is software around a language model that supplies context, executes requested tools and returns their results. It may also provide permission controls, hooks and context management; those features vary by implementation.

Also called: harness, AI harness, harness in AI, what is a harness in AI, what is harness in AI, what is AI harness, coding agent harness.

## In plain language

In an LLM-based agent, the language model proposes responses or tool requests. The harness is the program around it that executes permitted requests and returns results. It gathers your request and the relevant files, sends them to the model, runs the commands or edits the model asks for, applies its configured controls, and feeds the results back. Some harnesses ask for approval; others use different policies. Claude Code and Codex are harnesses. Swap the model and the harness stays; change the harness and the same model behaves differently.

## Technical definition

An LLM harness commonly runs a loop: assemble the prompt from instructions, history and tool results; call the model; parse any tool calls; check them against permission rules; execute them; append the output; repeat until the model stops. Around that core it may manage the context window, for example by compacting history, and expose extension points such as hooks. Claude Code's documentation describes hooks as user-defined actions that run at specific points in its lifecycle. Anthropic describes agents as typically just LLMs using tools based on environmental feedback in a loop.

## How it shows up when you use agents

When you run `claude` or `codex` in a project, the program you are talking to is the harness. The model is a separate service it calls. The harness reads your instruction files, collects the files and command output that fit in the [context window](/glossary/context-window), sends them to the model, and acts on the reply. Anthropic's overview describes Claude Code as a tool that reads your codebase, edits files and runs commands. The OpenAI Codex CLI page describes the same shape, and its `/permissions` command sets when Codex may edit files or run commands without asking.

Most of what you configure lives in the harness. Permission rules decide which [tool calls](/glossary/tool-calling) run unprompted. Hooks run your scripts at fixed points in the loop. Skills, instruction files and [MCP servers](/glossary/mcp-server) add instructions and tools. Context management, such as compacting a long session, is also the harness's job.

What breaks when this is misunderstood: people blame the model for behaviour that is the harness's, such as a blocked command, a forgotten instruction after compaction or a hook that did not fire. Equally, they credit a model for results that came from good tooling. To compare models fairly, hold the harness constant. See [AI agent](/glossary/ai-agent) for the larger idea.

## Common confusions

- **Harness versus model.** In this LLM-agent setting, the model proposes text or tool requests. The harness decides what the model sees, which of its requests run and what happens to the results. Same model, different harness, different behaviour.
- **Harness versus agent.** An agent is the whole running system with a goal. The harness is its software shell, the loop and controls. See [AI agent](/glossary/ai-agent).
- **Harness versus framework or SDK.** A framework gives you parts to build a harness. Claude Code's overview says the Agent SDK lets you build your own agents with Claude Code's tools and capabilities.
- **Harness versus test harness.** In software testing a harness drives code under test. An agent harness drives a model. The words match; the jobs differ.
- **Myth.** "Hooks and permissions are enforced by the model." When present, those controls run in the harness as ordinary code, which is why they can block an action the model has already asked for.

## Worked examples in this catalogue

### [What Is Claude Code and What It Can Touch on Your Machine](https://skillalmanac.com/learn/what-is-claude-code)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The guide explains what Claude Code can read, edit and run on your machine, and how permission modes and rules decide which actions go ahead and which prompt you first.

Why it exercises the concept: Those permission decisions are made by the harness, not the model. This guide shows the harness's gatekeeping role in a real tool.

### [Claude Code Hooks: Setup, One Example, and Failure Modes](https://skillalmanac.com/learn/claude-code-hooks-explained)

```
/hooks
```

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The guide shows how to add a hook in a settings file, read its JSON input and block a tool call with exit code 2. Typing /hooks at the Claude Code prompt opens a browser of configured hooks.

Why it exercises the concept: Hooks are extension points in the loop. They run code at fixed moments such as before a tool call, which only a harness can offer.

### [agent-hooks-authoring](https://skillalmanac.com/skills/skill-almanac/agent-hooks-authoring)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The skill helps you write, install, test and debug coding-agent hooks, proving each one by firing it with sample input.

Why it exercises the concept: It treats the harness as something you program: you change what the loop does without touching the model.

### [Claude Code](https://skillalmanac.com/tools/claude-code)

```
claude
```

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Starting claude in a project opens a session where the model proposes edits and commands and the tool asks for approval where your permission settings require it.

Why it exercises the concept: Claude Code is a harness around Claude models. Instruction files, skills, hooks, MCP servers and permissions all attach to the loop, not to the model.

## Related terms

- [AI agent](https://skillalmanac.com/glossary/ai-agent.md)
- [Agentic AI](https://skillalmanac.com/glossary/agentic-ai.md)
- [Tool calling (function calling)](https://skillalmanac.com/glossary/tool-calling.md)
- [Context window](https://skillalmanac.com/glossary/context-window.md)
- [Model Context Protocol (MCP)](https://skillalmanac.com/glossary/model-context-protocol.md)
- [Agent skill](https://skillalmanac.com/glossary/agent-skill.md)
- [Vibe coding](https://skillalmanac.com/glossary/vibe-coding.md)

## Sources

- [Claude Code overview](https://code.claude.com/docs/en/overview), Anthropic (Claude Code Docs) (accessed 2026-11-23)
- [Hooks reference](https://code.claude.com/docs/en/hooks), Anthropic (Claude Code Docs) (accessed 2026-11-23)
- [Codex CLI](https://learn.chatgpt.com/docs/codex/cli), OpenAI (Codex documentation) (accessed 2026-11-23)
- [Building effective agents](https://www.anthropic.com/engineering/building-effective-agents), Anthropic (accessed 2026-11-23)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
