Skip to content
Back to the glossary

Agent Harness

The software around a language model that runs the agent loop, decides what enters the model’s context, keeps memory between steps and sessions, and executes the tool calls the model requests.

What is an agent harness?

An agent harness is the runtime layer that turns a language model into an AI agent. On every turn, it assembles the context the model sees, exposes tools and executes the calls the model makes, enforces permissions and sandboxing, persists memory and task state across steps and sessions, and decides when the loop stops. The model supplies the reasoning, and the harness supplies everything around it, so two agents built on the same model can behave very differently.

No standards body defines the term, though Anthropic used it in Effective harnesses for long-running agents (November 2025), where the Claude Agent SDK is described as a general-purpose agent harness adept at coding and other tasks. The related phrase “harness engineering” spread in February 2026: Mitchell Hashimoto used it in My AI Adoption Journey for the habit of changing an agent’s environment each time the agent makes a mistake. Six days later, OpenAI published Harness engineering, describing a team that shipped about one million lines of code in roughly five months, with no manually written code, by designing the repository, documentation, linters, and feedback loops its Codex agents worked inside.

How an agent harness works

Most harnesses run the same loop, whatever the model or framework:

  1. Build the context for the next turn: system prompt, instruction files, tool definitions, relevant memory, recent messages, and tool results.
  2. Send it to the model for inference and parse the reply.
  3. If the reply requests a tool call, check the request against permission rules, run it (often inside a sandbox), and capture the output.
  4. Append the result, update stored state, and shrink the context if it is close to the window limit.
  5. Repeat until the task is done, a step or cost budget runs out, or a human must approve the next action.

Around that loop sit logging, retries, lifecycle hooks that run scripts at fixed points, and, in larger systems, the spawning of sub-agents, which is where a harness overlaps with multi-agent systems and agent orchestration. Sandboxing is a harness feature as well. In Making Claude Code safer with sandboxing (October 2025), Anthropic describes limiting file writes to the working directory and routing network traffic through a proxy that allows only approved hosts, and reports that sandboxing cut permission prompts by 84% in its internal use.

Context management

Context management is the part of the harness that decides which tokens the model sees on each turn. Anthropic’s Effective context engineering for AI agents (September 2025) treats context as a finite budget: As the window fills, the model recalls information less accurately, an effect the article calls “context rot.” The techniques it describes are now common across harnesses:

TechniqueWhat the harness does
CompactionSummarizes the conversation when it nears the limit and continues in a new window seeded with the summary
Tool result clearingDrops the raw output of old tool calls that the model no longer needs
Just-in-time retrievalKeeps lightweight references such as file paths or queries and loads the data only when a step needs it
Sub-agentsHands focused tasks to separate agents that work in clean context windows and return only a condensed summary

Instruction files are context too: The OpenAI team behind Harness engineering abandoned a single large instruction file because it crowded out task context and went stale, and replaced it with an AGENTS.md of about 100 lines that points to deeper documentation kept in the repository.

From a security point of view, context management decides what the model will treat as trustworthy. Tool output, retrieved documents, and web pages land in the same window as the system prompt, which is the mechanism behind indirect prompt injection, and a compaction summary can silently drop a constraint the user set early in the session.

Agent memory

Memory is the state a harness keeps outside the context window so that it survives compaction, restarts, and new sessions. Short-term memory is the window itself; long-term memory lives in files, databases, or vector stores that the harness reads back later.

Anthropic’s memory tool documentation shows a typical design. The tool runs client-side: The model asks to view, create, edit, rename, or delete files under a /memories prefix, and the application decides where that data actually lives and executes each operation. The documentation warns that a path such as /memories/../../secrets.env can escape the memory directory and tells implementers to canonicalize every path, reject traversal sequences, and watch for URL-encoded variants, the same defenses used against path traversal in any API.

