Harness 工程的关键战场:工具边界拦截 · 干货攻略
- 链接: https://x.com/hwchase17/status/2098866608785473858
- 分类: x-tips
- 来源: X @hwchase17
- 作者: Jay
- 更新: 2026-09-14
- 仓库: airbnb/agent-harness-optimizer
这是什么
Beyond Prompts: Measuring and Optimizing LLM Tool-Agent Harnesses 是 Airbnb 团队(Cen Mia Zhao、Haibo Ruan、Wenjie Chen 等)发表在 EMNLP 2026 的论文,核心命题:
给定一个固定模型,Agent 的质量提升来源不是换模型,而是优化它周围的 harness(运行时控制层)。
论文把这个问题形式化为资源受限的 harness 选择问题(resource-bounded harness selection),并引入了 PRISM 优化器——一个在 prompt 表面和工具边界中间件(tool-boundary middleware)两个维度上做遗传-帕累托搜索的框架。
关键约束:edits are guarded intercepts at the tool boundary, not arbitrary rewriting of agent execution logic.(编辑是工具边界的守卫拦截,而非对 Agent 执行逻辑的任意重写)
为什么值得关注
谁分享的、解决什么问题
@hwchase17(Harrison Chase,LangChain 联创)在 X 分享了这篇论文,附言:
"I like this framing a lot: agent improvement is harness improvement, not model improvement. The interesting interventions are often at the tool boundary: what context you pass, when tools are provided, how you recover from failure, what gets measured afterward."
这解决了两个现实痛点:
- 团队总是在错误的地方用力:遇到 Agent 效果差,直觉反应是「换个更强的模型」——但这篇论文证明,同一个模型,换一个好的 harness 就能带来 10–15 个百分点的 held-out lift,成本却接近于零。
- harness 优化的评测长期缺标准:之前的工作只报验证集 lift,不报跨批次稳定性、不报 cost、不报可靠性。论文提出了
RelLift95(B)——一个在固定预算 B 下,harness 选择器在未见数据上能「可靠拿到多少 lift」的保守估计量。
核验过程
官方来源
| 来源 | 读取内容 |
|---|---|
| arXiv:2609.05736 | 完整 abstract;introduction §1;实验 protocol §3–4;middleware edit patterns §4.3;component ablation §6.1 |
| arXiv HTML 全文 | 方法细节:三个 benchmark 基线分数、PRISM 伪代码、Pareto frontier 选择逻辑、ablation 数据表 |
| airbnb/agent-harness-optimizer | README:优化器对比表、CLI 使用示例、三种 middleware edit patterns、输出结构 report.json 字段说明 |
交叉验证结论
| 说法 | 官方来源 | 状态 |
|---|---|---|
| PRISM mean held-out lift: BFCL +14.2pp、τ²-Retail +14.9pp、τ²-Telecom +10.1pp | arXiv abstract + HTML Table 1 | ✅ 一致 |
| Middleware 三种 edit patterns:silent correction、error blocking、prerequisite blocking | arXiv HTML §4.3 + GitHub README | ✅ 一致 |
| 核心贡献 = failure-surface routing + edit-pattern constraint | arXiv abstract + component ablation | ✅ 一致 |
| PRISM selects by gate pass rate AND reliability, not score alone | arXiv HTML §4.3 + GitHub PRISM loop 伪代码 | ✅ 一致 |
| RelLift95(B) 是 harness 选择器在预算 B 下的保守 held-out lift 估计量 | arXiv §3 efficiency 节 | ✅ 原文明确 |
| PRISM builds on GEPA-style skeleton + failure clustering + Pareto retention | arXiv introduction §2 | ✅ 原文明确 |
| 外部模型 = claude-opus-4.7;内部执行模型 = gpt-5.4-mini | arXiv HTML §4.2 + GitHub README | ✅ 一致 |
铁律
原帖 @hwchase17 的核心观点——「harness 优化是最有价值的 Agent 干预层」——论文 abstract 明确支持,原文原话:
"LLM tool agents can be improved without retraining by modifying the runtime harness around a fixed model."
上手指南
理解核心概念:什么是 Tool-Boundary Middleware
Harness = 围绕固定模型的运行时控制层,包含:prompts、tool interfaces、context construction、state management、middleware、recovery logic、evaluation hooks。
Middleware 是在 tool boundary(工具边界)拦截的工具调用拦截层——它不动 Agent 的执行逻辑,只在工具调用前/后做检查和修正。
论文明确了三种 middleware edit patterns:
工具调用流程(含 middleware 拦截)
User Input → [Middleware Gate] → Tool Execution → [Middleware Gate] → Agent Next Turn
↑ ↑
prerequisite blocking silent correction / error blocking
| Pattern | 触发时机 | 动作 | 适用场景 |
|---|---|---|---|
| Silent Correction | 工具执行前 | 自动修正格式错误的参数 | API schema 宽松但实际调用严 |
| Error Blocking | 工具执行前 | 返回显式错误信息让模型重试 | 缺少必要参数或前置状态 |
| Prerequisite Blocking | 工具执行前 | 检查对话/状态历史再决定是否放行 | 需要先查某个状态再执行写操作 |
这三种 patterns 解决的是「failure locally observable and checkable at the tool boundary」的问题——模型自己不知道自己哪里错了,但 middleware 可以检测到并修正。
用 PRISM 跑一个优化实验
论文 GitHub 仓库(airbnb/agent-harness-optimizer)提供了完整 CLI:
# 安装
git clone https://github.com/airbnb/agent-harness-optimizer.git
cd agent-harness-optimizer
uv pip install -e ".[tau]" # 支持 tau-bench
# PRISM 优化 BFCL 多轮工具调用
python -m agent_harness_optimizer.cli \
--benchmark bfcl \
--optimizer prism \
--inner-model openai/gpt-5.4-mini \
--outer-model bedrock/global.anthropic.claude-sonnet-4-6 \
--output-dir runs/bfcl-prism-001 \
--train-cases 100 --holdout-cases 100 \
--generations 4 --mutations-per-gen 3 \
--wall-time-s 300 --max-steps 100
# 查看输出报告
cat runs/bfcl-prism-001/report.json
输出结构:
{
"baseline_holdout.pass_rate": 0.51,
"final_holdout.pass_rate": 0.652,
"delta_holdout": 0.142,
"final_scorecard.pass_rate": 0.652,
"final_scorecard.delta_scorecard_pp": 14.2,
"final_scorecard.improving_run": true,
"final_train.reliability": 0.95
}
对比四种优化器策略
| 优化器 | 策略 | 最佳场景 | 是否支持 Middleware |
|---|---|---|---|
| PRISM | 遗传算法 + 帕累托前沿 + 失败路由 | 多表面优化,最高 lift | ✅ 完整支持 |
| BetterHarness | 线性 propose → accept 循环 | 快速迭代,可解释 diff | ✅ 支持(无约束) |
| MIPROv2 | 贝叶斯指令搜索(DSPy) | Prompt-only,结构化调优 | ❌ Prompt-only |
| GEPA | 反思式轨迹变异 + 每实例帕累托选择 | Per-instance 最优 | ⚠️ 可切换 |
PRISM 的核心算法逻辑(伪代码)
PRISM loop:
for each generation:
1. analyze failures → LLM 将失败聚类归因
2. route each cluster to fix surface (prompt / middleware / both)
3. run N parallel mutations
4. deduplicate no-op mutations
5. full eval all children on train + holdout
6. crossover if children address complementary failure sets
7. update Pareto frontier (pass_rate × reliability)
select: highest reliability among top-tier Pareto candidates
坑与适用边界
论文承认的局限
- 跨调用协调、异步状态、控制流变更不在 middleware vocabulary 内:如果修复需要跨工具协调(先 A 再 B 且 A 的结果影响 B 的参数),middleware patterns 覆盖不到。
- τ²-bench Telecom 基线极低(pass¹ 约 25%):这说明强基线 harness 在困难任务上本身能力有限,PRISM 的 +10.1pp 是从极低基线起的提升,比例上看很显著。
- RelLift95(B) 是经验下尾估计,不是覆盖率保证:它报告的是「在固定预算下,用同一协议重复选择,最差 5% 情况下能拿到多少 lift」,这是 deployer 视角的诊断,不是 optimizer 的目标函数。
- 外部 proposer 模型用 claude-opus-4.7,成本较高:论文默认配置对资源受限团队不一定经济。
何时用 Middleware,何时用 Prompt
论文 component ablation 给出明确答案:
- Prompt-only vs Prompt+Middleware 的 gap:在 τ²-Retail 上,PRISM-MW 获得 +14.9pp,而 PRISM-PO 只有 +5.5pp(ablation 数据显示)。gap 主要来自 failure-surface routing——能把错误路由到 middleware 修复的,prompt 修不了。
经验法则:如果失败在工具边界可观测(参数错误、状态缺失、前置条件不满足)→ middleware;如果失败在规划层(选错工具、顺序不对)→ prompt。
Generic vs Domain-Specific Harness 的分界线
论文和 @hwchase17 的 X 帖都指向同一结论:
- 通用 Agent:选 generic harness + 普适 middleware patterns(如 prerequisite blocking)
- 业务 Agent:业务逻辑越深,domain harness 收益越大——因为failure distribution 更可预测,middleware 可以精确拦截
一句话结论
Agent 优化的最大收益来源是 Harness 工程而非换模型;PRISM 证明工具边界的 middleware 拦截(silent correction / error blocking / prerequisite blocking)可以让固定模型在 BFCL、τ²-Retail、τ²-Telecom 三个 benchmark 上分别提升 14.2、14.9、10.1 个百分点,关键是让失败被正确路由到它能被局部检查和修复的那一层。
核验来源:arXiv:2609.05736(abstract、introduction §1–2、实验 §3–4、ablation §6.1、GitHub HTML 全文);airbnb/agent-harness-optimizer GitHub README(CLI 用法、三种 edit patterns、report.json 字段);@hwchase17 X 帖子(2026-09-09,核心观点与论文 abstract 一致)。