defineEval 是编写评估用例的主要入口。每个评估用例文件调用一次,传入描述和 test(t),并默认导出结果。
不要提供
id 或 name。NiceEval 从文件路径推导评估用例 ID。defineEval 选项
description
niceeval list 和 view 里;纯说明,不影响调度或打分。
tags
--tag 过滤和 view 分类;与 id 前缀过滤是两套独立的筛选维度。
sandbox
plugins
judge
reporters
timeoutMs
metadata
diff
ignore 在默认清单上追加排除;include 优先级最高,把匹配路径显式加回。
合成规则固定为「默认 ∪ ignore,再被 include 打洞」,清单在分类账锚点时冻结。
test
Test context: t
t(TestContext)是评估用例作者拿到的高层上下文。每一次作者入口调用都直接登记一条 Assertion。t.check(value, match) 严格接收两个参数。t.succeeded()、session.succeeded()、turn.succeeded()、calledTool(...)、notCalledTool(...) 与 Judge recipe 也直接登记 Assertion。handle 只配置同一条 entry 的 key、label、.atLeast(n) 与 .score(n)。.orStop() 也只作用于此 entry,绝不登记第二条 Assertion。
Pass Eval 用 Boolean condition 折叠 Attempt Verdict。measurement 必须 .atLeast(n);await handle.orStop() 在 mismatch 或 below 时停止当前 continuation。defineScoreEval 的 ScoreTestContext 额外提供 t.score(n) 直接登记 contribution,n 必须 finite 且不小于零;已有 Assertion 用 .score(n) 贡献分数,n 必须 finite 且大于零。calledTool 与 notCalledTool 的完整契约见 Scoped assertions。全部成员:
evaluationKind
send
sendFile
requireInputRequest
respond
respondAll
reply
sessionId
events
newSession
signal
model
reasoningEffort
flags
progress
diagnostic
log
skip
group
check
sandbox
o11y
usage
succeeded
usedNoTools
maxToolCalls
noFailedActions
event
notEvent
maxTokens
maxCost
judge
Judge measurement
先在defineEval 或 defineScoreEval 声明 judge: true,再直接登记 Judge Assertion:
t.judge.autoevals 的根级 recipe 额外接收 { input, output } 字符串材料。turn.judge 已绑定 immutable Turn 材料。模型配置按 Eval、Experiment、项目配置解析一次;没有单次模型覆盖或 { on } 选项。Pass Eval 必须 .atLeast(n);Score Eval 直接 .score(n)。
Turn 返回类型
t.send(...) 返回一个 TurnHandle:从事件流派生的便利字段,加上一整套本轮作用域断言。
calledTool 与 notCalledTool 也属于 Turn 的作用域断言;它们的签名和 Match 规则只在 Scoped assertions 定义。
events
toolCalls
status
message
data
usage
succeeded
toolOrder
usedNoTools
maxToolCalls
noFailedActions
event
notEvent
eventOrder
maxTokens
maxCost
judge
测试集导出
file/0000、file/0001 等。
已有稳定业务 key 时也可以默认导出 Record<string, EvalDef>。例如 key 15193 在 swelancer.eval.ts 中生成 swelancer/15193。key 必须是非空单一路径片段,不能是 . / ..,不能含 /、\\ 或控制字符。发现顺序按 key 字典序固定。