Agent Harness

The layer that assembles context and tools, runs model-requested actions in a runtime, and returns results for the next step.
Updated 6 Oct 2026

Codex, Claude Code, and OpenCode can use a model to work on a repository because software around the model prepares each call and connects its decisions to the environment. That software is the harness.

On each iteration it can assemble instructions and context, present available tools, execute an action in a runtime, and return the result so the model can continue the agent loop.

What the harness adds around the model Project instructions, skills, tools, and deterministic checks feed the harness. The harness prepares context and tool access for the model, executes requested actions in the repository, shell, or tests, and returns results. Inputs and capabilities Project instructionsSkillsToolsDeterministic checks Harness Prepare contextExpose and run tools Model Choose the next step Runtime / environment RepositoryShellTests Context + toolsDecisionRequested actionResult What the harness adds around the model Project instructions, skills, tools, and deterministic checks feed the harness. The harness prepares context and tool access for the model, executes requested actions in the repository, shell, or tests, and returns results. Inputs and capabilities Project instructionsSkillsToolsDeterministic checks Harness Prepare contextExpose and run tools Model Choose the next step Runtime / environment RepositoryShellTests Result
Figure 1. The harness prepares the model call and connects model decisions to tools and a runtime; execution happens in the environment and results return for the next decision.

Context and tools

The harness decides what reaches the next inference: project instructions, conversation history, retrieved files, earlier results, and tool definitions. It may also discover a skill or connect external operations when the task requires them.

Implementation varies by product. Codex, Claude Code, and OpenCode do not have to search the same instruction paths, load skills in the same way, or expose exactly the same tools. Those differences belong to the harness rather than the model.

Runtime

Actions happen in a concrete environment: a local shell, VM, sandbox, or cloud workspace. That runtime determines which files, binaries, network paths, credentials, and services are actually available.

The same model can therefore complete a task in one harness and fail in another. If the repository is not mounted or the test runner is missing, better model output does not add that capability.

Checks and results

A harness can combine model decisions with deterministic checks. Counting findings, validating JSON, or running tests is often more reliable in code than through another inference.

In this repository, for example, editorial rules guide the agent while npm run test:content checks invariants that should not depend on the model remembering them.

When reviewing a run, tool calls, results, errors, and validation outcomes are the useful evidence. The result sent back to the model can be much smaller than the original artifact: a full log can stay in a file while the next inference receives only the relevant lines.

References