@tangle-network/agent-bench 1.0.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +24 -2
  3. package/dist/adapters.d.ts +3 -3
  4. package/dist/adapters.js +3 -5
  5. package/dist/adapters.js.map +1 -1
  6. package/dist/benchmarks/_harness.d.ts +4 -4
  7. package/dist/benchmarks/_harness.js +5 -2
  8. package/dist/benchmarks/_harness.js.map +1 -1
  9. package/dist/benchmarks/aec-bench.d.ts +2 -2
  10. package/dist/benchmarks/aec-bench.js +49 -42
  11. package/dist/benchmarks/aec-bench.js.map +1 -1
  12. package/dist/benchmarks/agentbench.d.ts +2 -2
  13. package/dist/benchmarks/agentbench.js +41 -34
  14. package/dist/benchmarks/agentbench.js.map +1 -1
  15. package/dist/benchmarks/appworld.d.ts +4 -4
  16. package/dist/benchmarks/appworld.js +67 -53
  17. package/dist/benchmarks/appworld.js.map +1 -1
  18. package/dist/benchmarks/bfcl.d.ts +2 -2
  19. package/dist/benchmarks/bfcl.js +52 -44
  20. package/dist/benchmarks/bfcl.js.map +1 -1
  21. package/dist/benchmarks/cad-design.d.ts +2 -2
  22. package/dist/benchmarks/cad-design.js +53 -44
  23. package/dist/benchmarks/cad-design.js.map +1 -1
  24. package/dist/benchmarks/cadbench.d.ts +2 -2
  25. package/dist/benchmarks/cadbench.js +1 -1
  26. package/dist/benchmarks/cadgenbench.d.ts +2 -2
  27. package/dist/benchmarks/cadgenbench.js +1 -1
  28. package/dist/benchmarks/commit0.d.ts +2 -2
  29. package/dist/benchmarks/commit0.js +38 -31
  30. package/dist/benchmarks/commit0.js.map +1 -1
  31. package/dist/benchmarks/crag.d.ts +2 -2
  32. package/dist/benchmarks/crag.js +37 -32
  33. package/dist/benchmarks/crag.js.map +1 -1
  34. package/dist/benchmarks/dabstep.d.ts +2 -2
  35. package/dist/benchmarks/dabstep.js +41 -34
  36. package/dist/benchmarks/dabstep.js.map +1 -1
  37. package/dist/benchmarks/finresearchbench.d.ts +4 -4
  38. package/dist/benchmarks/finresearchbench.js +63 -50
  39. package/dist/benchmarks/finresearchbench.js.map +1 -1
  40. package/dist/benchmarks/finsearchcomp.d.ts +3 -3
  41. package/dist/benchmarks/finsearchcomp.js +55 -44
  42. package/dist/benchmarks/finsearchcomp.js.map +1 -1
  43. package/dist/benchmarks/frames.d.ts +2 -2
  44. package/dist/benchmarks/frames.js +66 -51
  45. package/dist/benchmarks/frames.js.map +1 -1
  46. package/dist/benchmarks/hotpotqa.d.ts +2 -2
  47. package/dist/benchmarks/hotpotqa.js +59 -47
  48. package/dist/benchmarks/hotpotqa.js.map +1 -1
  49. package/dist/benchmarks/humaneval.d.ts +3 -3
  50. package/dist/benchmarks/humaneval.js +39 -35
  51. package/dist/benchmarks/humaneval.js.map +1 -1
  52. package/dist/benchmarks/mcad-bench.d.ts +2 -2
  53. package/dist/benchmarks/mcad-bench.js +68 -56
  54. package/dist/benchmarks/mcad-bench.js.map +1 -1
  55. package/dist/benchmarks/mcad-cq-bench.d.ts +3 -3
  56. package/dist/benchmarks/mcad-cq-bench.js +70 -58
  57. package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
  58. package/dist/benchmarks/mcad-cq-golds.d.ts +1 -1
  59. package/dist/benchmarks/mcad-cq-golds.js +1 -1
  60. package/dist/benchmarks/mcad-cq-golds.js.map +1 -1
  61. package/dist/benchmarks/mcad-golds.d.ts +1 -1
  62. package/dist/benchmarks/mcad-golds.js.map +1 -1
  63. package/dist/benchmarks/mind2web.d.ts +3 -3
  64. package/dist/benchmarks/mind2web.js +62 -49
  65. package/dist/benchmarks/mind2web.js.map +1 -1
  66. package/dist/benchmarks/nomiracl.d.ts +2 -2
  67. package/dist/benchmarks/nomiracl.js +43 -36
  68. package/dist/benchmarks/nomiracl.js.map +1 -1
  69. package/dist/benchmarks/open-rag-bench.d.ts +2 -2
  70. package/dist/benchmarks/open-rag-bench.js +37 -32
  71. package/dist/benchmarks/open-rag-bench.js.map +1 -1
  72. package/dist/benchmarks/programbench.d.ts +2 -2
  73. package/dist/benchmarks/programbench.js +28 -23
  74. package/dist/benchmarks/programbench.js.map +1 -1
  75. package/dist/benchmarks/rag-shared.d.ts +2 -2
  76. package/dist/benchmarks/rag-shared.js +15 -13
  77. package/dist/benchmarks/rag-shared.js.map +1 -1
  78. package/dist/benchmarks/ragbench.d.ts +2 -2
  79. package/dist/benchmarks/ragbench.js +34 -29
  80. package/dist/benchmarks/ragbench.js.map +1 -1
  81. package/dist/benchmarks/simpleqa.d.ts +2 -2
  82. package/dist/benchmarks/simpleqa.js +63 -52
  83. package/dist/benchmarks/simpleqa.js.map +1 -1
  84. package/dist/benchmarks/swe-bench.d.ts +4 -4
  85. package/dist/benchmarks/swe-bench.js +47 -41
  86. package/dist/benchmarks/swe-bench.js.map +1 -1
  87. package/dist/benchmarks/t2-ragbench.d.ts +2 -2
  88. package/dist/benchmarks/t2-ragbench.js +37 -32
  89. package/dist/benchmarks/t2-ragbench.js.map +1 -1
  90. package/dist/benchmarks/tau-bench-shared.d.ts +2 -2
  91. package/dist/benchmarks/tau-bench-shared.js +43 -36
  92. package/dist/benchmarks/tau-bench-shared.js.map +1 -1
  93. package/dist/benchmarks/tau2-bench.d.ts +2 -2
  94. package/dist/benchmarks/tau2-bench.js.map +1 -1
  95. package/dist/benchmarks/tau3-banking.d.ts +2 -2
  96. package/dist/benchmarks/tau3-banking.js.map +1 -1
  97. package/dist/benchmarks/terminal-bench.d.ts +2 -2
  98. package/dist/benchmarks/terminal-bench.js +29 -23
  99. package/dist/benchmarks/terminal-bench.js.map +1 -1
  100. package/dist/benchmarks/toollm.d.ts +2 -2
  101. package/dist/benchmarks/toollm.js +40 -34
  102. package/dist/benchmarks/toollm.js.map +1 -1
  103. package/dist/benchmarks/trata-hedge.d.ts +2 -2
  104. package/dist/benchmarks/trata-hedge.js +49 -43
  105. package/dist/benchmarks/trata-hedge.js.map +1 -1
  106. package/dist/benchmarks/types.d.ts +33 -63
  107. package/dist/benchmarks/types.js +36 -1
  108. package/dist/benchmarks/types.js.map +1 -0
  109. package/dist/benchmarks/webarena-verified.d.ts +2 -2
  110. package/dist/benchmarks/webarena-verified.js +29 -24
  111. package/dist/benchmarks/webarena-verified.js.map +1 -1
  112. package/dist/{cadbench-DhAndllg.js → cadbench-htzAmMaI.js} +41 -36
  113. package/dist/cadbench-htzAmMaI.js.map +1 -0
  114. package/dist/{cadgenbench-Tvk16YKT.js → cadgenbench-BLvEtnxU.js} +28 -22
  115. package/dist/cadgenbench-BLvEtnxU.js.map +1 -0
  116. package/dist/cli.d.ts +1 -0
  117. package/dist/cli.js +667 -0
  118. package/dist/cli.js.map +1 -0
  119. package/dist/index.d.ts +11 -10
  120. package/dist/index.js +64 -59
  121. package/dist/index.js.map +1 -1
  122. package/package.json +9 -6
  123. package/scripts/enterpriseops-gym-run.sh +82 -0
  124. package/scripts/grade-recorded-evidence.mjs +50 -0
  125. package/scripts/harvey-lab-judge.py +50 -0
  126. package/scripts/harvey-lab-run.sh +53 -0
  127. package/scripts/harvey-lab-sandbox.sh +21 -0
  128. package/scripts/healthbench-professional-run.sh +30 -0
  129. package/scripts/healthbench_professional_run.py +112 -0
  130. package/scripts/mlcr-run.sh +17 -0
  131. package/scripts/mlcr_run.py +133 -0
  132. package/scripts/prbench-run.sh +39 -0
  133. package/scripts/prbench_run.py +53 -0
  134. package/scripts/verify-packed-consumer.mjs +32 -27
  135. package/src/adapters.ts +5 -7
  136. package/src/atom-mcp-e2e.mts +2 -2
  137. package/src/benchmarks/_harness.test.mts +18 -1
  138. package/src/benchmarks/_harness.ts +12 -7
  139. package/src/benchmarks/aec-bench.test.mts +14 -14
  140. package/src/benchmarks/aec-bench.ts +62 -56
  141. package/src/benchmarks/agent-eval-contract.test.mts +38 -0
  142. package/src/benchmarks/agentbench.ts +44 -37
  143. package/src/benchmarks/appworld.test.mts +7 -7
  144. package/src/benchmarks/appworld.ts +88 -75
  145. package/src/benchmarks/bfcl.ts +60 -53
  146. package/src/benchmarks/cad-design.ts +34 -32
  147. package/src/benchmarks/cadbench.ts +36 -36
  148. package/src/benchmarks/cadgenbench.ts +30 -28
  149. package/src/benchmarks/commit0.test.mts +9 -9
  150. package/src/benchmarks/commit0.ts +50 -43
  151. package/src/benchmarks/crag.ts +45 -40
  152. package/src/benchmarks/dabstep-official.test.mts +8 -8
  153. package/src/benchmarks/dabstep.test.mts +11 -11
  154. package/src/benchmarks/dabstep.ts +47 -40
  155. package/src/benchmarks/external-adapters.test.mts +43 -44
  156. package/src/benchmarks/finresearchbench.ts +58 -48
  157. package/src/benchmarks/finsearchcomp.ts +73 -68
  158. package/src/benchmarks/frames.ts +76 -69
  159. package/src/benchmarks/hotpotqa.ts +69 -64
  160. package/src/benchmarks/humaneval.ts +37 -35
  161. package/src/benchmarks/mcad-bench.test.mts +30 -30
  162. package/src/benchmarks/mcad-bench.ts +66 -60
  163. package/src/benchmarks/mcad-cq-bench.ts +69 -63
  164. package/src/benchmarks/mcad-cq-golds.ts +1 -1
  165. package/src/benchmarks/mcad-cq.test.mts +40 -40
  166. package/src/benchmarks/mcad-golds.ts +1 -1
  167. package/src/benchmarks/mind2web.ts +66 -58
  168. package/src/benchmarks/nomiracl.ts +53 -46
  169. package/src/benchmarks/open-rag-bench.ts +47 -42
  170. package/src/benchmarks/programbench.test.mts +10 -10
  171. package/src/benchmarks/programbench.ts +38 -33
  172. package/src/benchmarks/rag-benchmarks.test.mts +31 -31
  173. package/src/benchmarks/rag-shared.ts +13 -16
  174. package/src/benchmarks/ragbench.ts +44 -39
  175. package/src/benchmarks/simpleqa.ts +79 -74
  176. package/src/benchmarks/swe-bench.test.mts +3 -3
  177. package/src/benchmarks/swe-bench.ts +66 -61
  178. package/src/benchmarks/t2-ragbench.ts +47 -42
  179. package/src/benchmarks/tau-bench-shared.ts +51 -44
  180. package/src/benchmarks/tau-pin.test.mts +1 -1
  181. package/src/benchmarks/tau2-bench.ts +2 -2
  182. package/src/benchmarks/tau3-banking.ts +2 -2
  183. package/src/benchmarks/terminal-bench.test.mts +3 -3
  184. package/src/benchmarks/terminal-bench.ts +41 -36
  185. package/src/benchmarks/toollm.ts +54 -47
  186. package/src/benchmarks/trata-hedge.ts +61 -58
  187. package/src/benchmarks/types.ts +70 -59
  188. package/src/benchmarks/webarena-verified.ts +49 -42
  189. package/src/cli.ts +74 -0
  190. package/src/corpus-replay.mts +9 -9
  191. package/src/examples/benchmark-matrix.mts +19 -16
  192. package/src/examples/lean-proof-gate.mts +1 -1
  193. package/src/examples/math-demo.mts +2 -2
  194. package/src/examples/strategy-demo.mts +1 -1
  195. package/src/gate-cli.mts +6 -6
  196. package/src/gate.test.mts +14 -12
  197. package/src/gate.ts +23 -22
  198. package/src/generate-eval/certify.ts +4 -4
  199. package/src/index.ts +17 -11
  200. package/src/published.test.mts +534 -0
  201. package/src/published.ts +524 -0
  202. package/src/run-benchmarks-cli.mts +3 -3
  203. package/src/run-benchmarks.test.mts +58 -48
  204. package/src/run-benchmarks.ts +64 -57
  205. package/src/swe-bench-env.ts +6 -6
  206. package/src/swe-self-improve.mts +3 -3
  207. package/src/terminal-compare.ts +1 -1
  208. package/src/worker.ts +1 -1
  209. package/dist/benchmarks/enterpriseops-gym.d.ts +0 -6
  210. package/dist/benchmarks/enterpriseops-gym.js +0 -236
  211. package/dist/benchmarks/enterpriseops-gym.js.map +0 -1
  212. package/dist/cadbench-DhAndllg.js.map +0 -1
  213. package/dist/cadgenbench-Tvk16YKT.js.map +0 -1
  214. package/fixtures/enterpriseops-gym.json +0 -103
  215. package/scripts/enterpriseops_gym_judge.py +0 -281
  216. package/src/benchmarks/enterpriseops-gym.test.mts +0 -77
  217. package/src/benchmarks/enterpriseops-gym.ts +0 -343
  218. package/src/eops-skills/address-every-subtask.md +0 -5
  219. package/src/eops-skills/exact-tools-and-args.md +0 -5
  220. package/src/eops-skills/full-sequence-to-goal.md +0 -5
  221. package/src/eops-skills/ground-every-value.md +0 -5
  222. package/src/eops-skills/honor-the-policies.md +0 -5
