定义
1. AI Harness 的正式定义
1.1. 统一定义
本白皮书全文(以及本工程全部 176 篇调研文档)统一采用如下定义,不得改写:
AI Harness(人工智能驾驭层 / 智能体运行时框架):位于基础模型(Foundation Model)与真实业务系统之间的一整套工程化承载层。它不负责提升模型本身的智能,而负责把模型的不确定性转化为工程上的可预期性。
Harness 一词借自软件工程的 Test Harness(测试夹具):测试夹具不生产功能,但让功能可被自动、可重复、可判定地验证。AI Harness 同理——它让模型能力可被编排、可被观测、可被约束、可被回归验证。
定义中有四个关键词值得逐一强调:位置(模型与业务系统之间)、职责(承载而非增强智能)、目标(可预期性而非能力上限)、手段(编排、观测、约束、回归验证)。
1.2. 定义的四个限定条件
为了避免歧义,该定义包含四个必须同时满足的限定条件:
| 限定条件 | 含义 | 反例 |
|---|---|---|
| 位置限定 | 必须位于基础模型与业务系统之间 | 模型训练、微调、推理基础设施不属于 Harness |
| 职责限定 | 不负责提升模型智能,只负责承载与约束 | 仅为“让模型更聪明”而做的提示词技巧,不属于 Harness 的核心职责 |
| 目标限定 | 目标是可预期性,而非能力上限 | 单纯为刷榜而做的基准优化不属于 Harness 工程目标 |
| 手段限定 | 通过编排、观测、约束、回归验证四种手段达成 | 一次性的人工审核不是 Harness |
四个限定条件合起来划出了一条清晰的界线:Harness 是工程层,不是模型层,也不是业务层。凡是试图用“更强的模型”或“更聪明的提示词”来解决的问题,都不在 Harness 的射程之内;凡是“同样的模型,换个环境表现就不同”的问题,都在。
1.3. 定义的多角度印证
除统一定义外,以下四组来自厂商与方法论社区的一手表述,可从不同角度印证这一定义:
表述一 · Anthropic(产品定义)。Anthropic 在《Effective harnesses for long-running agents》(2025,A 级)中直接把 Claude Agent SDK 定义为 harness:“The Claude Agent SDK is a powerful, general-purpose agent harness adept at coding, as well as other tasks that require the model to use tools to gather context, plan, and execute.” 这是“Harness”一词被头部厂商写进产品定义的直接证据。
表述二 · OpenAI(三大支柱)。OpenAI 在《Harness engineering》(2026-02-11,A 级)中给出核心哲学“Human Steer, Agent Execute”,并把 Harness 工程拆为三大支柱:
| 支柱 | 英文 | 含义 |
|---|---|---|
| 上下文工程 | Context Engineering | 决定模型看到什么 |
| 架构约束 | Architecture Constraints | 决定系统能被怎样组合 |
| 垃圾回收 | Garbage Collection | 治理熵增,防止文档与规则腐烂 |
表述三 · martinfowler.com(方法论界定)。Birgitta Böckeler 把 Harness 拆为三个维度:guides(引导,前馈控制——在行动之前告诉智能体该怎么做)、sensors(传感,反馈控制——在行动之后检查结果是否合格)、behavioural harness(行为约束——把前两者组织成可执行的约束体系)。同文中一句话应当被反复引用:“A good harness should not necessarily aim to fully eliminate human input, but to direct it to where our input is most important.”
表述四 · martinfowler.com(中间层定位)。《Humans and Agents in Software Engineering Loops》(2026,A 级)提出“in the loop”(人工修改产物)与“on the loop”(修改产生产物的 harness)的区分,并界定:“The collection of specifications, quality checks, and workflow guidance that control different levels of loops inside the how loop is the agent's harness.” 这一表述明确了 Harness 是可被持续改进的中间层,而不是一次性写好的提示词。
2. 词源与类比
2.1. 软件工程中的 Test Harness
在软件工程传统中,Test Harness(测试夹具 / 测试支架)指外部于被测软件的一套执行环境。它的职责是:
- 准备测试所需的输入与依赖(stub、mock、fixture);
- 驱动被测组件运行;
- 收集输出结果;
- 把结果与预期判据比对,产出通过或失败的判定。
它的关键特征是:不执行被测组件本身的业务逻辑,但让该逻辑可被自动、可重复、可判定地验证。需要说明,本工程未能直接抓取相关百科条目原文,上述描述基于软件工程通行定义并经多篇二手来源交叉印证,具体措辞标 。
2.2. 同构性:为什么这个类比成立
把 Test Harness 的结构映射到 AI 场景,可以得到几乎一一对应的关系:
| Test Harness 的组成部分 | AI Harness 中的对应物 | 所属层 |
|---|---|---|
| 测试输入与 fixture | 检索到的上下文、少样本示例、环境快照 | L1 |
| 被测组件的外部依赖(stub / mock) | 工具注册、MCP server、沙箱执行器 | L2 |
| 测试驱动脚本 | 编排循环、状态机、子智能体派发 | L3 |
| 测试间共享的状态 | 会话态、长期记忆、检查点 | L4 |
| 断言与判据 | 评估集、轨迹追踪、回归基准 | L5 |
| 测试隔离与权限边界 | 权限模型、护栏、审计日志、预算约束 | L6 |
Agent Harness 与 Test Harness 的同构性在于:它存在于智能体推理逻辑的外部,不干预模型内部的决策过程,但确保智能体的行动在受控环境中被执行、被追踪、被约束。测试夹具不生产功能,但让功能可验证;AI Harness 不生产智能,但让智能可交付。
2.3. 马具:harness 一词的本义
harness 一词的本义是马具(源自十二世纪古法语 harneis,本义为“成套战具 / 甲胄”)。这个类比同样精确:
- 马决定往哪里跑——对应模型决定输出什么;
- 马具不参与决策——对应 Harness 不干预模型内部推理;
- 马具管控力量如何被传导、约束越界、防止脱轨——对应 Harness 管控上下文、权限与副作用。
Test Harness 强调可验证性,马具强调可控性。两者合起来,恰好覆盖 AI Harness 的两个核心价值。
2.4. 命名确立的时间线
“Harness”作为 AI 领域术语被主流接受,经历了三个阶段(全部为 A 级来源):
| 时点 | 事件 |
|---|---|
| 2025 年内 | Anthropic 在官方文档中用 “harness” 描述 Claude Agent SDK |
| 2026-02-05 | Mitchell Hashimoto 发表《My AI Adoption Journey》,把 “Engineer the Harness” 列为其 AI 采用六阶段中的第五阶段 |
| 2026-02-11 | OpenAI 发布官方博客《Harness engineering: leveraging Codex in an agent-first world》 |
| 2026-02 | Birgitta Böckeler 在 martinfowler.com 发表 Harness engineering 体系文章 |
Hashimoto 对第五阶段的描述(转述)是:“每次当你发现 Agent 犯了一个错误,就花时间去工程化一个解决方案,让它永远不会再犯同样的错误。”这句话揭示了 Harness 工程的本质:不是让模型更强,而是把每一次失败固化成不会再犯的机制。
需要如实说明:“Agent Harness”这一术语的首创者与首次出现的一手出处,本工程未能确认。常被提及的 LangChain《The Anatomy of an Agent Harness》一文,未检索到原文与确切发布日。本白皮书不作首创归属主张。
3. 为什么 Harness 需要独立成层
一个常见的质疑是:上下文管理、工具调用、评估这些东西,早已分散在框架、平台与最佳实践里,为什么还要发明一个新概念、新层级?本章用三个相互独立的论证回答。
3.1. 论证一:评测变量论证
论证形式:如果某个因素在受控评测中被证实能系统性改变结果,它就不是实现细节,而是独立变量;独立变量需要独立的工程纪律。
事实基础:
- Terminal-Bench(Stanford + Laude Institute)方法论明确声明:“每一个结果都是模型加智能体框架的组合……排行榜排的是系统,不是模型”(A 级)。评测社区已经把 Harness 作为变量写进了方法论。
- SWE-bench 历史上,Claude 3.5 Sonnet 搭配 agentic harness 于 2024 年下半年达到 49.0%——第一次在公开基准的成绩单里写入了 Harness(C 级)。
- 多个同模型不同分的对照案例(详见 01-引言 3.3 节,数字均 ):仅更换智能体框架可带来 2 个百分点以上的差异;仅重构 Harness 可带来 13 个百分点以上的排名跃迁。
- 模型与 Harness 的后训练耦合已被官方确认:Anthropic 指出头部编码产品已在后训练阶段把模型与特定 Harness 结构放在一起训练,改变工具逻辑反而让模型表现变差(A 级)。
结论(判断):Harness 已经是评测中的显式变量、产业中的竞争变量。一个能够系统性决定结果的因素,必须被独立命名、独立设计、独立治理——这正是“独立成层”的含义。
3.2. 论证二:行业差异化论证
论证形式:如果八个差异极大的行业在面对同一套能力模型时,呈现出系统性的、可解释的侧重差异,那么这套模型就是真实存在的公共结构,而不是某家厂商的产品说明书。
事实基础:本工程八大行业组的调研(详见 04-实践)得出的瓶颈层分布如下:
| 行业组 | 最重/瓶颈层 | 结构性原因 |
|---|---|---|
| AI Infra 组 | L2 工具与执行(物理底座)、L5 评估与观测、L6 治理与安全 | 芯片与超节点决定物理上限;训推框架是 L2/L3 调度中枢;故障降级与能耗约束属 L5/L6 |
| 具身智能组 | L2 工具与执行、L5 评估与观测(大脑与小脑瓶颈在 L5,执行器瓶颈在 L2) | 大小脑分离:低频语义规划与高频实时控制环解耦;sim2real 是唯一可回归的评估闭环 |
| 软件工程组 | L1 上下文工程、L5 评估与观测 | 代码库即外部记忆,度量侧尚未越过可信阈值(自评 +80% 对实测 −19%) |
| 硬件研发组 | L2 工具与执行、L5 评估与观测(最重);L6 代价最高 | EDA 工具不可替代,智能体的角色是编排引擎而非替代引擎;tape-out 不可逆 |
| 知识协同组 | L1 上下文工程、L4 记忆与状态 | 任务是知识的取用与沉淀,权限必须下沉到检索层 |
| 数据科学组 | L5 评估与观测、L6 治理与安全 | 静默错误(管道不崩溃只撒谎)与数据分级硬边界 |
| 创意产业组 | L4 记忆与状态(内容侧)、L6 治理与安全(合规) | 跨会话一致性是质量瓶颈;标识合规已下沉到元数据级 |
| 风险合规组 | L6 治理与安全 | L6 的输出物本身就是交付给监管与法庭的最终交付物 |
结论(判断):八个行业共享同一个六层骨架,但权重分布完全不同——这不是巧合,而是“Harness 是一层独立工程能力”的直接证据:正因为它是独立的层,它才能被不同行业按各自的风险结构与判据形态重新加权。如果 Harness 只是模型的功能或框架的附属品,就无法解释这种跨行业的结构性差异。
3.3. 论证三:失败模式论证
论证形式:如果把 Harness 的职责拆散给模型、框架和业务代码分别承担,每一块都会以可预测的方式失败;这些失败模式恰恰是六层模型要防范的对象。
第二代的实践(约 2023—2025)提供了完整的反例记录(详见 01-概述 / 02-发展历史第 4 章):
| 失败模式 | 表现 | 归属层 |
|---|---|---|
| 上下文腐烂 | 长任务下关键指令被挤出窗口,性能渐进退化 | L1 |
| 工具过载 | 工具越多决策点越含糊,工具数量与表现并非正相关 | L2 |
| 编排失控 | 无约束循环导致无限循环、目标漂移、成本失控(AutoGPT 一代的教训) | L3 |
| 状态丢失 | 跨会话、跨窗口交接时上下文断裂,长任务必然中断 | L4 |
| 自评偏差 | 让智能体评估自己的作品,它会“自信地称赞”平庸产物 | L5 |
| 权限裸奔 | 权限提示频繁打断,既不安全也不流畅;或一次性授予过宽 | L6 |
结论(判断):六类失败模式跨越六个不同环节,任何单点方案(更长的上下文、更好的框架、更强的模型)都只能覆盖其中一两种。它们需要一层统一的、有主观立场的工程基础设施来整体防范——这层基础设施就是 Harness。与“中立”的框架不同,Harness 会明确告诉你上下文该怎么组织、工具该怎么裁剪、什么算“完成”。
3.4. 三个论证的共同结论
三个论证相互独立而结论一致:
- 评测变量论证说明 Harness 必须被度量为一个变量;
- 行业差异化论证说明 Harness 可以被独立加权为一个层;
- 失败模式论证说明 Harness 必须被统一建设为一个层。
三者合起来支持本白皮书的中心命题:在模型能力给定的前提下,系统表现的方差主要由 Harness 决定。
4. 六层能力模型逐层定义
图 4-1|AI Harness 六层能力模型与层间依赖关系
数据来源:基于本文分析绘制的示意图。
4.1. 模型总览
本白皮书全文统一使用如下六层能力模型,它是后续所有章节的公共坐标系:
| 层 | 名称 | 英文 | 职责一句话 | 典型实现 |
|---|---|---|---|---|
| L1 | 上下文工程层 | Context Engineering | 决定模型“看到什么” | RAG、Context Compaction、Prompt Assembly、KV Cache 复用 |
| L2 | 工具与执行层 | Tooling & Execution | 决定模型“能做什么” | MCP、Function Calling、沙箱执行器、Computer Use |
| L3 | 编排与控制层 | Orchestration & Control | 决定“按什么顺序做” | Agent Loop、Plan-and-Execute、DAG / Workflow、Sub-agent |
| L4 | 记忆与状态层 | Memory & State | 决定“记住什么” | Session Store、Episodic / Semantic Memory、Checkpoint |
| L5 | 评估与观测层 | Evaluation & Observability | 决定“做得好不好” | Trace、Eval Set、Golden Dataset、Online Metrics |
| L6 | 治理与安全层 | Governance & Safety | 决定“不能做什么” | RBAC、护栏模型、审计日志、Budget Guardrail |
以下各节按统一结构逐层展开:职责、关键组件、代表性实现、典型失败模式。
4.2. L1 上下文工程层
职责:在每一步推理之前,决定模型应当看到哪些 token。Anthropic 的官方定义是:在 LLM 推理期间,策展并维护那组最优 Token(信息)的一整套策略(A 级)。
两个关键官方概念:
- context rot(上下文腐烂):上下文变长时性能是渐进退化(性能梯度),而非到某个长度突然崩塌——因此上下文治理必须靠工程手段持续进行,不能依赖“卡一个阈值”。
- 注意力预算(attention budget):由于自注意力的关联特性,上下文中每增加一个 token 都会稀释模型对其他 token 的注意力。上下文是稀缺资源,不是免费容器。
关键组件与代表性实现:检索(RAG、Contextual Retrieval、GraphRAG)、压缩(Context Compaction)、缓存(KV Cache 复用)、装配(Prompt Assembly)、按需加载(Agent Skills 的三层渐进式披露)。
典型失败模式:上下文膨胀导致关键指令被挤出;检索返回已删除的旧接口;把整个知识库塞进提示词造成负收益(多文档问答呈 U 形位置效应,相关信息埋在中部时表现甚至可能低于闭卷)。
4.3. L2 工具与执行层
职责:决定模型能对环境施加哪些动作,以及这些动作在哪里执行。
关键组件与代表性实现:
| 组件类别 | 作用 | 代表 |
|---|---|---|
| 工具注册与描述 | 把外部能力声明为模型可调用的结构化接口 | Function Calling、JSON Schema 工具描述 |
| 连接协议 | 让工具生态与宿主应用解耦 | MCP(Model Context Protocol) |
| 执行环境 | 限定动作的作用范围与副作用边界 | 沙箱(Seatbelt / bubblewrap / Landlock + seccomp)、Computer Use |
一条反直觉的实证:工具数量与表现并非正相关。Vercel 将工具从 15 个削减到 2 个后,准确率从 80% 升至 100%,Token 消耗下降 37%,速度提升 3.5 倍(C 级)。Anthropic 官方亦建议工具应“自包含、对错误健壮、用途极其明确”(A 级)。
典型失败模式:沙箱逃逸;工具返回巨大输出污染上下文;并行写冲突;破坏性动作未设人工闸门。
4.4. L3 编排与控制层
职责:决定按什么顺序做、谁来做、中断后怎么恢复。
关键编排形态:
| 形态 | 适用 | 代表 |
|---|---|---|
| 单循环(Agent Loop) | 通用任务,模型自主决策下一步 | ReAct 循环、Claude Code 主循环 |
| 计划-执行(Plan-and-Execute) | 长周期、需要全局规划的任务 | Claude Code Plan Mode |
| 有向无环图 / 工作流 | 确定性要求高的业务流程 | DAG / Workflow 引擎 |
| 子智能体派发 | 可并行探索的复杂任务 | Sub-agent、Orchestrator-Worker |
Anthropic 官方给出的子智能体参数:子智能体可用数万 token 深入探索,但只回传 1,000~2,000 tokens 的浓缩摘要(A 级)——典型的“用上下文换并行度”的架构取舍。
典型失败模式:循环不收敛;子智能体上下文互相污染;中断后状态丢失、恢复后重复执行副作用。
4.5. L4 记忆与状态层
职责:跨会话、跨上下文窗口时,状态如何交接。Anthropic 的比喻:像工程师轮班工作的软件项目,每位新工程师上班时对前一班发生的事情毫无记忆(A 级)。官方解法是进度文件加版本库历史,并规定智能体每次会话开场必做三步:确认工作目录、读取历史与进度、读取任务清单选出最高优先项;结束时必须把环境留在可合并的干净状态。
两种上下文交接机制的区别(A 级):
| 机制 | 做法 | 优点 | 代价 |
|---|---|---|---|
| Compaction(压缩) | 就地摘要 | 保留连续性 | “上下文焦虑”仍在 |
| Context Reset(重置) | 清空后重新注入 | 给干净白板 | 交接产物必须足够完整 |
典型失败模式:检查点未包含工具副作用;恢复后重放导致重复写;错误信息进入长期记忆后持续传播(上下文投毒,context poisoning)。
4.6. L5 评估与观测层
职责:决定做得好不好、如何判定、如何回归。
最重要的设计原则(Anthropic《Harness design for long-running apps》,A 级):评估者与被评估者必须分离。让智能体评估自己的作品时,它会“自信地称赞”——即便质量明显平庸。官方结论是:把一个独立的 Evaluator 调教得怀疑,远比让 Generator 自我批判容易得多。
关键组件与代表性实现:轨迹追踪(Trace)、评估集(Eval Set)、黄金数据集(Golden Dataset)、回归集与回归门控、在线指标(Online Metrics)、程序化判分原则(SWE-bench 与 Terminal-Bench 共同确立:“测试通过即通过”,没有“看起来不错但测试不过”的部分分)。
典型失败模式:只看最终结果不看过程;回归集被反复“优化”到过拟合;评估口径漂移(跨榜比较基本无效);评估成本过高导致回归停摆。
4.7. L6 治理与安全层
职责:决定什么不能做、做了怎么发现、花多少钱有上限。
关键组件与代表性实现:权限模型(RBAC)、护栏模型(Guardrails)、审计日志、预算护栏(Budget Guardrail)、凭据保护、三级配置作用域(项目级 / 用户级 / 组织级)。
一条必须澄清的实证:常见误解认为“治理拖慢自主性”。三组证据指向相反结论(判断:约束即能力):
| 证据 | 数据 | 来源等级 |
|---|---|---|
| Anthropic 沙箱内部使用 | 权限提示减少 84%,同时安全性提升 | A |
| OpenAI 架构约束 | “约束让速度成为可能,且架构不漂移” | A |
| Codex Auto-review | 人工审批停止次数约为手动模式的 1/200,审阅批准率约 99% | B, |
典型失败模式:权限一次性授予过宽;审计日志不含输入上下文导致不可复盘;把可观测性(L5,服务优化)与审计(L6,服务举证)混为一谈——两者的留存期限、不可篡改要求与访问主体都不同。
4.8. 六层之间的依赖与调用关系
图 4-2|六层之间的依赖与调用关系
六层并非并列堆砌,而是存在明确的依赖方向:
┌─────────────────────────────────────────┐
│ L6 治理与安全层(贯穿全层,横向切面) │
└─────────────────────────────────────────┘
▲ 约束与审计
L1 上下文 ──► L2 工具与执行 ──► L3 编排与控制
▲ │ │
│ ▼ ▼
└──────── L4 记忆与状态 ◄──────────┘
│
▼
L5 评估与观测
│
└──► 反馈回 L1(改变下次看到什么) 阅读要点:
- L1 → L2 → L3 是主执行链:先决定看到什么,再决定能做什么,最后决定按什么顺序做。
- L4 为 L1 / L3 提供跨会话的状态支撑,是时间维度的横向支撑层。
- L5 观察全链并产出反馈,反馈最终回到 L1。
- L6 是横向切面,对 L1~L5 全部施加约束并记录审计。
5. 与相邻概念的边界
5.1. 边界总表
本白皮书全文统一使用如下边界:
| 概念 | 与 AI Harness 的关系 |
|---|---|
| Agent(智能体) | 运行在 Harness 之上的执行单元;Harness 是 Agent 的“底盘” |
| Agent Framework(LangGraph 等) | 主要覆盖 L2 / L3,是 Harness 的子集 |
| Agent Platform(Dify 等) | Harness 的产品化封装,叠加 UI、租户、计费 |
| AI IDE(Cursor 等) | Harness 在编码场景的垂直集成形态 |
| Model(模型) | Harness 的被承载对象,不属于 Harness 本身 |
| MLOps / LLMOps | 关注模型生命周期;Harness 关注智能体任务生命周期 |
5.2. 逐概念辨析
与 Agent 的边界。Agent 是执行单元,Harness 是底盘,二者是“车与路”的关系。判据:如果更换它不改变“模型的输出分布如何被约束与验证”,它属于 Agent;如果更换它改变了“模型如何被编排、观测、约束与回归验证”,它属于 Harness。中国官方对“智能体”的定义可作中文语境口径(A 级):“智能体是具备自主感知、记忆、决策、交互与执行能力的新型智能系统,已成为人工智能产品与服务的关键载体。”
与 Agent Framework 的边界。Framework(如 LangChain / LangGraph)主要覆盖 L2 与 L3,是 Harness 的子集。关键区别在于:Framework 中立,Harness 有主张——Harness 会明确告诉你上下文该怎么组织、工具该怎么裁剪、什么算“完成”,而 Framework 只提供构建块、不提供意见。这正是第二代“Framework 即解决方案”认知的盲区:Framework 不解决生产问题。
与 Agent Platform 的边界。Platform 是 Harness 的产品化封装,在其之上叠加可视化编排 UI、多租户与权限体系、计费与配额、面向非技术用户的发布运营能力。判据:剥离 UI、租户与计费后剩下的那部分运行时,就是 Harness。
与 AI IDE 的边界。AI IDE 是 Harness 在编码场景的垂直集成形态,叠加了编辑器、终端、diff 视图、LSP 集成等编码专属能力。其中终端类产品(Claude Code、Codex CLI)更接近“终端形态的 Harness”,编辑器类产品(Cursor)更接近“IDE 形态的 Harness”。
与 Model 的边界。Model 是被承载对象,不属于 Harness。这条边界在 2025—2026 年出现了值得注意的模糊化:头部厂商已在后训练阶段把模型与 Harness 放在一起训练,造成“模型过拟合到特定 Harness 结构”的副作用——改变工具逻辑反而让模型表现变差(A 级)。其实践含义:适合你任务的最佳 Harness,不一定是模型被后训练时使用的那个。
与 MLOps / LLMOps 的边界。
| 维度 | MLOps / LLMOps | Harness Engineering |
|---|---|---|
| 关注对象 | 模型生命周期:训练、微调、部署、漂移监控 | 智能体任务生命周期:单次任务从意图到验证的闭环 |
| 时间尺度 | 天到月 | 秒到小时 |
| 核心产物 | 模型版本、特征仓库、部署流水线 | 上下文策略、工具集、评估集、护栏规则 |
| 方法来源 | 机器学习工程 | 软件工程手段的复用(左移反馈、变异测试、结构测试) |
5.3. 一个便于记忆的类比:计算机四层栈
业界流传一组类比(类比本身经多方转述可引用,其原始出处与配套案例标 ):
| 计算机概念 | AI 系统对应物 |
|---|---|
| CPU | 模型(Model) |
| RAM | 上下文窗口(Context Window) |
| 操作系统 | AI Harness |
| 应用程序 | Agent |
正如操作系统不生产算力但决定算力如何被使用,Harness 也不生产智能,但决定智能如何被安全、可预期地交付。注意:本类比仅用于辅助理解,不作为论证依据;“AI 操作系统”不作为正式术语(见第 6 章)。
6. 常见误用与澄清
| 序号 | 常见说法 | 本白皮书的澄清 |
|---|---|---|
| 1 | “Harness 就是一套好的提示词模板” | 提示词只是 L1 的一部分。六层模型中任何单层都不等于 Harness;一次性写好的提示词不可持续改进,而 Harness 是可被持续改进的中间层 |
| 2 | “Harness 就是 Agent Framework 换个名字” | Framework 中立、Harness 有主张;Framework 主要覆盖 L2 / L3,通常不含 L5 评估闭环与 L6 治理基座,是 Harness 的子集 |
| 3 | “更强模型出来后 Harness 就不需要了” | 模型变强会裁撤一部分 Harness 设计(官方自陈正在动态裁撤),但后训练耦合现象反而强化了 Harness 设计的重要性。Harness 会变轻、改构,不会消失 |
| 4 | “治理(权限、沙箱、审计)会拖慢智能体” | 实证方向相反:沙箱化后权限提示减少 84% 且更安全。“约束即能力”——治理与自主性是正和而非取舍 |
| 5 | “让智能体自己评估自己的产出即可” | 自评偏差是系统性现象。评估者与被评估者必须分离,主观任务尤甚 |
| 6 | “Harness 工程的目标是把榜单分数刷高” | 刷分不属于 Harness 工程目标。公开榜单只能校准能力天花板,不能预测内部收益 |
| 7 | “Harness 是一个可以采购的单一产品” | Harness 是一层能力,其产品形态多样(SDK、CLI、IDE、平台、企业运行时);采购某产品不等于建成该层能力 |
| 8 | “上下文窗口足够大就不需要上下文工程” | U 形位置效应与多项长上下文评测表明,堆上下文可能带来负收益;大窗口改变的是策略空间,不是取消策略 |
| 9 | “可观测性和审计是一回事” | L5 观测服务于优化,L6 审计服务于举证;留存期限、不可篡改要求与访问主体均不同 |
| 10 | “AI Harness / Agent Harness / Agent Runtime 随便叫” | 本白皮书统一使用“AI Harness”;“Agent Harness”仅指编码等具体场景下的实现形态;“Agent Runtime”指 Harness 的运行时产品形态 |
7. 总结
- 定义:AI Harness 是位于基础模型与真实业务系统之间的工程化承载层,把模型的不确定性转化为工程上的可预期性;它不提升智能,但让智能可被编排、观测、约束、回归验证。
- 词源:Test Harness 的可验证性 + 马具的可控性,共同构成这个词的两面。
- 独立成层的三重论证:评测变量论证(它是评测中的显式变量)、行业差异化论证(八个行业对同一六层骨架给出系统性不同的权重)、失败模式论证(六类跨环节失败需要统一防范)。
- 六层能力模型:L1 看到什么、L2 能做什么、L3 按什么顺序、L4 记住什么、L5 做得好不好、L6 不能做什么——六层有依赖方向,L6 横向贯穿,L5 反馈回流 L1。
- 边界:Agent 是执行单元、Framework 是子集、Platform 是封装、AI IDE 是垂直形态、Model 是被承载对象、MLOps 关注另一条生命周期。
- 中心命题:在模型能力给定的前提下,系统表现的方差主要由 Harness 决定。
8. 信息缺口声明
- 同模型不同分的全部对照数字(77.3% 对 75.1%、52.8% 对 66.5%、Vercel 80% 对 100%、Claude 3.5 Sonnet + agentic harness 49.0%):来自 B/C 级来源,标 。
- Wikipedia “Test harness” 条目原文:未直接抓取,2.1 节措辞基于通行定义并经二手交叉印证,标 。
- “Agent Harness”术语首创出处:未找到一手首创文献;LangChain《The Anatomy of an Agent Harness》原文与发布日未检索到,暂无权威信息。
- 计算机四层栈类比的原始出处:类比可引用,原始出处与配套案例标 。
- Codex Auto-review 的 1/200 与 99%:B 级来源,标 。
- 行业差异化论证中的瓶颈层分布:来自本工程八大行业组的分析性结论(判断),非公开标准的评级,引用时应注明。
9. 参考资料
- Effective harnesses for long-running agents — Anthropic,2025。https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents
- Harness design for long-running application development — Anthropic,2026。https://www.anthropic.com/engineering/harness-design-long-running-apps
- Effective context engineering for AI agents — Anthropic,2025。https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents
- Harness engineering: leveraging Codex in an agent-first world — OpenAI,2026-02-11。https://openai.com/index/harness-engineering/
- Harness engineering for coding agent users — Birgitta Böckeler,martinfowler.com,2026。https://martinfowler.com/articles/harness-engineering.html
- Humans and Agents in Software Engineering Loops — martinfowler.com,2026。https://martinfowler.com/articles/exploring-gen-ai/humans-and-agents.html
- My AI Adoption Journey — Mitchell Hashimoto,2026-02-05。https://mitchellh.com/writing/my-ai-adoption-journey
- Introducing the Model Context Protocol — Anthropic,2024-11-25。https://www.anthropic.com/news/model-context-protocol
- SWE-bench: Can Language Models Resolve Real-World GitHub Issues? — Jimenez、Yang 等(Princeton),2023-10(ICLR 2024 Oral)。https://www.swebench.com/
- Terminal-Bench 官方站 — Stanford / Laude Institute,2025。https://www.tbench.ai/
- 《人工智能 智能体互联》系列国家标准解读 — 中国产业经济信息网,2026。https://cinic.org.cn/xw/zcdt/1643418.html
- Sandboxing: a safer and more autonomous approach — Anthropic,2025。https://www.anthropic.com/engineering/claude-code-sandboxing
Definitions
1. The Formal Definition of AI Harness
1.1. Unified Definition
This whitepaper in its entirety (as well as all 176 research documents in this project) uniformly adopts the following definition, without any rewording:
**AI Harness (AI Stewardship Layer / Agent Runtime Framework)**: an engineering carrier layer located between the Foundation Model and real business systems. It is not responsible for improving the model's own intelligence, but rather for converting the model's **uncertainty** into engineering **predictability**.
The word "Harness" is borrowed from software engineering's *Test Harness*: a test harness does not produce functionality, but it makes functionality verifiable automatically, repeatedly, and deterministically. AI Harness is analogous — it makes model capabilities orchestratable, observable, constrainable, and regression-verifiable.
Four key words in the definition deserve emphasis one by one: **position** (between the model and business systems), **responsibility** (carrying rather than enhancing intelligence), **goal** (predictability rather than capability ceiling), and **means** (orchestration, observation, constraint, and regression verification).
1.2. The Four Qualification Conditions of the Definition
To avoid ambiguity, the definition includes four qualification conditions that must all be satisfied simultaneously:
| Condition | Meaning | Counterexample |
|---|---|---|
| **Position condition** | Must be located between the foundation model and the business system | Model training, fine-tuning, and inference infrastructure do not belong to Harness |
| **Responsibility condition** | Not responsible for improving model intelligence; only for carrying and constraining | Prompt tricks done merely to "make the model smarter" are not part of Harness's core responsibility |
| **Goal condition** | The goal is predictability, not capability ceiling | Benchmark optimization done purely to climb leaderboards is not a Harness engineering goal |
| **Means condition** | Achieved through the four means of orchestration, observation, constraint, and regression verification | One-off manual review is not Harness |
The four qualification conditions together draw a clear boundary line: Harness is an **engineering layer**, not a model layer, and not a business layer. Any problem that tries to be solved with a "stronger model" or "smarter prompts" lies outside Harness's scope; any problem where "the same model performs differently in a different environment" lies inside it.
1.3. Corroboration of the Definition from Multiple Angles
In addition to the unified definition, the following four first-hand statements from vendors and the methodology community can corroborate this definition from different angles:
**Statement one · Anthropic (product definition)**. In *Effective harnesses for long-running agents* (2025, A-level), Anthropic directly defines the Claude Agent SDK as a harness: "The Claude Agent SDK is a powerful, general-purpose agent harness adept at coding, as well as other tasks that require the model to use tools to gather context, plan, and execute." This is direct evidence that the word "Harness" has been written into a product definition by a leading vendor.
**Statement two · OpenAI (three pillars)**. In *Harness engineering* (2026-02-11, A-level), OpenAI presents the core philosophy "Human Steer, Agent Execute" and splits Harness engineering into three pillars:
| Pillar | English | Meaning |
|---|---|---|
| Context engineering | Context Engineering | Determines what the model sees |
| Architecture constraints | Architecture Constraints | Determines how the system can be composed |
| Garbage collection | Garbage Collection | Governs entropy, preventing documents and rules from rotting |
**Statement three · martinfowler.com (methodological definition)**. Birgitta Böckeler splits Harness into three dimensions: guides (guidance, feedforward control — telling the agent what to do before it acts), sensors (sensing, feedback control — checking after it acts whether the result is satisfactory), and behavioural harness (behavioral constraints — organizing the first two into an executable system of constraints). One sentence in the same article deserves to be quoted again and again: "A good harness should not necessarily aim to fully eliminate human input, but to direct it to where our input is most important."
**Statement four · martinfowler.com (middle-layer positioning)**. *Humans and Agents in Software Engineering Loops* (2026, A-level) draws the distinction between "in the loop" (humans modifying artifacts) and "on the loop" (the harness that modifies the artifacts being produced) and defines: "The collection of specifications, quality checks, and workflow guidance that control different levels of loops inside the how loop is the agent's harness." This statement makes clear that Harness is a **middle layer that can be continuously improved**, not a one-off prompt written once.
2. Etymology and Analogies
2.1. Test Harness in Software Engineering
In the software engineering tradition, a *Test Harness* (test fixture / test scaffolding) refers to **an execution environment external to the software under test**. Its responsibilities are:
- Prepare the inputs and dependencies required for testing (stubs, mocks, fixtures);
- Drive the component under test to run;
- Collect the output results;
- Compare the results against the expected criteria and produce a pass or fail verdict.
Its key characteristic is: **it does not execute the business logic of the component under test itself, but it makes that logic verifiable automatically, repeatedly, and deterministically**. It should be noted that this project was unable to directly capture the original text of the relevant encyclopedia entries; the above description is based on the prevailing definition in software engineering and has been cross-corroborated through multiple secondary sources, and its specific wording is marked `[to be verified]`.
2.2. Isomorphism: Why This Analogy Holds
Mapping the structure of a Test Harness onto the AI scenario produces an almost one-to-one correspondence:
| Component of the Test Harness | Counterpart in AI Harness | Layer |
|---|---|---|
| Test inputs and fixtures | Retrieved context, few-shot examples, environment snapshots | L1 |
| External dependencies of the component under test (stub / mock) | Tool registration, MCP server, sandbox executor | L2 |
| Test driver scripts | Orchestration loops, state machines, sub-agent dispatch | L3 |
| State shared between tests | Session state, long-term memory, checkpoints | L4 |
| Assertions and criteria | Evaluation sets, trajectory tracing, regression baselines | L5 |
| Test isolation and permission boundaries | Permission models, guardrails, audit logs, budget constraints | L6 |
The isomorphism between Agent Harness and Test Harness lies in this: it **exists outside the agent's reasoning logic** and **does not intervene in the model's internal decision-making process**, yet it ensures that the agent's actions are executed, tracked, and constrained in a controlled environment. A test fixture does not produce functionality, but it makes functionality verifiable; AI Harness does not produce intelligence, but it makes intelligence deliverable.
2.3. Horse Harness: The Original Meaning of the Word
The original meaning of the word "harness" is **horse harness** (derived from the twelfth-century Old French *harneis*, whose original meaning was "full set of battle gear / armor"). This analogy is equally precise:
- The horse decides where to run — corresponding to the model deciding what to output;
- The harness does not participate in decision-making — corresponding to Harness not intervening in the model's internal reasoning;
- The harness governs how force is transmitted, constrains going out of bounds, and prevents derailment — corresponding to Harness governing context, permissions, and side effects.
Test Harness emphasizes **verifiability**, while the horse harness emphasizes **controllability**. Together, the two precisely cover the two core values of AI Harness.
2.4. Timeline of How the Name Was Established
As a term accepted by the mainstream in the AI field, "Harness" went through three stages (all from A-level sources):
| Point in time | Event |
|---|---|
| Within 2025 | Anthropic used "harness" to describe the Claude Agent SDK in its official documentation |
| 2026-02-05 | Mitchell Hashimoto published *My AI Adoption Journey*, listing "Engineer the Harness" as the fifth of his six stages of AI adoption |
| 2026-02-11 | OpenAI published the official blog *Harness engineering: leveraging Codex in an agent-first world* |
| 2026-02 | Birgitta Böckeler published her system article on Harness engineering on martinfowler.com |
Hashimoto's description of the fifth stage (paraphrased) is: "Every time you find the Agent making a mistake, take the time to engineer a solution so that it never makes the same mistake again." This sentence reveals the essence of Harness engineering: **not making the model stronger, but solidifying every failure into a mechanism that will not recur**.
To be honest: this project was unable to confirm the originator of the term "Agent Harness" or the first-hand source where it first appeared. The frequently mentioned LangChain article *The Anatomy of an Agent Harness* could not be located for its original text or exact publication date. This whitepaper makes no claim of attribution for originating the term.
3. Why Harness Needs to Stand as Its Own Layer
A common objection is: context management, tool calling, and evaluation — these things are already scattered across frameworks, platforms, and best practices, so why invent a new concept and a new layer? This chapter answers with three mutually independent arguments.
3.1. Argument One: The Evaluation Variable Argument
**Argument form**: if a factor is proven in controlled evaluation to systematically change results, it is not an implementation detail but an independent variable; an independent variable requires an independent engineering discipline.
**Factual basis**:
- Terminal-Bench (Stanford + Laude Institute) methodology explicitly states: "Every result is a combination of a model plus an agent framework... leaderboards rank systems, not models" (A-level). The evaluation community has already written Harness into the methodology as a variable.
- In SWE-bench history, Claude 3.5 Sonnet paired with an agentic harness reached 49.0% in the second half of 2024 — **the first time Harness was written into the scorecard of a public benchmark** (C-level, `
[to be verified]`). - Multiple controlled cases of the same model with different scores (see 01-Introduction, section 3.3; all numbers `
[to be verified]`): merely changing the agent framework can produce a difference of more than 2 percentage points; merely restructuring the Harness can produce a ranking jump of more than 13 percentage points. - The post-training coupling of the model and Harness has been officially confirmed: Anthropic points out that leading coding products already train the model together with a specific Harness structure during post-training, and changing the tool logic actually makes the model perform worse (A-level).
**Conclusion (judgment)**: Harness is already an explicit variable in evaluation and a competitive variable in industry. A factor that can systematically determine results must be independently named, independently designed, and independently governed — this is precisely what "standing as its own layer" means.
3.2. Argument Two: The Industry Differentiation Argument
**Argument form**: if eight vastly different industries, when facing the same capability model, exhibit **systematic, explainable** differences in emphasis, then that model is a real, existing common structure rather than a product brochure from some vendor.
**Factual basis**: the research of this project's eight industry groups (see 04-Practice for details) yielded the following distribution of bottleneck layers:
| Industry group | Heaviest / bottleneck layer | Structural reason |
|---|---|---|
| AI Infrastructure group | L2 tooling and execution (physical substrate), L5 evaluation and observability, L6 governance and safety | Chips and supernodes determine the physical ceiling; training/inference frameworks are the L2/L3 scheduling hub; fault degradation and energy-consumption constraints fall under L5/L6 |
| Embodied Intelligence group | L2 tooling and execution, L5 evaluation and observability (the brain and cerebellum bottleneck is at L5, the actuator bottleneck is at L2) | Brain-cerebellum separation: low-frequency semantic planning decoupled from the high-frequency real-time control loop; sim2real is the only regressable evaluation closed loop |
| Software engineering group | L1 context engineering, L5 evaluation and observability | The codebase acts as external memory; the measurement side has not yet crossed the credibility threshold (self-assessment +80% vs. actual −19%) |
| Hardware R&D group | L2 tooling and execution, L5 evaluation and observability (heaviest); L6 highest cost | EDA tools are irreplaceable; the agent's role is an orchestration engine rather than a replacement engine; tape-out is irreversible |
| Knowledge collaboration group | L1 context engineering, L4 memory and state | The task is the retrieval and accumulation of knowledge; permissions must be pushed down to the retrieval layer |
| Data science group | L5 evaluation and observability, L6 governance and safety | Silent errors (pipelines that don't crash but only lie) and hard boundaries of data classification |
| Creative industry group | L4 memory and state (content side), L6 governance and safety (compliance) | Cross-session consistency is the quality bottleneck; labeling compliance has been pushed down to the metadata level |
| Risk and compliance group | L6 governance and safety | The output of L6 is itself the final deliverable submitted to regulators and courts |
**Conclusion (judgment)**: eight industries share the same six-layer skeleton, but their weight distributions are entirely different — this is not a coincidence but direct evidence that "Harness is an independent layer of engineering capability": precisely because it is an independent layer, it can be re-weighted by different industries according to their own risk structures and criteria shapes. If Harness were merely a function of the model or an appendage of a framework, this cross-industry structural difference would be inexplicable.
3.3. Argument Three: The Failure Mode Argument
**Argument form**: if the responsibilities of Harness are split apart to be borne separately by the model, the framework, and the business code, each piece will fail in a predictable way; these failure modes are precisely the objects that the six-layer model is designed to guard against.
The practice of the second generation (roughly 2023–2025) provides a complete record of counterexamples (see 01-Overview / Chapter 4 of 02-History):
| Failure mode | Manifestation | Layer |
|---|---|---|
| Context rot | Under long tasks, critical instructions get pushed out of the window and performance degrades gradually | L1 |
| Tool overload | The more tools there are, the fuzzier the decision points become; tool count and performance are not positively correlated | L2 |
| Orchestration runaway | Unconstrained loops lead to infinite loops, goal drift, and runaway cost (lesson of the AutoGPT generation) | L3 |
| State loss | Context breaks during cross-session/window handoffs, so long tasks inevitably get interrupted | L4 |
| Self-assessment bias | When asked to evaluate its own work, the agent will "confidently praise" mediocre output | L5 |
| Permission exposure | Frequent permission prompts interrupt the flow, being neither safe nor smooth; or permissions are granted too broadly at once | L6 |
**Conclusion (judgment)**: the six types of failure modes span six different stages, and any single-point solution (longer context, a better framework, a stronger model) can cover only one or two of them. They require a layer of **unified engineering infrastructure with a clear stance** to guard against them as a whole — and this layer of infrastructure is Harness. Unlike a "neutral" framework, Harness will explicitly tell you how context should be organized, how tools should be pruned, and what counts as "done".
3.4. Common Conclusion of the Three Arguments
The three arguments are mutually independent, yet their conclusions agree:
- The evaluation variable argument shows that Harness **must be measured as a variable**;
- The industry differentiation argument shows that Harness **can be independently weighted as a layer**;
- The failure mode argument shows that Harness **must be uniformly built as a layer**.
Taken together, the three support the central thesis of this whitepaper: **given a fixed model capability, the variance in system performance is determined mainly by Harness**.
4. Layer-by-Layer Definition of the Six-Layer Capability Model
图 4-1|AI Harness 六层能力模型与层间依赖关系
数据来源:基于本文分析绘制的示意图。
4.1. Model Overview
This whitepaper in its entirety uniformly uses the following six-layer capability model; it serves as the common frame of reference for all subsequent chapters:
| Layer | Name | English | One-sentence responsibility | Typical implementations |
|---|---|---|---|---|
| L1 | Context Engineering Layer | Context Engineering | Determines what the model "sees" | RAG, Context Compaction, Prompt Assembly, KV Cache reuse |
| L2 | Tooling & Execution Layer | Tooling & Execution | Determines what the model "can do" | MCP, Function Calling, sandbox executor, Computer Use |
| L3 | Orchestration & Control Layer | Orchestration & Control | Determines "in what order to do things" | Agent Loop, Plan-and-Execute, DAG / Workflow, Sub-agent |
| L4 | Memory & State Layer | Memory & State | Determines "what to remember" | Session Store, Episodic / Semantic Memory, Checkpoint |
| L5 | Evaluation & Observability Layer | Evaluation & Observability | Determines "how well it was done" | Trace, Eval Set, Golden Dataset, Online Metrics |
| L6 | Governance & Safety Layer | Governance & Safety | Determines "what cannot be done" | RBAC, guardrail model, audit logs, Budget Guardrail |
The following sections expand each layer one by one following a unified structure: responsibility, key components, representative implementations, and typical failure modes.
4.2. L1 Context Engineering Layer
**Responsibility**: before each step of reasoning, decide which tokens the model should see. Anthropic's official definition: a set of strategies for curating and maintaining the optimal set of tokens (information) during LLM inference (A-level).
**Two key official concepts**:
- **context rot**: as the context grows longer, performance degrades gradually (a performance gradient) rather than collapsing abruptly at some length — therefore context governance must be carried out continuously through engineering means and cannot rely on "pinning a threshold".
- **attention budget**: due to the relational nature of self-attention, every additional token in the context dilutes the model's attention to other tokens. Context is a **scarce resource**, not a free container.
**Key components and representative implementations**: retrieval (RAG, Contextual Retrieval, GraphRAG), compression (Context Compaction), caching (KV Cache reuse), assembly (Prompt Assembly), on-demand loading (the three-level progressive disclosure of Agent Skills).
**Typical failure modes**: context bloat pushes critical instructions out; retrieval returns deleted old interfaces; stuffing the entire knowledge base into the prompt yields negative returns (multi-document Q&A exhibits a U-shaped positional effect, and performance can even fall below closed-book when the relevant information is buried in the middle).
4.3. L2 Tooling and Execution Layer
**Responsibility**: decide which actions the model can exert on the environment, and where those actions are executed.
**Key components and representative implementations**:
| Component category | Role | Representatives |
|---|---|---|
| Tool registration and description | Declare external capabilities as structured interfaces callable by the model | Function Calling, JSON Schema tool descriptions |
| Connection protocol | Decouple the tool ecosystem from the host application | MCP (Model Context Protocol) |
| Execution environment | Bound the scope of actions and the boundaries of side effects | Sandbox (Seatbelt / bubblewrap / Landlock + seccomp), Computer Use |
**A counterintuitive piece of evidence**: tool count and performance are not positively correlated. After Vercel cut its tools from 15 to 2, accuracy rose from 80% to 100%, token consumption dropped 37%, and speed increased 3.5× (C-level, `[to be verified]`). Anthropic officially also recommends that tools should be "self-contained, robust to errors, and extremely clear in purpose" (A-level).
**Typical failure modes**: sandbox escape; tools returning enormous output that pollutes the context; concurrent write conflicts; destructive actions without a human gate.
4.4. L3 Orchestration and Control Layer
**Responsibility**: decide in what order to do things, who does them, and how to recover after an interruption.
**Key orchestration forms**:
| Form | Applicable to | Representatives |
|---|---|---|
| Agent Loop | General tasks where the model autonomously decides the next step | ReAct loops, Claude Code main loop |
| Plan-and-Execute | Long-horizon tasks that require global planning | Claude Code Plan Mode |
| DAG / Workflow | Business processes with high determinism requirements | DAG / Workflow engines |
| Sub-agent dispatch | Complex tasks that can be explored in parallel | Sub-agent, Orchestrator-Worker |
Anthropic's official sub-agent parameters: a sub-agent can explore deeply using tens of thousands of tokens but only returns a condensed summary of 1,000–2,000 tokens (A-level) — a typical architectural trade-off of "trading context for parallelism".
**Typical failure modes**: loops that fail to converge; sub-agent contexts cross-contaminating each other; state lost after interruption, and side effects re-executed after recovery.
4.5. L4 Memory and State Layer
**Responsibility**: how state is handed over across sessions and across context windows. Anthropic's analogy: like a software project where engineers work in shifts, each new engineer arrives with no memory of what happened in the previous shift (A-level). The official solution is a progress file plus version-control history, with the agent required to do three things at the start of every session: confirm the working directory, read the history and progress, and read the task list to select the highest-priority item; at the end, it must leave the environment in a **clean, mergeable state**.
**The difference between the two context handover mechanisms** (A-level):
| Mechanism | Approach | Advantage | Cost |
|---|---|---|---|
| Compaction | Summarize in place | Preserves continuity | "Context anxiety" remains |
| Context Reset | Clear and re-inject | Provides a clean slate | The handover artifact must be complete enough |
**Typical failure modes**: checkpoints do not include tool side effects; replay after recovery causes duplicate writes; erroneous information enters long-term memory and keeps propagating (context poisoning).
4.6. L5 Evaluation and Observability Layer
**Responsibility**: decide how well it was done, how to judge, and how to regress.
**The most important design principle** (Anthropic's *Harness design for long-running apps*, A-level): **the evaluator and the evaluated must be separated**. When an agent is asked to evaluate its own work, it will "confidently praise" it — even when the quality is clearly mediocre. The official conclusion is that tuning an independent Evaluator to be skeptical is far easier than having the Generator critique itself.
**Key components and representative implementations**: trajectory tracing (Trace), evaluation sets (Eval Set), golden datasets (Golden Dataset), regression sets and regression gating, online metrics (Online Metrics), and the principle of programmatic scoring (jointly established by SWE-bench and Terminal-Bench: "if the test passes, it passes", with no partial credit for "looks good but fails the test").
**Typical failure modes**: looking only at the final result without examining the process; regression sets repeatedly "optimized" into overfitting; evaluation-criteria drift (cross-leaderboard comparisons are largely invalid); evaluation cost so high that regression comes to a halt.
4.7. L6 Governance and Safety Layer
**Responsibility**: decide what cannot be done, how violations are discovered, and that spending is capped.
**Key components and representative implementations**: permission model (RBAC), guardrail model (Guardrails), audit logs, budget guardrail (Budget Guardrail), credential protection, and three-level configuration scope (project-level / user-level / organization-level).
**A piece of evidence that must be clarified**: the common misconception is that "governance slows down autonomy". Three groups of evidence point to the opposite conclusion (judgment: constraint is capability):
| Evidence | Data | Source level |
|---|---|---|
| Anthropic sandbox internal usage | Permission prompts reduced 84% while safety improved | A |
| OpenAI architecture constraints | "Constraints make speed possible, and the architecture does not drift" | A |
| Codex Auto-review | Human approval stops about 1/200 of the manual mode, with an approval rate of about 99% | B, `[to be verified]` |
**Typical failure modes**: permissions granted too broadly at once; audit logs that omit input context and therefore cannot be reviewed; conflating observability (L5, serving optimization) with audit (L6, serving evidence) — the two differ in retention period, tamper-resistance requirements, and access principals.
4.8. Dependency and Call Relationships Among the Six Layers
图 4-2|六层之间的依赖与调用关系
The six layers are not stacked side by side in parallel; rather, they have clear dependency directions:
┌─────────────────────────────────────────┐
│ L6 治理与安全层(贯穿全层,横向切面) │
└─────────────────────────────────────────┘
▲ 约束与审计
L1 上下文 ──► L2 工具与执行 ──► L3 编排与控制
▲ │ │
│ ▼ ▼
└──────── L4 记忆与状态 ◄──────────┘
│
▼
L5 评估与观测
│
└──► 反馈回 L1(改变下次看到什么) Reading notes:
- **L1 → L2 → L3** is the main execution chain: first decide what to see, then decide what can be done, and finally decide in what order to do things.
- **L4** provides cross-session state support for L1 / L3 and is the horizontal support layer of the time dimension.
- **L5** observes the entire chain and produces feedback, which ultimately returns to L1.
- **L6** is a horizontal cross-cutting concern that imposes constraints on all of L1–L5 and records audit.
5. Boundaries with Adjacent Concepts
5.1. Summary Table of Boundaries
This whitepaper in its entirety uniformly uses the following boundaries:
| Concept | Relationship with AI Harness |
|---|---|
| Agent | An **execution unit** that runs on top of Harness; Harness is the "chassis" of the Agent |
| Agent Framework (LangGraph, etc.) | Mainly covers L2 / L3 and is a **subset** of Harness |
| Agent Platform (Dify, etc.) | A **productized packaging** of Harness, layering on UI, tenancy, and billing |
| AI IDE (Cursor, etc.) | Harness's vertical integration form in the **coding scenario** |
| Model | The **carried object** of Harness, not part of Harness itself |
| MLOps / LLMOps | Focus on the model lifecycle; Harness focuses on the **agent task lifecycle** |
5.2. Concept-by-Concept Clarification
**Boundary with Agent**. The Agent is the execution unit and Harness is the chassis, with a "car and road" relationship between the two. Criterion: if replacing it does not change "how the model's output distribution is constrained and verified", it belongs to the Agent; if replacing it changes "how the model is orchestrated, observed, constrained, and regression-verified", it belongs to Harness. The official Chinese definition of "agent" can serve as the Chinese-context benchmark (A-level): "An agent is a new type of intelligent system with autonomous perception, memory, decision-making, interaction, and execution capabilities, and has become a key carrier of AI products and services."
**Boundary with Agent Framework**. A Framework (such as LangChain / LangGraph) mainly covers L2 and L3 and is a subset of Harness. The key difference is that a Framework is **neutral** while Harness **takes a stance** — Harness explicitly tells you how context should be organized, how tools should be pruned, and what counts as "done", whereas a Framework only provides building blocks without offering opinions. This is precisely the blind spot of the second-generation "framework-as-solution" mindset: a Framework does not solve production problems.
**Boundary with Agent Platform**. A Platform is the productized packaging of Harness, layering on top of it visual orchestration UI, multi-tenancy and permission systems, billing and quotas, and release/operation capabilities aimed at non-technical users. Criterion: the runtime that remains after stripping away the UI, tenancy, and billing is Harness.
**Boundary with AI IDE**. An AI IDE is Harness's vertical integration form in the coding scenario, layering on coding-specific capabilities such as editors, terminals, diff views, and LSP integration. Among them, terminal-type products (Claude Code, Codex CLI) are closer to "Harness in terminal form", while editor-type products (Cursor) are closer to "Harness in IDE form".
**Boundary with Model**. The Model is the carried object and does not belong to Harness. In 2025–2026 this boundary saw noteworthy blurring: leading vendors have already trained the model together with the Harness during post-training, producing the side effect of "the model overfitting to a specific Harness structure" — changing the tool logic actually makes the model perform worse (A-level). The practical implication is: **the best Harness for your task is not necessarily the one the model was post-trained with**.
**Boundary with MLOps / LLMOps**.
| Dimension | MLOps / LLMOps | Harness Engineering |
|---|---|---|
| Focus | Model lifecycle: training, fine-tuning, deployment, drift monitoring | Agent task lifecycle: the closed loop of a single task from intent to verification |
| Time scale | Days to months | Seconds to hours |
| Core artifacts | Model versions, feature stores, deployment pipelines | Context strategies, tool sets, evaluation sets, guardrail rules |
| Method source | Machine learning engineering | Reuse of software engineering practices (shift-left feedback, mutation testing, structural testing) |
5.3. A Memorable Analogy: The Computer Four-Layer Stack
A set of analogies circulates in the industry (the analogy itself is quotable as relayed by multiple parties; its original source and accompanying cases are marked `[to be verified]`):
| Computer concept | Counterpart in AI systems |
|---|---|
| CPU | Model |
| RAM | Context Window |
| Operating system | **AI Harness** |
| Application | Agent |
Just as an operating system does not produce compute but determines how compute is used, Harness does not produce intelligence but determines how intelligence is delivered safely and predictably. Note: this analogy is used only to aid understanding and not as a basis for argument; "AI operating system" is not used as a formal term (see Chapter 6).
6. Common Misuses and Clarifications
| # | Common claim | Clarification in this whitepaper |
|---|---|---|
| 1 | "Harness is just a good set of prompt templates" | Prompts are only part of L1. No single layer of the six-layer model equals Harness; a one-off prompt cannot be continuously improved, whereas Harness is a middle layer that can be continuously improved |
| 2 | "Harness is just Agent Framework under a different name" | A Framework is neutral, while Harness takes a stance; a Framework mainly covers L2 / L3 and usually does not include the L5 evaluation loop or the L6 governance foundation, making it a subset of Harness |
| 3 | "Once stronger models arrive, Harness will no longer be needed" | Stronger models will trim away part of the Harness design (the officials themselves state they are dynamically trimming), but the post-training coupling phenomenon actually strengthens the importance of Harness design. Harness will become lighter and restructured, but it will not disappear |
| 4 | "Governance (permissions, sandbox, audit) slows down the agent" | The evidence points in the opposite direction: after sandboxing, permission prompts decreased 84% while becoming safer. "Constraint is capability" — governance and autonomy are positive-sum rather than a trade-off |
| 5 | "Just let the agent evaluate its own output" | Self-assessment bias is a systematic phenomenon. The evaluator and the evaluated must be separated, especially for subjective tasks |
| 6 | "The goal of Harness engineering is to climb leaderboard scores" | Score climbing is not a Harness engineering goal. Public leaderboards can only calibrate the capability ceiling; they cannot predict internal returns |
| 7 | "Harness is a single product that can be procured" | Harness is a layer of capability whose product forms are diverse (SDK, CLI, IDE, platform, enterprise runtime); procuring a product does not equal building that layer's capability |
| 8 | "A large enough context window eliminates the need for context engineering" | The U-shaped positional effect and multiple long-context evaluations show that piling on context can yield negative returns; a large window changes the strategy space, not the need for strategy |
| 9 | "Observability and audit are the same thing" | L5 observability serves optimization, while L6 audit serves evidence; their retention periods, tamper-resistance requirements, and access principals all differ |
| 10 | "AI Harness / Agent Harness / Agent Runtime can be used interchangeably" | This whitepaper uniformly uses "AI Harness"; "Agent Harness" refers only to implementation forms in specific scenarios such as coding; "Agent Runtime" refers to the runtime product form of Harness |
7. Summary
- **Definition**: AI Harness is an engineering carrier layer located between the foundation model and real business systems, converting the model's uncertainty into engineering predictability; it does not increase intelligence, but it makes intelligence orchestratable, observable, constrainable, and regression-verifiable.
- **Etymology**: the verifiability of the Test Harness plus the controllability of the horse harness together make up the two faces of this word.
- **The three-fold argument for standing as its own layer**: the evaluation variable argument (it is an explicit variable in evaluation), the industry differentiation argument (eight industries give systematically different weights to the same six-layer skeleton), and the failure mode argument (six types of cross-stage failures require unified prevention).
- **The six-layer capability model**: L1 what to see, L2 what can be done, L3 in what order, L4 what to remember, L5 how well it was done, L6 what cannot be done — the six layers have dependency directions, L6 runs across horizontally, and L5 feeds feedback back to L1.
- **Boundaries**: the Agent is the execution unit, the Framework is a subset, the Platform is a packaging, the AI IDE is a vertical form, the Model is the carried object, and MLOps focuses on a different lifecycle.
- **Central thesis**: given a fixed model capability, the variance in system performance is determined mainly by Harness.
8. Statement of Information Gaps
- **All comparative numbers for the same model with different scores** (77.3% vs. 75.1%, 52.8% vs. 66.5%, Vercel 80% vs. 100%, Claude 3.5 Sonnet + agentic harness 49.0%): from B/C-level sources, marked `
[to be verified]`. - **The original text of the Wikipedia "Test harness" entry**: not directly captured; the wording in section 2.1 is based on the prevailing definition and cross-corroborated through secondary sources, marked `
[to be verified]`. - **The original source of the term "Agent Harness"**: no first-hand originating literature was found; the original text and publication date of LangChain's *The Anatomy of an Agent Harness* could not be located, **no authoritative information is currently available**.
- **The original source of the computer four-layer stack analogy**: the analogy is quotable, but its original source and accompanying cases are marked `
[to be verified]`. - **Codex Auto-review's 1/200 and 99%**: B-level source, marked `
[to be verified]`. - **The bottleneck layer distribution in the industry differentiation argument**: an analytical conclusion (judgment) from this project's eight industry groups, not a rating under any public standard; this should be noted when cited.
9. References
- Effective harnesses for long-running agents — Anthropic, 2025. https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents
- Harness design for long-running application development — Anthropic, 2026. https://www.anthropic.com/engineering/harness-design-long-running-apps
- Effective context engineering for AI agents — Anthropic, 2025. https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents
- Harness engineering: leveraging Codex in an agent-first world — OpenAI, 2026-02-11. https://openai.com/index/harness-engineering/
- Harness engineering for coding agent users — Birgitta Böckeler, martinfowler.com, 2026. https://martinfowler.com/articles/harness-engineering.html
- Humans and Agents in Software Engineering Loops — martinfowler.com, 2026. https://martinfowler.com/articles/exploring-gen-ai/humans-and-agents.html
- My AI Adoption Journey — Mitchell Hashimoto, 2026-02-05. https://mitchellh.com/writing/my-ai-adoption-journey
- Introducing the Model Context Protocol — Anthropic, 2024-11-25. https://www.anthropic.com/news/model-context-protocol
- SWE-bench: Can Language Models Resolve Real-World GitHub Issues? — Jimenez, Yang, et al. (Princeton), 2023-10 (ICLR 2024 Oral). https://www.swebench.com/
- Terminal-Bench official site — Stanford / Laude Institute, 2025. https://www.tbench.ai/
- Interpretation of the national standard series "Artificial Intelligence Agent Interconnection" — China Industrial Economic Information Network, 2026. https://cinic.org.cn/xw/zcdt/1643418.html
- Sandboxing: a safer and more autonomous approach — Anthropic, 2025. https://www.anthropic.com/engineering/claude-code-sandboxing