LLM harness 是什么?
agent harness 和 eval harness 有什么区别?

英文问法What is an LLM harness? · What's the difference between an agent harness and an eval harness? · How do you make agent runs reproducible?

考过推断,非面经。recruiter 邮件把 "LLM Harness" 列为实习内容,但没有解释具体指什么 · 这个词在业界还没有统一定义,面试时先问清对方指哪一种

先弄清楚:每个概念是什么

Harness
模型外面的那层代码,让模型能干活、也能被测。业界常见的说法是 Agent = Model + Harness。
Agent harness
运行时,让模型完成任务。
Eval harness
测试设施,衡量任务完成得好不好。
Grader
判断一次运行算不算成功的代码或模型,也叫 verifier。
Trace
一次运行的完整记录:每一步的输入、输出、tool call 和返回,再加 token 数、latency、错误。有了它才能回答“为什么失败”。

30 秒回答

A harness is everything around the model that makes it usable and testable. An agent harness builds the context, calls the model, runs tools, handles errors, and logs each step. An eval harness replays a fixed set of tasks through that agent, grades each run, and aggregates the scores, so two versions can be compared. When you evaluate an agent, you measure the model and the harness together, so both must be versioned. I'd first ask which one the team means.

两种 harness

Agent harnessEval harness
输入用户请求task 集:prompt、环境初始状态、期望结果
部件context 组装、tool 执行、loop 和 stop、retry、副作用确认、日志task loader、runner、grader、aggregator
输出回答或动作分数、trace、失败分类

最小的 eval harness

def run_eval(tasks, agent, grader, k=3):
    rows = []
    for task in tasks:
        for trial in range(k):
            env = task.make_env()              # 每次从初始状态开始
            trace = agent.run(task.prompt, env)
            rows.append({
                "task": task.id,
                "trial": trial,
                "score": grader(task, env, trace),
                "steps": len(trace),
            })
    return rows

可复现:固定 model 版本和 sampling 参数。tool 返回用 mock 或 cache。每次运行把环境重置到初始状态。prompt、tool schema、grader 进版本控制。每题跑 k 次,报方差。

必答点

追问

为什么换一个 harness,同一个模型的分数会变?

context 怎么裁剪、tool 描述怎么写、出错后重试几次,都会改变结果。所以比较模型时固定 harness,比较 harness 时固定模型。

grader 用规则还是用 LLM?tool 有副作用怎么评?

有副作用的 tool 放进 sandbox 跑,用 state match 比较环境的最终状态和期望状态,不看模型自己说“完成了”。其他能用规则的也用规则,开放式的回答才用 LLM judge,并用人工标注校准(见标注与 LLM judge)。

你做过类似的东西吗?

Excel Copilot 的 RL environment 就是一种 eval harness。它的 task、episode、reward 对应这里的 task、一次运行、grader 的分数。只讲简历上公开的层面。

来源术语来自业界博客,定义还在变化:Arize:What is an agent harness? · Eval harness 词条 · agent loop 见 Agent、tool calling 和 MCP