@@ -17,8 +17,8 @@
17
17
  * Task 2: per-move coverage check (ground truth + agent answer + flagged claims)
18
18
  * Task 3: synthesis check (ground truth + agent answer)
19
19
  * Score 0–4: themes_covered == num_themes && synthesis → 4, all themes → 3,
20
- * ≥2 themes → 2, ≥1 theme → 1, else → 0. Normalized to 0..1 for BenchScore;
21
- * resolved = score 4 (sparse reward).
20
+ * ≥2 themes → 2, ≥1 theme → 1, else → 0. Normalized to 0..1 for BenchEvaluation;
21
+ * passed = score 4 (sparse reward).
22
22
  *
23
23
  * Requires TANGLE_API_KEY and TRATA_BENCH_ROOT=/tmp/trata-hedge-bench.
24
24
  * Clone: git clone --depth 1 https://github.com/Trata-Inc/trata-hedge-bench /tmp/trata-hedge-bench
@@ -27,7 +27,7 @@
27
27
  import { readdirSync, readFileSync, statSync } from 'node:fs'
28
28
  import { join } from 'node:path'
29
29
  import { runBenchRouterTurn } from '../router-turn'
30
- import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
30
+ import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
31
31
 
32
32
  const DEFAULT_BENCH_ROOT = '/tmp/trata-hedge-bench'
