# trivedy-langchain-anatomy-agent-harness-2026-03-10

## Veille

Anatomy of an Agent Harness: Agent = Model + Harness, foundational components and the evolution of LangChain harnesses

## Titre Article

The Anatomy of an Agent Harness

## Date

2026-03-10

## URL

https://blog.langchain.com/the-anatomy-of-an-agent-harness/

## Keywords

agent harness, harness engineering, Agent = Model + Harness, filesystem, sandbox, bash, code execution, memory, search, context rot, compaction, long-running execution, Ralph Loop, planning, self-verification, model-harness co-evolution, deepagents, LangChain, Terminal Bench

## Authors

Vivek Trivedy

## Ton

**Profile**: Framework-developer perspective, didactic technical register, intermediate-to-advanced level. Vivek writes like an engineer systematically breaking down a concept to make it actionable.

**Description**: The tone is pedagogical and structured, following a logical derivation approach: each harness component is justified by starting from a desired agent behavior and working back toward the technical solution. The article uses a recurring pattern, "Behavior we want → Harness Design to help the model achieve this," that makes the reading progressive and understandable. The style is technical yet accessible, with concrete examples drawn from the LangChain ecosystem. The author takes a nuanced stance on the future of harnesses: even though models will absorb some harness functions, harness engineering will remain useful because it builds systems around the model's intelligence. The target audience is developers building AI agents.

## Pense-betes

- **Fundamental definition**: Agent = Model + Harness. "If you're not the model, you're the harness." The harness = all the code, configuration, and execution logic that is not the model itself
- **Harness components**: system prompts, tools/Skills/MCP and their descriptions, embedded infrastructure (filesystem, sandbox, browser), orchestration logic (subagents, handoffs, model routing), hooks/middleware for deterministic execution (compaction, continuation, lint checks)
- **Filesystem**: the most fundamental primitive of the harness. Unlocks: workspace, incremental storage, multi-agent/human collaboration surface. Git adds versioning
- **Bash + code execution**: a general-purpose tool rather than pre-configured tools for each action. The model designs its own tools on the fly via code
- **Sandboxes**: safe, isolated execution environments. Unlock scalability (created on demand, destroyed afterward). Good environments include default tools (runtimes, git CLI, browsers)
- **Memory and search**: the filesystem as a memory primitive (AGENTS.md loaded into context at startup). Web Search and MCP (e.g. Context7) to access knowledge beyond the training cutoff
- **Context rot**: performance degradation as the context window fills up. Solutions: compaction (intelligent summarization), offloading tool results, Skills as progressive disclosure
- **Ralph Loop**: a harness pattern that intercepts the model's exit attempt via a hook and re-injects the original prompt into a clean context window, forcing the agent to continue. The filesystem enables this because each iteration starts from a fresh context but reads the state of the previous iteration
- **Self-verification**: hooks that run a test suite and loop feedback back to the model with the error message on failure
- **Model-harness co-evolution**: agent products (Claude Code, Codex) are post-trained with model and harness in the loop. This creates overfitting (e.g. changing apply_patch logic degrades performance). But the best harness for your task is not necessarily the one the model was trained with
- **Terminal Bench 2.0**: Opus 4.6 in Claude Code scores well below Opus 4.6 in other harnesses. LangChain went from Top 30 to Top 5 by changing only the harness
- **Future**: some harness functions will be absorbed by models, but harness engineering will remain useful because it builds systems around the model's intelligence, not just patches for its shortcomings
- **deepagents**: LangChain's library for improving harness building. Open problems: orchestrating hundreds of agents in parallel, agents analyzing their own traces, harnesses dynamically assembling the right tools just-in-time

## RésuméDe400mots

Vivek Trivedy of LangChain proposes a structured definition of the agent harness: Agent = Model + Harness. The harness encompasses all the code, configuration, and execution logic that is not the model itself, including system prompts, tools and MCP, embedded infrastructure, orchestration logic, and deterministic hooks.

The article derives each harness component from the desired behaviors that models cannot natively provide. The **filesystem** is identified as the most fundamental primitive: it offers a workspace, incremental storage, and a collaboration surface between agents and humans. **Bash and code execution** provide a general-purpose tool that lets the model design its own tools on the fly. **Sandboxes** offer safe, scalable execution environments with default tools pre-installed.

For **memory**, the filesystem serves as the central primitive via standard files like AGENTS.md, loaded into context at startup and updated between sessions. Web search and MCP tools (such as Context7) provide access to knowledge beyond the training cutoff.

The article identifies **context rot** as a major challenge: performance degrades as the context window fills up. Solutions include compaction (intelligent summarization of context), offloading large tool results to the filesystem, and Skills as a progressive disclosure mechanism.

For **long-running execution**, the previous primitives compose together. The **Ralph Loop** is a pattern that intercepts the model's attempt to exit and re-injects the prompt into a clean context, forcing the work to continue. Planning and self-verification (tests + a correction loop) keep the agent on the right trajectory.

The article explores **model-harness co-evolution**: agent products like Claude Code and Codex are post-trained together with their harness, creating a coupling (changing a tool's logic can degrade performance). However, the best harness for a given task is not necessarily the one used for training — LangChain went from Top 30 to Top 5 on Terminal Bench 2.0 by changing only the harness.

In conclusion, even though some harness functions will be absorbed by models, harness engineering will remain relevant because it builds systems around the model's intelligence. LangChain is developing deepagents and exploring massive agent orchestration, self-analysis of traces, and dynamic just-in-time context assembly.

## GrapheDeConnaissance

- Vivek Trivedy —publie→ The Anatomy of an Agent Harness (DOCUMENT, 0.99)
- Vivek Trivedy —travaille_chez→ LangChain (ORGANISATION, 0.95)
- LangChain —a_créé→ deepagents (TECHNOLOGIE, 0.95)
- LangChain —mesure→ passage du Top 30 au Top 5 sur Terminal Bench 2.0 en changeant uniquement le harnais (MESURE, 0.92)
- Harnais d'agent —est_instance_de→ Tout ce qui n'est pas le modèle dans un agent (CONCEPT, 0.98)
- Système de fichiers —est_instance_de→ Primitive la plus fondamentale du harnais (CONCEPT, 0.9)
- Ralph Loop —utilise→ Interception de la tentative de sortie du modèle (CONCEPT, 0.88)
- Context Rot —réduit→ Performance de l'agent (CONCEPT, 0.92)
- Compaction —résout→ Context Rot (CONCEPT, 0.9)
- Claude Code —est_basé_sur→ Post-entraînement avec harnais dans la boucle (CONCEPT, 0.85)
- Codex —est_basé_sur→ Post-entraînement avec harnais dans la boucle (CONCEPT, 0.85)
- Opus 4.6 —mesure→ scores très différents selon le harnais utilisé (Terminal Bench 2.0) (MESURE, 0.88)

---
Canonical: https://www.thekb.eu/en/fiches/trivedy-langchain-anatomy-agent-harness-2026-03-10/
