Verifier 与 Reward
tests/test.sh(Windows 为 tests/test.bat)是验证器入口。
agent 跑完后,Harbor 把 tests/ 上传到 /tests/ 并执行。
必须写一个 reward
Section titled “必须写一个 reward”| 文件 | 格式 |
|---|---|
/logs/verifier/reward.txt |
单个数,通常 1 或 0 |
/logs/verifier/reward.json |
带标签的数值指标对象 |
两者都存在时,Harbor 优先读 reward.json。
#!/bin/bashset -euo pipefail
if pytest /tests/test_outputs.py; then echo 1 > /logs/verifier/reward.txtelse echo 0 > /logs/verifier/reward.txtfi官方 hello-world 的写法类似,只是多了把 pytest 结果转成 CTRF:
uvx --with pytest==8.4.1 --with pytest-json-ctrf==0.3.5 \ pytest --ctrf /logs/verifier/ctrf.json /tests/test_state.py -rA共享 vs 独立验证环境
Section titled “共享 vs 独立验证环境”| 模式 | 行为 |
|---|---|
shared(默认) |
验证器跑在 agent 的同一环境里,需要把测试依赖装进 agent 镜像 |
separate |
用 [verifier.environment] 指定的镜像,或在 tests/ 放 Dockerfile |
separate 模式下,Harbor 不会把测试上传进验证镜像,必须在镜像里自带 /tests/test.sh。
agent 的文件系统改动不会继承,所以要用 artifacts 声明需要收集的产物。
- reward hacking:测试能被绕开时,agent 会学会绕开。仓库里专门有
reward-hacking示例 - reliability:
set -euo pipefail+ 绝对路径,避免 cwd 与静默失败 - 多指标:用
reward.json,不要塞一个加权分数糊过去