33
33
  const MAX_FILE_BYTES = 8_000
@@ -40,8 +40,8 @@ const WORKER_SUFFIX = [
40
40
  'Take a clear position on the topic. Every factual claim must name the file it comes from.',
41
41
  ].join('\n')
42
42
 
43
- // Judge model: Gemini 2.5 Pro via router (matches gemini-3.1-pro-preview tier used by grade.py).
44
- const JUDGE_MODEL = 'gemini-2.5-pro'
43
+ // Judge model: Gemini 3.1 Pro preview via router, the model grade.py uses.
44
+ const JUDGE_MODEL = 'gemini-3.1-pro-preview'
45
45
 
46
46
  interface TrataTaskMeta {
47
47
  taskDir: string
@@ -203,10 +203,8 @@ async function callJudge(router: JudgeRouter, prompt: string, maxAttempts = 2):
203
203
  model: {
204
204
  provider: 'tangle-router',
205
205
  default: router.model,
206
- metadata: {
207
- temperature: 0,
208
- maxTokens: Number(process.env.JUDGE_MAX_TOKENS ?? 16384),
209
- },
206
+ maxVisibleOutputTokens: Number(process.env.JUDGE_MAX_TOKENS ?? 16384),
207
+ metadata: { temperature: 0 },
210
208
  },
211
209
  },
212
210
  },
@@ -291,9 +289,10 @@ async function task3SynthesisCheck(
291
289
  return (result as Task3Result) ?? { synthesis_found: null }
292
290
  }
293
291
 