Long-running coding agents use structured memory to hand off work between sessions. In the Anthropic harness article, the first session, an initializer, writes a progress log, an init script, a git commit, and a JSON feature list (more than 200 features for a claude.ai clone, all initially marked as failing), and every later session reads them before working on one feature. JSON was chosen for that list because, according to the authors, the model edited it less freely than Markdown.

Agent harness vs. model vs. orchestration

LayerWhat it doesWhat changes when it changes
ModelGenerates the next message or tool call from the context it receivesReasoning quality, refusal behavior, cost per token
Agent harnessRuns the loop, builds context, stores memory, executes tools, enforces permissionsWhat the agent can see, touch, and remember
OrchestrationRoutes work between several agents and combines their resultsWhich agent handles which step

A review of a foundation model alone says little about how an agent built on it will behave, because permissions, memory, and tool access are set in the harness.

The agent harness as an attack surface

The current OWASP Top 10 for Agentic Applications is the 2026 edition, published on December 9, 2025. Several of its entries describe harness failures: According to the OWASP launch post, ASI06 Memory & Context Poisoning covers memory poisoning that reshapes an agent’s behavior long after the initial interaction, while ASI02 Tool Misuse and ASI05 Unexpected Code Execution concern how the harness exposes and runs tools.

A worked example of memory poisoning comes from Cisco research published as Identifying and remediating a persistent memory compromise in Claude Code (April 2026). The attack chain ran as follows:

  1. A user asked the agent to set up an untrusted repository and approved an npm install.
  2. An npm lifecycle hook ran code that overwrote the MEMORY.md file in each project’s memory folder and the global hooks configuration in ~/.claude/settings.json.
  3. An alias added to the user’s shell profile re-enabled auto-memory on every launch, even if the user had turned it off.
  4. In the tested version, the first 200 lines of each MEMORY.md were loaded into the system prompt, so the poisoned agent recommended committing an API key to source code and gave no security warning.

Anthropic changed Claude Code in version 2.1.50 so that user memories are no longer placed in the system prompt. Writing for OWASP in Memory Is a Feature. It Is Also an Attack Surface (May 2026), a co-lead of the ASI06 entry argues that memory and context deserve the same scrutiny as credentials and execution paths. Poisoned memory is hard to spot: It looks like ordinary project configuration, and its effect appears sessions later, often during a different task.

How to test an agent harness

  • Map every source that enters the context window, including instruction files, memory, retrieved documents, and tool output, and mark which ones an attacker can influence.
  • Place instructions in tool responses, documents, and files the agent reads, and check whether it acts on them.
  • Write to memory from one session or user and check whether behavior changes in another session, for another user, or in a sub-agent.
  • Send traversal sequences, including URL-encoded ones, to memory and file tools.
  • Confirm that permissions are enforced in harness code: Request disallowed commands and attempt network egress to unapproved hosts, which also tests for excessive agency.
  • Run tasks long enough to force compaction and check whether safety instructions and user constraints survive the summary.
  • Check whether the agent can modify its own hooks, settings, or instruction files, and whether tool calls and memory writes are logged.

Agent harness with Equixly

Equixly owns both its models and the harness around them, which it describes in Equixly’s proprietary AI: A model that only knows how to attack as “the orchestration of tools, memory, planning, and verification loops around the model.” Its exploitation engine, offensive models, agent orchestration, and inference layer are developed as one system, and the AI engine is stateful and graph based, adapting its next move to what the target reveals. Equixly’s agents operate within a deterministic, controlled-autonomy framework.


Did you like our post? Share it on social!

  • AI Agents and Agentic AI

    A software system in which a language model decides which actions to take toward a goal and carries them out by calling tools such as APIs, code execution, or a browser.

  • AI Hallucination and Non-Determinism

    AI hallucination is output a language model states with confidence that is false or unsupported; non-determinism is the tendency of the same model to answer the same input differently from one run to the next.

  • AI Penetration Testing

    AI-driven security testing that uses autonomous systems to identify and validate exploitable vulnerabilities across applications, APIs, and infrastructure at a speed and scale that manual testing cannot replicate.