294
- async function runTriataJudge(meta: TrataTaskMeta, answer: string, router: JudgeRouter): Promise<BenchScore> {
292
+ async function runTriataJudge(meta: TrataTaskMeta, answer: string, router: JudgeRouter): Promise<BenchEvaluation> {
295
293
  if (!answer.trim()) {
296
- return { resolved: false, score: 0, detail: JSON.stringify({ error: 'empty answer' }) }
294
+ const raw = { error: 'empty answer' }
295
+ return { passed: false, score: 0, notes: JSON.stringify(raw), raw }
297
296
  }
298
297
 
299
298
  // Stage 1: hallucination check (serial — feeds into stage 2).
@@ -336,18 +335,20 @@ async function runTriataJudge(meta: TrataTaskMeta, answer: string, router: Judge
336
335
  const hallRaw = t1.hallucinations_detected
337
336
  const hallucinations = hallRaw === true || hallRaw === 'true'
338
337
 
338
+ const raw = {
339
+ rawScore,
340
+ themesHit,
341
+ themesMissed,
342
+ hallucinations,
343
+ unverifiableClaims: flaggedClaims.length,
344
+ synthesis: synth ?? null,
345
+ judgeModel: router.model,
346
+ }
339
347
  return {
340
- resolved: rawScore === 4,
348
+ passed: rawScore === 4,
341
349
  score: numThemes > 0 ? rawScore / 4 : 0,
342
- detail: JSON.stringify({
343
- rawScore,
344
- themesHit,
345
- themesMissed,
346
- hallucinations,
347
- unverifiableClaims: flaggedClaims.length,
348
- synthesis: synth ?? null,
349
- judgeModel: router.model,
350
- }),
350
+ notes: JSON.stringify(raw),
351
+ raw,
351
352
  }
352
353
  }
353
354
 
@@ -400,7 +401,7 @@ function loadTask(taskId: string): { task: BenchTask; meta: TrataTaskMeta } {
400
401
  // Store meta in the BenchTask so the judge can access it without re-reading.
401
402
  const task: BenchTask = {
402
403
  id: taskId,
403
- prompt,
404
+ payload: { prompt },
404
405
  metadata: meta as unknown as Record<string, unknown>,
405
406
  }
406
407
 
@@ -449,34 +450,11 @@ function extractAnalysis(artifact: string): string {
449
450
 
450
451
  // ── adapter factory ───────────────────────────────────────────────────────────
451
452
 
452
- export function createTrataHedgeAdapter(): BenchmarkAdapter {
453
- return {
454
- name: 'trata-hedge',
455
-
456
- async preflight() {
457
- const root = benchRoot()
458
- const envDir = join(root, 'environments')
459
- try {
460
- const stat = statSync(envDir)
461
- if (!stat.isDirectory()) throw new Error('not a directory')
462
- } catch {
463
- throw new Error(
464
- `Trata hedge-bench not found at ${envDir}.\n` +
465
- `Clone: git clone --depth 1 https://github.com/Trata-Inc/trata-hedge-bench ${root}`,
466
- )
467
- }
468
- // Validate judge router connectivity.
469
- judgeRouter()
470
- const ids = listTaskIds(root)
471
- if (ids.length === 0) throw new Error(`No task directories found under ${envDir}`)
472
- console.warn(
473
- `[trata-hedge] ${ids.length} tasks loaded from ${root}. ` +
474
- `Worker model reads embedded data inline (Harbor/Docker not required). ` +
475
- `Judge uses ${process.env.JUDGE_MODEL ?? JUDGE_MODEL} via Tangle router.`,
476
- )
477
- },
453
+ export function createTrataHedgeAdapter(): RuntimeBenchmark {
454
+ return runtimeBenchmark({
455
+ id: 'trata-hedge',
478
456
 
479
- async loadTasks(opts: LoadOptions = {}): Promise<BenchTask[]> {
457
+ async loadAll(opts: LoadOptions = {}): Promise<BenchTask[]> {
480
458
  const root = benchRoot()
481
459
  let ids = listTaskIds(root)
482
460
  if (opts.ids) {
@@ -488,17 +466,42 @@ export function createTrataHedgeAdapter(): BenchmarkAdapter {
488
466
  return ids.map((id) => loadTask(id).task)
489
467
  },
490
468
 
491
- async goldArtifact(_task: BenchTask): Promise<string | undefined> {
492
- // No single gold answer: the score comes from rubric theme coverage, not
493
- // string-match against a reference response. Return undefined — the bench
494
- // harness will skip judge self-verification for this adapter.
495
- return undefined
496
- },
497
-
498
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
469
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
499
470
  const meta = readMeta(task)
500
471
  const answer = extractAnalysis(artifact)
501
472
  return runTriataJudge(meta, answer, judgeRouter())
502
473
  },
503
- }
474
+
475
+ runtime: {
476
+ async preflight() {
477
+ const root = benchRoot()
478
+ const envDir = join(root, 'environments')
479
+ try {
480
+ const stat = statSync(envDir)
481
+ if (!stat.isDirectory()) throw new Error('not a directory')
482
+ } catch {
483
+ throw new Error(
484
+ `Trata hedge-bench not found at ${envDir}.\n` +
485
+ `Clone: git clone --depth 1 https://github.com/Trata-Inc/trata-hedge-bench ${root}`,
486
+ )
487
+ }
488
+ // Validate judge router connectivity.
489
+ judgeRouter()
490
+ const ids = listTaskIds(root)
491
+ if (ids.length === 0) throw new Error(`No task directories found under ${envDir}`)
492
+ console.warn(
493
+ `[trata-hedge] ${ids.length} tasks loaded from ${root}. ` +
494
+ `Worker model reads embedded data inline (Harbor/Docker not required). ` +
495
+ `Judge uses ${process.env.JUDGE_MODEL ?? JUDGE_MODEL} via Tangle router.`,
496
+ )
497
+ },
498
+
499
+ async goldArtifact(_task: BenchTask): Promise<string | undefined> {
500
+ // No single gold answer: the score comes from rubric theme coverage, not
501
+ // string-match against a reference response. Return undefined — the bench
502
+ // harness will skip judge self-verification for this adapter.
503
+ return undefined
504
+ },
505
+ },
506
+ })
504
507
  }
@@ -1,25 +1,38 @@
1
1
  /**
2
- * BenchmarkAdapter — the seam every external benchmark implements so the
3
- * agent-runtime loop can be A/B'd (blind vs steering vs steering+memory) against
4
- * a REAL, DETERMINISTIC judge. The worker produces an `artifact` (a patch, a
5
- * command transcript, a final state); the benchmark's own harness scores it.
2
+ * agent-bench's benchmarks are agent-eval `BenchmarkAdapter`s, the one benchmark contract, each with the
3
+ * `runtime` hooks an agent-runtime worker needs: the prompt, the deliverable parser, the in-box workspace
4
+ * setup and extraction, and, where the benchmark's own protocol is the worker, that worker.
6
5
  *
7
- * The point: no self-authored judge, no invented score noise. The number comes
8
- * from the benchmark's published evaluation harness.
6
+ * The point: no self-authored judge, no invented score noise. `evaluate` is the benchmark's published
7
+ * evaluation harness, run on the artifact the worker produced.
8
+ *
9
+ * A public benchmark reports every task, so each one also has `loadAll`, a loader that ignores agent-eval's
10
+ * search/dev/holdout splits, as agent-eval's own Harbor adapter has. `loadDataset(split)` serves the same
11
+ * tasks by agent-eval's deterministic split.
9
12
  */
10
13
 
11
- import type { AgentTurnUsage, OutputAdapter } from '@tangle-network/agent-runtime/kernel'
14
+ import {
15
+ type BenchmarkAdapter,
16
+ type BenchmarkDatasetItem,
17
+ type BenchmarkEvaluation,
18
+ type BenchmarkLoadOptions,
19
+ type BenchmarkRuntimeHooks,
20
+ deterministicSplit,
21
+ selectBenchmarkItems,
22
+ } from '@tangle-network/agent-eval/benchmarks'
23
+ import type { RunSplitTag } from '@tangle-network/agent-eval'
24
+ import type { AgentTurnUsage } from '@tangle-network/agent-runtime/kernel'
25
+ import type { SandboxEvent } from '@tangle-network/sandbox'
12
26
 
13
- export interface BenchTask {
14
- /** Stable benchmark instance id. */
15
- id: string
16
- /** The task statement handed to the worker agent. */
27
+ /** What the worker is handed, and the publisher's subset (domain, category, language, dataset version) the task is in. */
28
+ export interface BenchPayload {
17
29
  prompt: string
18
- split?: string
19
- /** Benchmark-specific fields the worker/judge need (repo, base_commit, gold, …). */
20
- metadata?: Record<string, unknown>
30
+ subset?: string
21
31
  }
22
32
 
33
+ /** One benchmark instance. `metadata` carries the fields the worker and judge need (repo, base_commit, gold, …). */
34
+ export type BenchTask = BenchmarkDatasetItem<BenchPayload>
35
+
23
36
  export interface JudgeArtifactFileReceipt {
24
37
  /** POSIX path relative to the capture directory. */
25
38
  path: string
@@ -46,12 +59,9 @@ export interface JudgeArtifactReceipt {
46
59
  treeSha256: `sha256:${string}`
47
60
  }
48
61
 
49
- export interface BenchScore {
50
- /** Did the deterministic judge pass (tests resolved / state correct)? */
51
- resolved: boolean
52
- /** 0..1 — 1 = fully resolved; partial credit where the harness supports it. */
53
- score: number
54
- detail?: string
62
+ /** agent-eval's verdict (`passed`: the judge passed; `score` 0..1 with partial credit where the harness has it;
63
+ * `notes`), plus the evidence agent-bench's judges keep. */
64
+ export interface BenchEvaluation extends BenchmarkEvaluation {
55
65
  /** Present only when the caller explicitly requested durable judge evidence. */
56
66
  judgeArtifacts?: JudgeArtifactReceipt
57
67
  /** The judge model turn's exact Runtime usage record, present only when the
@@ -61,45 +71,46 @@ export interface BenchScore {
61
71
  judgeUsage?: AgentTurnUsage
62
72
  }
63
73
 
64
- export interface LoadOptions {
65
- limit?: number
66
- split?: string
67
- ids?: string[]
74
+ /** agent-eval's load options (`limit`, `ids`), plus the publisher's subset. */
75
+ export interface LoadOptions extends BenchmarkLoadOptions {
76
+ subset?: string
77
+ }
78
+
79
+ /** The runtime hooks over agent-runtime's sandbox events. `workspaceSetup` runs in the box before the agent
80
+ * shot (a non-zero exit fails the shot); `workspaceExtract` runs in the still-alive box after it, and its
81
+ * stdout is the judged artifact (empty stdout falls back to `output`, then the final answer text). */
82
+ export type BenchRuntime = BenchmarkRuntimeHooks<BenchPayload, string, SandboxEvent>
83
+
84
+ /** An agent-eval `BenchmarkAdapter` an agent-runtime worker runs. */
85
+ export interface RuntimeBenchmark extends BenchmarkAdapter<BenchTask, BenchPayload, string, SandboxEvent> {
86
+ readonly id: string
87
+ readonly runtime: BenchRuntime
88
+ /** Every task in the publisher's order, ignoring agent-eval's splits. */
89
+ loadAll(options?: LoadOptions): Promise<BenchTask[]>
90
+ /** The benchmark's own judge on the worker's artifact. */
91
+ evaluate(item: BenchTask, artifact: string): Promise<BenchEvaluation>
92
+ }
93
+
94
+ export type RuntimeBenchmarkSpec = Omit<RuntimeBenchmark, 'loadDataset' | 'assignSplit' | 'runtime'> & {
95
+ assignSplit?: RuntimeBenchmark['assignSplit']
96
+ /** `prompt` defaults to the task's `payload.prompt`. */
97
+ runtime?: Omit<BenchRuntime, 'prompt'> & Partial<Pick<BenchRuntime, 'prompt'>>
68
98
  }
69
99
 
70
- export interface BenchmarkAdapter {
71
- readonly name: string
72
- /** Throw with actionable guidance when the harness/judge isn't installed/runnable. */
73
- preflight(): Promise<void>
74
- loadTasks(opts?: LoadOptions): Promise<BenchTask[]>
75
- /** DETERMINISTIC judge: score the worker's produced artifact for a task. */
76
- judge(task: BenchTask, artifact: string): Promise<BenchScore>
77
- /** Gold/oracle artifact — lets us self-verify the judge before spending model tokens. */
78
- goldArtifact(task: BenchTask): Promise<string | undefined>
79
- /** How to extract the judged artifact from a run's event stream. Optional —
80
- * defaults to the agent's final answer text (the research/QA case). SWE sets
81
- * it to a patch parser. This is `benchmark = adapter` owning its deliverable,
82
- * so the gate runner (`runGate` / `runBenchmark`) needs no
83
- * per-benchmark branching. */
84
- output?: OutputAdapter<string>
85
- /** Post-shot deliverable extraction from the box FILESYSTEM, not the event stream.
86
- * When set, the shot runner execs `command` in the STILL-ALIVE box after the agent
87
- * turn drains and uses its stdout as the judged artifact — the durable way to capture
88
- * a git diff of the agent's in-box edits (standard SWE-bench practice: SWE-agent /
89
- * OpenHands read the diff from repo STATE), instead of hoping the model printed a
90
- * fenced diff in its reply. Empty stdout ⇒ the runner falls back to `output` (the
91
- * event-stream parse). `cwd` defaults to the box root. */
92
- boxExtract?(task: BenchTask): { command: string; cwd?: string }
93
- /** Optional workspace pre-stage run in the box BEFORE the agent shot (same
94
- * session as `boxExtract`). For repo-state benchmarks (SWE-bench) this clones
95
- * the instance repo at `base_commit` into a fixed path so the agent only edits
96
- * — the harness owns the checkout, not the (stochastic) model. A non-zero exit
97
- * fails the shot loud rather than letting the agent run against an empty box. */
98
- boxSetup?(task: BenchTask): { command: string; cwd?: string }
99
- /** Benchmark-owned worker leaf. Set when the benchmark's native protocol IS the
100
- * worker (e.g. AppWorld's interactive ReAct episode runs inside the engine,
101
- * not as a chat completion) — the experiment uses this instead of the
102
- * BACKEND-selected client; the steer still flows through the per-round prompt.
103
- * Typed loosely to avoid a runtime import cycle; the harness casts it. */
104
- leafClient?: (cfg: { model: string; routerBaseUrl: string; routerKey: string }) => unknown
100
+ /** Build a `RuntimeBenchmark`: splits default to agent-eval's `deterministicSplit` over `<id>::<task id>`. */
101
+ export function runtimeBenchmark(spec: RuntimeBenchmarkSpec): RuntimeBenchmark {
102
+ const assignSplit =
103
+ spec.assignSplit ?? ((itemId: string): RunSplitTag => deterministicSplit(`${spec.id}::${itemId}`))
104
+ return {
105
+ ...spec,
106
+ runtime: { prompt: (task) => task.payload.prompt, ...spec.runtime },
107
+ assignSplit,
108
+ async loadDataset(split, options) {
109
+ const tasks = await spec.loadAll(options?.ids?.length ? { ids: options.ids } : {})
110
+ const inSplit = tasks
111
+ .map((task) => ({ ...task, split: task.split ?? assignSplit(task.id) }))
112
+ .filter((task) => task.split === split)
113
+ return selectBenchmarkItems(inSplit, options)
114
+ },
115
+ }
105
116
  }
@@ -11,7 +11,7 @@ import { access, readFile, stat } from 'node:fs/promises'
11
11
  import { join, resolve } from 'node:path'
12
12
  import type { OutputAdapter } from '@tangle-network/agent-runtime/kernel'
13
13
  import { benchRoot, runVenvPython } from './_harness'
14
- import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
14
+ import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
15
15
 
16
16
  const FIXTURES = join(benchRoot, 'fixtures', 'webarena-verified.json')
17
17
  const DATASET_REL = join('assets', 'dataset', 'webarena-verified.json')
@@ -78,17 +78,19 @@ function rowToTask(row: WebArenaRow): BenchTask {
78
78
  }
79
79
  return {
80
80
  id: String(row.task_id),
81
- prompt: [
82
- 'Run this WebArena-Verified browser task in the official environment.',
83
- `Goal: ${row.intent}`,
84
- row.start_urls?.length ? `Start URL templates: ${row.start_urls.join(', ')}` : undefined,
85
- row.sites?.length ? `Sites: ${row.sites.join(', ')}` : undefined,
86
- '',
87
- 'Return the path to the official WebArena-Verified run output directory for this task.',
88
- 'The judge expects that directory to contain the task response and network trace files.',
89
- ]
90
- .filter(Boolean)
91
- .join('\n'),
81
+ payload: {
82
+ prompt: [
83
+ 'Run this WebArena-Verified browser task in the official environment.',
84
+ `Goal: ${row.intent}`,
85
+ row.start_urls?.length ? `Start URL templates: ${row.start_urls.join(', ')}` : undefined,
86
+ row.sites?.length ? `Sites: ${row.sites.join(', ')}` : undefined,
87
+ '',
88
+ 'Return the path to the official WebArena-Verified run output directory for this task.',
89
+ 'The judge expects that directory to contain the task response and network trace files.',
90
+ ]
91
+ .filter(Boolean)
92
+ .join('\n'),
93
+ },
92
94
  metadata: meta as unknown as Record<string, unknown>,
93
95
  }
94
96
  }
@@ -96,7 +98,7 @@ function rowToTask(row: WebArenaRow): BenchTask {
96
98
  function readMeta(task: BenchTask): WebArenaMeta {
97
99
  const md = task.metadata
98
100
  if (!md || typeof md.taskId !== 'number') {
99
- throw new Error(`webarena-verified task ${task.id} missing metadata — loadTasks did not populate it`)
101
+ throw new Error(`webarena-verified task ${task.id} missing metadata — loadAll did not populate it`)
100
102
  }
101
103
  return md as unknown as WebArenaMeta
102
104
  }
@@ -147,41 +149,20 @@ print(json.dumps(json.loads(result_path.read_text())))
147
149
  return JSON.parse(stdout.trim().split('\n').at(-1) ?? '{}') as Record<string, unknown>
148
150
  }
149
151
 
150
- export function createWebArenaVerifiedAdapter(): BenchmarkAdapter {
152
+ export function createWebArenaVerifiedAdapter(): RuntimeBenchmark {
151
153
  const fixturesMode = process.env.WEBARENA_VERIFIED_FIXTURES === '1'
152
154
 
153
- return {
154
- name: 'webarena-verified',
155
- output: webarenaOutputDirOutput,
156
-
157
- async preflight() {
158
- if (fixturesMode) return
159
- const dir = webarenaDir()
160
- if (!dir) {
161
- throw new Error(
162
- 'WEBARENA_VERIFIED_DIR is required. Fix: clone https://github.com/ServiceNow/webarena-verified, install its deps in bench/.venv, and set WEBARENA_VERIFIED_DIR=/path/to/webarena-verified.',
163
- )
164
- }
165
- await assertFile(join(dir, DATASET_REL), 'official dataset')
166
- await assertFile(join(dir, 'src', 'webarena_verified', '__main__.py'), 'official CLI module')
167
- await runVenvPython(
168
- 'import sys; sys.path.insert(0, sys.argv[1]); import webarena_verified; print("ok")',
169
- [join(dir, 'src')],
170
- )
171
- },
155
+ return runtimeBenchmark({
156
+ id: 'webarena-verified',
172
157
 
173
- async loadTasks(opts: LoadOptions = {}) {
158
+ async loadAll(opts: LoadOptions = {}) {
174
159
  if (fixturesMode) return loadFixtures(opts)
175
160
  const dir = webarenaDir()
176
161
  if (!dir) throw new Error('WEBARENA_VERIFIED_DIR is required to load official WebArena-Verified tasks')
177
162
  return loadOfficialRows(dir, opts)
178
163
  },
179
164
 
180
- async goldArtifact() {
181
- return undefined
182
- },
183
-
184
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
165
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
185
166
  const dir = webarenaDir()
186
167
  if (!dir) throw new Error('WEBARENA_VERIFIED_DIR is required to judge WebArena-Verified artifacts')
187
168
  const outputDir = resolve(artifact.trim())
@@ -190,11 +171,37 @@ export function createWebArenaVerifiedAdapter(): BenchmarkAdapter {
190
171
  const report = await runOfficialEval(dir, meta.taskId, outputDir)
191
172
  const score = typeof report.score === 'number' ? report.score : 0
192
173
  const status = typeof report.status === 'string' ? report.status : 'unknown'
174
+ const raw = { taskId: meta.taskId, status, outputDir }
193
175
  return {
194
- resolved: score === 1,
176
+ passed: score === 1,
195
177
  score,
196
- detail: JSON.stringify({ taskId: meta.taskId, status, outputDir }),
178
+ notes: JSON.stringify(raw),
179
+ raw,
197
180
  }
198
181
  },
199
- }
182
+
183
+ runtime: {
184
+ output: webarenaOutputDirOutput,
185
+
186
+ async preflight() {
187
+ if (fixturesMode) return
188
+ const dir = webarenaDir()
189
+ if (!dir) {
190
+ throw new Error(
191
+ 'WEBARENA_VERIFIED_DIR is required. Fix: clone https://github.com/ServiceNow/webarena-verified, install its deps in bench/.venv, and set WEBARENA_VERIFIED_DIR=/path/to/webarena-verified.',
192
+ )
193
+ }
194
+ await assertFile(join(dir, DATASET_REL), 'official dataset')
195
+ await assertFile(join(dir, 'src', 'webarena_verified', '__main__.py'), 'official CLI module')
196
+ await runVenvPython(
197
+ 'import sys; sys.path.insert(0, sys.argv[1]); import webarena_verified; print("ok")',
198
+ [join(dir, 'src')],
199
+ )
200
+ },
201
+
202
+ async goldArtifact() {
203
+ return undefined
204
+ },
205
+ },
206
+ })
200
207
  }
package/src/cli.ts ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * agent-bench run <benchmark> --target <model:|app:|profile:> [--tasks N] [--task <publisher task id>]... [--out <dir>] [-- <runner args>]
4
+ * agent-bench list
5
+ *
6
+ * Runs a published benchmark with its publisher's own runner and grader (src/published.ts), prints the score with what it
7
+ * measured, and writes the run record to --out (default ./agent-bench-runs/<benchmark>-<time>).
8
+ */
9
+ import path from 'node:path'
10
+ import { PUBLISHED_BENCHMARKS, runPublished } from './published'
11
+
12
+ const usage = 'usage: agent-bench run <benchmark> --target <model:<router model>|app:<agent app>@<harness/model>|profile:<harness/model>> [--tasks N] [--task <id>]... [--judge bridge/<harness/model>] [--experiment <id>] [--candidate <id>] [--split search|dev|holdout] [--out <dir>] [-- <runner args>]\n agent-bench list'
13
+
14
+ async function main(argv: string[]): Promise<number> {
15
+ const [command, ...rest] = argv
16
+ if (command === 'list') {
17
+ for (const benchmark of Object.values(PUBLISHED_BENCHMARKS)) {
18
+ console.log(`${benchmark.name} ${benchmark.version} ${benchmark.repository}@${benchmark.ref.slice(0, 12)} ${benchmark.measured} judge=${benchmark.judge ?? 'deterministic'} license=${benchmark.license}`)
19
+ }
20
+ return 0
21
+ }
22
+ if (command !== 'run' || !rest[0] || rest[0].startsWith('-')) {
23
+ console.error(usage)
24
+ return 2
25
+ }
26
+ const name = rest[0]
27
+ const separator = rest.indexOf('--')
28
+ const own = separator === -1 ? rest.slice(1) : rest.slice(1, separator)
29
+ const runnerArgs = separator === -1 ? [] : rest.slice(separator + 1)
30
+ let target: string | undefined
31
+ let tasks: number | undefined
32
+ const taskIds: string[] = []
33
+ let out: string | undefined
34
+ let judge: string | undefined
35
+ const record: { experimentId?: string; candidateId?: string; splitTag?: 'search' | 'dev' | 'holdout' } = {}
36
+ for (let i = 0; i < own.length; i++) {
37
+ const flag = own[i]
38
+ const value = own[i + 1]
39
+ if (value === undefined) throw new Error(`${flag} needs a value\n${usage}`)
40
+ if (flag === '--target') target = value
41
+ else if (flag === '--tasks') tasks = Number.parseInt(value, 10)
42
+ else if (flag === '--task') taskIds.push(value)
43
+ else if (flag === '--out') out = value
44
+ else if (flag === '--judge') judge = value
45
+ else if (flag === '--experiment') record.experimentId = value
46
+ else if (flag === '--candidate') record.candidateId = value
47
+ else if (flag === '--split') record.splitTag = value as 'search' | 'dev' | 'holdout'
48
+ else throw new Error(`unknown option ${flag}\n${usage}`)
49
+ i++
50
+ }
51
+ if (!target) throw new Error(`--target is required\n${usage}`)
52
+ if (tasks !== undefined && !(Number.isSafeInteger(tasks) && tasks > 0)) throw new Error('--tasks must be a positive integer')
53
+ const run = await runPublished(name, target, {
54
+ ...(tasks === undefined ? {} : { tasks }),
55
+ ...(taskIds.length ? { taskIds } : {}),
56
+ ...(judge === undefined ? {} : { judge }),
57
+ ...(Object.keys(record).length ? { record } : {}),
58
+ args: runnerArgs,
59
+ out: path.resolve(out ?? path.join('agent-bench-runs', `${name}-${new Date().toISOString().replace(/[:.]/g, '-')}`)),
60
+ })
61
+ console.log(`${run.benchmark} ${run.version} on ${run.target}: ${run.passed} of ${run.tasks} passed, score ${run.score.toFixed(3)}, measured ${run.measured}, judge ${run.judge === null ? 'deterministic' : run.judge} (${run.official ? 'official' : `${[run.judge !== run.publisherJudge ? `substituted for ${run.publisherJudge}` : undefined, run.unofficial].filter(Boolean).join('; ')}, not official`})`)
62
+ if (run.app) {
63
+ console.log(`app: ${run.app.app} profile ${run.app.profileName ?? '?'} ${run.app.profileVersion ?? ''} ${run.app.profileDigest.slice(0, 19)} from ${run.app.profileUrl}; ` +
64
+ `its production model ${JSON.stringify(run.app.productionModel)} replaced by ${run.model}; its MCP servers not mounted: ${run.app.omittedMcp.join(', ') || 'none'}`)
65
+ }
66
+ console.log(`record: ${path.join(path.dirname(run.resultPath), `${run.benchmark}-run.json`)}`)
67
+ console.log(`run records: ${run.runRecords}`)
68
+ return 0
69
+ }
70
+
71
+ main(process.argv.slice(2)).then((code) => process.exit(code), (error: unknown) => {
72
+ console.error(error instanceof Error ? error.message : String(error))
73
+ process.exit(1)
74
+ })
@@ -30,13 +30,13 @@
30
30
  import { readFile } from 'node:fs/promises'
31
31
  import { argv } from 'node:process'
32
32
  import { fileURLToPath } from 'node:url'
33
- import type { BenchmarkAdapter, BenchScore, BenchTask } from './benchmarks/types'
33
+ import type { BenchEvaluation, BenchTask, RuntimeBenchmark } from './benchmarks/types'
34
34
  import { ADAPTERS } from './adapters'
35
35
  import type { BenchRunRecord } from './corpus'
36
36
  import { selfConsistencySelect, summarizeSelector, summarizeVerifierSelector } from './selector'
37
37
 
38
38
  /** The benchmark's own judge - the EXTERNAL, write-only anchor (learning-flywheel.md). */
39
- export type Judge = (task: BenchTask, artifact: string) => Promise<BenchScore>
39
+ export type Judge = (task: BenchTask, artifact: string) => Promise<BenchEvaluation>
40
40
 
41
41
  /**
42
42
  * The recorded FINAL output of a controller-run: the last attempt that actually
@@ -88,7 +88,7 @@ export async function scoreCandidateOffline(
88
88
  )
89
89
  }
90
90
  const verdict = await judge(task, candidateOutput)
91
- return { resolved: verdict.resolved === true, score: verdict.score }
91
+ return { resolved: verdict.passed === true, score: verdict.score }
92
92
  }
93
93
 
94
94
  /** Parse the corpus JSONL; fail loud on empty/unreadable. */
@@ -115,12 +115,12 @@ async function readCorpus(corpusPath: string): Promise<BenchRunRecord[]> {
115
115
 
116
116
  /**
117
117
  * Resolve every recorded instanceId for one benchmark to its BenchTask in a single
118
- * loadTasks call (the judge needs the task's gold/judge metadata). Fail loud when a
118
+ * loadAll call (the judge needs the task's gold/judge metadata). Fail loud when a
119
119
  * recorded instance is absent from the live/fixture dataset - that is corpus/dataset
120
120
  * drift, not a replayable record.
121
121
  */
122
- async function loadTaskMap(adapter: BenchmarkAdapter, ids: string[]): Promise<Map<string, BenchTask>> {
123
- const tasks = await adapter.loadTasks({ ids })
122
+ async function loadTaskMap(adapter: RuntimeBenchmark, ids: string[]): Promise<Map<string, BenchTask>> {
123
+ const tasks = await adapter.loadAll({ ids })
124
124
  const byId = new Map<string, BenchTask>()
125
125
  for (const t of tasks) byId.set(t.id, t)
126
126
  return byId
@@ -249,7 +249,7 @@ async function main(): Promise<void> {
249
249
 
250
250
  // --judge: preflight, resolve recorded instances -> BenchTask, re-run the judge
251
251
  // on each recorded final output, compare the replayed verdict to record.resolved.
252
- await adapter.preflight()
252
+ await adapter.runtime.preflight?.()
253
253
  const ids = [...new Set(replayable.map((r) => r.instanceId))]
254
254
  const taskMap = await loadTaskMap(adapter, ids)
255
255
 
@@ -265,9 +265,9 @@ async function main(): Promise<void> {
265
265
  console.warn(`[${bench}] instance ${r.instanceId} not in dataset - corpus/dataset drift; skipping`)
266
266
  continue
267
267
  }
268
- const verdict = await adapter.judge(task, out)
268
+ const verdict = await adapter.evaluate(task, out)
269
269
  judged += 1
270
- if ((verdict.resolved === true) === (r.resolved === true)) agree += 1
270
+ if ((verdict.passed === true) === (r.resolved === true)) agree += 1
271
271
  }
272
272
  const rate = judged > 0 ? agree / judged : 0
273
273
  console.log(