@tangle-network/agent-bench 2.0.0 → 4.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 +27 -0
  2. package/README.md +32 -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 +61 -48
  39. package/dist/benchmarks/finresearchbench.js.map +1 -1
  40. package/dist/benchmarks/finsearchcomp.d.ts +3 -3
  41. package/dist/benchmarks/finsearchcomp.js +54 -43
  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 +2 -2
  56. package/dist/benchmarks/mcad-cq-bench.js +69 -57
  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 +62 -51
  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 +46 -38
  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-Byr5gO1M.js → cadbench-htzAmMaI.js} +39 -32
  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 +43 -22
  120. package/dist/index.js +297 -144
  121. package/dist/index.js.map +1 -1
  122. package/package.json +7 -4
  123. package/pier_agents/candidate_contract.py +226 -74
  124. package/pier_agents/tangle_candidate.py +79 -1
  125. package/pier_agents/workspace_boundary.py +29 -1
  126. package/scripts/enterpriseops-gym-run.sh +82 -0
  127. package/scripts/grade-recorded-evidence.mjs +6 -6
  128. package/scripts/harvey-lab-judge.py +50 -0
  129. package/scripts/harvey-lab-run.sh +53 -0
  130. package/scripts/harvey-lab-sandbox.sh +21 -0
  131. package/scripts/healthbench-professional-run.sh +30 -0
  132. package/scripts/healthbench_professional_run.py +112 -0
  133. package/scripts/mlcr-run.sh +17 -0
  134. package/scripts/mlcr_run.py +133 -0
  135. package/scripts/prbench-run.sh +39 -0
  136. package/scripts/prbench_run.py +53 -0
  137. package/scripts/verify-packed-consumer.mjs +32 -27
  138. package/scripts/verify-pier-agent.mts +142 -25
  139. package/src/adapters.ts +5 -7
  140. package/src/benchmarks/_harness.test.mts +18 -1
  141. package/src/benchmarks/_harness.ts +12 -7
  142. package/src/benchmarks/aec-bench.test.mts +14 -14
  143. package/src/benchmarks/aec-bench.ts +62 -56
  144. package/src/benchmarks/agent-eval-contract.test.mts +38 -0
  145. package/src/benchmarks/agentbench.ts +44 -37
  146. package/src/benchmarks/appworld.test.mts +7 -7
  147. package/src/benchmarks/appworld.ts +88 -75
  148. package/src/benchmarks/bfcl.ts +60 -53
  149. package/src/benchmarks/cad-design.ts +34 -32
  150. package/src/benchmarks/cadbench.ts +34 -32
  151. package/src/benchmarks/cadgenbench.ts +30 -28
  152. package/src/benchmarks/commit0.test.mts +9 -9
  153. package/src/benchmarks/commit0.ts +50 -43
  154. package/src/benchmarks/crag.ts +45 -40
  155. package/src/benchmarks/dabstep-official.test.mts +8 -8
  156. package/src/benchmarks/dabstep.test.mts +11 -11
  157. package/src/benchmarks/dabstep.ts +47 -40
  158. package/src/benchmarks/external-adapters.test.mts +43 -44
  159. package/src/benchmarks/finresearchbench.ts +57 -47
  160. package/src/benchmarks/finsearchcomp.ts +72 -67
  161. package/src/benchmarks/frames.ts +76 -69
  162. package/src/benchmarks/hotpotqa.ts +69 -64
  163. package/src/benchmarks/humaneval.ts +37 -35
  164. package/src/benchmarks/mcad-bench.test.mts +30 -30
  165. package/src/benchmarks/mcad-bench.ts +66 -60
  166. package/src/benchmarks/mcad-cq-bench.ts +69 -63
  167. package/src/benchmarks/mcad-cq-golds.ts +1 -1
  168. package/src/benchmarks/mcad-cq.test.mts +40 -40
  169. package/src/benchmarks/mcad-golds.ts +1 -1
  170. package/src/benchmarks/mind2web.ts +66 -58
  171. package/src/benchmarks/nomiracl.ts +53 -46
  172. package/src/benchmarks/open-rag-bench.ts +47 -42
  173. package/src/benchmarks/programbench.test.mts +10 -10
  174. package/src/benchmarks/programbench.ts +38 -33
  175. package/src/benchmarks/rag-benchmarks.test.mts +31 -31
  176. package/src/benchmarks/rag-shared.ts +13 -16
  177. package/src/benchmarks/ragbench.ts +44 -39
  178. package/src/benchmarks/simpleqa.ts +78 -73
  179. package/src/benchmarks/swe-bench.test.mts +3 -3
  180. package/src/benchmarks/swe-bench.ts +66 -61
  181. package/src/benchmarks/t2-ragbench.ts +47 -42
  182. package/src/benchmarks/tau-bench-shared.ts +51 -44
  183. package/src/benchmarks/tau-pin.test.mts +1 -1
  184. package/src/benchmarks/tau2-bench.ts +2 -2
  185. package/src/benchmarks/tau3-banking.ts +2 -2
  186. package/src/benchmarks/terminal-bench.test.mts +3 -3
  187. package/src/benchmarks/terminal-bench.ts +41 -36
  188. package/src/benchmarks/toollm.ts +54 -47
  189. package/src/benchmarks/trata-hedge.ts +57 -52
  190. package/src/benchmarks/types.ts +70 -59
  191. package/src/benchmarks/webarena-verified.ts +49 -42
  192. package/src/cli.ts +74 -0
  193. package/src/corpus-replay.mts +9 -9
  194. package/src/examples/benchmark-matrix.mts +13 -10
  195. package/src/gate-cli.mts +5 -5
  196. package/src/gate.test.mts +14 -12
  197. package/src/gate.ts +23 -22
  198. package/src/index.ts +20 -11
  199. package/src/pier-agent.ts +108 -38
  200. package/src/pier-trial-controller.test.mts +48 -1
  201. package/src/pier-trial-controller.ts +121 -8
  202. package/src/published.test.mts +534 -0
  203. package/src/published.ts +524 -0
  204. package/src/run-benchmarks-cli.mts +2 -2
  205. package/src/run-benchmarks.test.mts +58 -48
  206. package/src/run-benchmarks.ts +64 -57
  207. package/src/swe-bench-env.ts +6 -6
  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-Byr5gO1M.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
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Requires: an isolated bench `.venv-terminal-bench` with `terminal-bench`
10
10
  * installed + a running Docker daemon (per-task images are built on first run).
11
- * Override with TERMINAL_BENCH_VENV. loadTasks caches the dataset from the
11
+ * Override with TERMINAL_BENCH_VENV. loadAll caches the dataset from the
12
12
  * Terminal-Bench registry on first run.
13
13
  *
14
14
  * Process/Docker/report plumbing is shared via ./_harness; this file owns the
@@ -28,7 +28,7 @@ import {
28
28
  venvBinAt,
29
29
  venvPythonAt,
30
30
  } from './_harness'
31
- import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
31
+ import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
32
32
 
33
33
  // Terminal-Bench imports LiteLLM/Pydantic-2 APIs, while AppWorld pins Pydantic 1.
34
34
  // Keep it out of the shared bench .venv. Resolved at call-time so tests/runs can
@@ -106,38 +106,25 @@ print(json.dumps(out))
106
106
  return JSON.parse(stdout) as TbTaskRow[]
107
107
  }
108
108
 
109
- export function createTerminalBenchAdapter(): BenchmarkAdapter {
110
- return {
111
- name: 'terminal-bench',
112
-
113
- async preflight() {
114
- await preflightVenvImports({
115
- modules: ['terminal_bench'],
116
- requireDocker: true,
117
- python: terminalBenchPython(),
118
- fix:
119
- `Fix: (1) python3 -m venv bench/${terminalBenchVenvDir()} && ` +
120
- `bench/${terminalBenchVenvDir()}/bin/pip install terminal-bench ` +
121
- `(an ISOLATED venv — Terminal-Bench/LiteLLM require Pydantic 2 while AppWorld pins Pydantic 1; ` +
122
- `override the dir with TERMINAL_BENCH_VENV) ; ` +
123
- `(2) ensure the Docker daemon is running (the judge builds per-task images on first run). ` +
124
- `The ${DATASET_REF} dataset is cached from the Terminal-Bench registry on first loadTasks.`,
125
- })
126
- },
109
+ export function createTerminalBenchAdapter(): RuntimeBenchmark {
110
+ return runtimeBenchmark({
111
+ id: 'terminal-bench',
127
112
 
128
- async loadTasks(opts: LoadOptions = {}) {
113
+ async loadAll(opts: LoadOptions = {}) {
129
114
  const rows = await loadRows(opts)
130
115
  if (rows.length === 0) {
131
116
  throw new Error(
132
- `terminal-bench loadTasks returned no tasks for ${JSON.stringify(opts)} ` +
117
+ `terminal-bench loadAll returned no tasks for ${JSON.stringify(opts)} ` +
133
118
  `(dataset ${DATASET_REF}). Check the requested ids exist in the dataset.`,
134
119
  )
135
120
  }
136
121
  return rows.map(
137
122
  (r): BenchTask => ({
138
123
  id: r.id,
139
- split: DATASET_VERSION,
140
- prompt: r.instruction,
124
+ payload: {
125
+ subset: DATASET_VERSION,
126
+ prompt: r.instruction,
127
+ },
141
128
  metadata: {
142
129
  dataset: DATASET,
143
130
  datasetVersion: DATASET_VERSION,
@@ -150,15 +137,7 @@ export function createTerminalBenchAdapter(): BenchmarkAdapter {
150
137
  )
151
138
  },
152
139
 
153
- async goldArtifact(task: BenchTask) {
154
- // Gold = the task's solution.sh (the oracle script). solution.yaml tasks have
155
- // no shell-script artifact form here, so they return undefined (cannot be
156
- // verify-judged via the script-replay seam — use a .sh-solution task).
157
- const sol = task.metadata?.solution
158
- return typeof sol === 'string' ? sol : undefined
159
- },
160
-
161
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
140
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
162
141
  const runId = safeRunId('bench', `${task.id}-${Date.now()}`)
163
142
  return runStagedJudge({
164
143
  tmpPrefix: 'tbench-',
@@ -187,12 +166,38 @@ export function createTerminalBenchAdapter(): BenchmarkAdapter {
187
166
  const resolved = (report.resolved_ids ?? []).includes(task.id)
188
167
  const trial = report.results?.find((r) => r.task_id === task.id)
189
168
  return {
190
- resolved,
169
+ passed: resolved,
191
170
  score: resolved ? 1 : 0,
192
- detail: JSON.stringify(trial?.parser_results ?? report.resolved_ids ?? {}),
171
+ notes: JSON.stringify(trial?.parser_results ?? report.resolved_ids ?? {}),
172
+ raw: {},
193
173
  }
194
174
  },
195
175
  })
196
176
  },
197
- }
177
+
178
+ runtime: {
179
+ async preflight() {
180
+ await preflightVenvImports({
181
+ modules: ['terminal_bench'],
182
+ requireDocker: true,
183
+ python: terminalBenchPython(),
184
+ fix:
185
+ `Fix: (1) python3 -m venv bench/${terminalBenchVenvDir()} && ` +
186
+ `bench/${terminalBenchVenvDir()}/bin/pip install terminal-bench ` +
187
+ `(an ISOLATED venv — Terminal-Bench/LiteLLM require Pydantic 2 while AppWorld pins Pydantic 1; ` +
188
+ `override the dir with TERMINAL_BENCH_VENV) ; ` +
189
+ `(2) ensure the Docker daemon is running (the judge builds per-task images on first run). ` +
190
+ `The ${DATASET_REF} dataset is cached from the Terminal-Bench registry on first loadAll.`,
191
+ })
192
+ },
193
+
194
+ async goldArtifact(task: BenchTask) {
195
+ // Gold = the task's solution.sh (the oracle script). solution.yaml tasks have
196
+ // no shell-script artifact form here, so they return undefined (cannot be
197
+ // verify-judged via the script-replay seam — use a .sh-solution task).
198
+ const sol = task.metadata?.solution
199
+ return typeof sol === 'string' ? sol : undefined
200
+ },
201
+ },
202
+ })
198
203
  }
@@ -11,7 +11,7 @@ import { readFile } from 'node:fs/promises'
11
11
  import { join } from 'node:path'
12
12
  import type { OutputAdapter } from '@tangle-network/agent-runtime/kernel'
13
13
  import { benchRoot } 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', 'toollm.json')
17
17
  const DEFAULT_QUERY_REL = join('data_example', 'instruction', 'G1_query.json')
@@ -65,16 +65,18 @@ function rowToTask(row: ToolBenchRow): BenchTask {
65
65
  }
66
66
  return {
67
67
  id: String(row.query_id),
68
- prompt: [
69
- 'Solve this ToolLLM/ToolBench API-use task.',
70
- 'Use only the listed APIs/tools and return the completed tool-use trace plus final answer.',
71
- '',
72
- `Query: ${row.query}`,
73
- '',
74
- `Available APIs: ${JSON.stringify(row.api_list ?? [], null, 2)}`,
75
- '',
76
- 'Return the APIs you used as JSON: {"api_calls":[{"tool_name":"...","api_name":"..."}]}.',
77
- ].join('\n'),
68
+ payload: {
69
+ prompt: [
70
+ 'Solve this ToolLLM/ToolBench API-use task.',
71
+ 'Use only the listed APIs/tools and return the completed tool-use trace plus final answer.',
72
+ '',
73
+ `Query: ${row.query}`,
74
+ '',
75
+ `Available APIs: ${JSON.stringify(row.api_list ?? [], null, 2)}`,
76
+ '',
77
+ 'Return the APIs you used as JSON: {"api_calls":[{"tool_name":"...","api_name":"..."}]}.',
78
+ ].join('\n'),
79
+ },
78
80
  metadata: meta as unknown as Record<string, unknown>,
79
81
  }
80
82
  }
@@ -107,7 +109,7 @@ function normalizeApiPairs(value: unknown): Array<[string, string]> {
107
109
  function readMeta(task: BenchTask): ToolBenchMeta {
108
110
  const md = task.metadata
109
111
  if (!md || !Array.isArray(md.relevantApis)) {
110
- throw new Error(`ToolLLM task ${task.id} missing metadata — loadTasks did not populate deterministic API-selection labels`)
112
+ throw new Error(`ToolLLM task ${task.id} missing metadata — loadAll did not populate deterministic API-selection labels`)
111
113
  }
112
114
  return md as unknown as ToolBenchMeta
113
115
  }
@@ -186,7 +188,7 @@ function extractCalledApis(text: string, expected: readonly [string, string][]):
186
188
  }
187
189
  }
188
190
 
189
- function scoreApiSelection(task: BenchTask, artifact: string): BenchScore {
191
+ function scoreApiSelection(task: BenchTask, artifact: string): BenchEvaluation {
190
192
  const meta = readMeta(task)
191
193
  if (meta.relevantApis.length === 0) {
192
194
  throw new Error(`ToolLLM task ${task.id} has no deterministic API-selection labels; refusing to score`)
@@ -200,55 +202,60 @@ function scoreApiSelection(task: BenchTask, artifact: string): BenchScore {
200
202
  const recall = truePositives / expected.size
201
203
  const score = expected.size === 0 ? 0 : recall
202
204
  const resolved = extracted.source === 'structured-json' && recall === 1 && precision === 1
205
+ const raw = {
206
+ scoring: 'api-selection-only',
207
+ extractionSource: extracted.source,
208
+ queryId: meta.queryId,
209
+ expected: meta.relevantApis,
210
+ called: calledPairs,
211
+ precision,
212
+ recall,
213
+ fullToolEvalScore: null,
214
+ }
203
215
  return {
204
- resolved,
216
+ passed: resolved,
205
217
  score,
206
- detail: JSON.stringify({
207
- scoring: 'api-selection-only',
208
- extractionSource: extracted.source,
209
- queryId: meta.queryId,
210
- expected: meta.relevantApis,
211
- called: calledPairs,
212
- precision,
213
- recall,
214
- fullToolEvalScore: null,
215
- }),
218
+ notes: JSON.stringify(raw),
219
+ raw,
216
220
  }
217
221
  }
218
222
 
219
- export function createToolLlmAdapter(): BenchmarkAdapter {
223
+ export function createToolLlmAdapter(): RuntimeBenchmark {
220
224
  const fixturesMode = process.env.TOOLLM_FIXTURES === '1'
221
225
 
222
- return {
223
- name: 'toollm',
224
- output: toollmOutput,
225
-
226
- async preflight() {
227
- if (fixturesMode) return
228
- const dir = toolbenchDir()
229
- if (!dir) {
230
- throw new Error('TOOLBENCH_DIR is required. Fix: clone https://github.com/OpenBMB/ToolBench and set TOOLBENCH_DIR=/path/to/ToolBench.')
231
- }
232
- await loadOfficialTasks(dir, { limit: 1 })
233
- },
226
+ return runtimeBenchmark({
227
+ id: 'toollm',
234
228
 
235
- async loadTasks(opts: LoadOptions = {}) {
229
+ async loadAll(opts: LoadOptions = {}) {
236
230
  if (fixturesMode) return loadFixtures(opts)
237
231
  const dir = toolbenchDir()
238
232
  if (!dir) throw new Error('TOOLBENCH_DIR is required to load ToolLLM tasks')
239
233
  return loadOfficialTasks(dir, opts)
240
234
  },
241
235
 
242
- async goldArtifact(task: BenchTask) {
243
- const meta = readMeta(task)
244
- if (meta.relevantApis.length === 0) return undefined
245
- return JSON.stringify({
246
- api_calls: meta.relevantApis.map(([tool_name, api_name]) => ({ tool_name, api_name })),
247
- }, null, 2)
236
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
237
+ return scoreApiSelection(task, artifact)
248
238
  },
249
239
 
250
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
251
- return scoreApiSelection(task, artifact)
240
+ runtime: {
241
+ output: toollmOutput,
242
+
243
+ async preflight() {
244
+ if (fixturesMode) return
245
+ const dir = toolbenchDir()
246
+ if (!dir) {
247
+ throw new Error('TOOLBENCH_DIR is required. Fix: clone https://github.com/OpenBMB/ToolBench and set TOOLBENCH_DIR=/path/to/ToolBench.')
248
+ }
249
+ await loadOfficialTasks(dir, { limit: 1 })
250
+ },
251
+
252
+ async goldArtifact(task: BenchTask) {
253
+ const meta = readMeta(task)
254
+ if (meta.relevantApis.length === 0) return undefined
255
+ return JSON.stringify({
256
+ api_calls: meta.relevantApis.map(([tool_name, api_name]) => ({ tool_name, api_name })),
257
+ }, null, 2)
258
+ },
252
259
  },
253
- }
260
+ })
254
261
  }
@@ -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
@@ -289,9 +289,10 @@ async function task3SynthesisCheck(
289
289
  return (result as Task3Result) ?? { synthesis_found: null }
290
290
  }
291
291
 
292
- async function runTriataJudge(meta: TrataTaskMeta, answer: string, router: JudgeRouter): Promise<BenchScore> {
292
+ async function runTriataJudge(meta: TrataTaskMeta, answer: string, router: JudgeRouter): Promise<BenchEvaluation> {
293
293
  if (!answer.trim()) {
294
- 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 }
295
296
  }
296
297
 
297
298
  // Stage 1: hallucination check (serial — feeds into stage 2).
@@ -334,18 +335,20 @@ async function runTriataJudge(meta: TrataTaskMeta, answer: string, router: Judge
334
335
  const hallRaw = t1.hallucinations_detected
335
336
  const hallucinations = hallRaw === true || hallRaw === 'true'
336
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
+ }
337
347
  return {
338
- resolved: rawScore === 4,
348
+ passed: rawScore === 4,
339
349
  score: numThemes > 0 ? rawScore / 4 : 0,
340
- detail: JSON.stringify({
341
- rawScore,
342
- themesHit,
343
- themesMissed,
344
- hallucinations,
345
- unverifiableClaims: flaggedClaims.length,
346
- synthesis: synth ?? null,
347
- judgeModel: router.model,
348
- }),
350
+ notes: JSON.stringify(raw),
351
+ raw,
349
352
  }
350
353
  }
351
354
 
@@ -398,7 +401,7 @@ function loadTask(taskId: string): { task: BenchTask; meta: TrataTaskMeta } {
398
401
  // Store meta in the BenchTask so the judge can access it without re-reading.
399
402
  const task: BenchTask = {
400
403
  id: taskId,
401
- prompt,
404
+ payload: { prompt },
402
405
  metadata: meta as unknown as Record<string, unknown>,
403
406
  }
404
407
 
@@ -447,34 +450,11 @@ function extractAnalysis(artifact: string): string {
447
450
 
448
451
  // ── adapter factory ───────────────────────────────────────────────────────────
449
452
 
450
- export function createTrataHedgeAdapter(): BenchmarkAdapter {
451
- return {
452
- name: 'trata-hedge',
453
-
454
- async preflight() {
455
- const root = benchRoot()
456
- const envDir = join(root, 'environments')
457
- try {
458
- const stat = statSync(envDir)
459
- if (!stat.isDirectory()) throw new Error('not a directory')
460
- } catch {
461
- throw new Error(
462
- `Trata hedge-bench not found at ${envDir}.\n` +
463
- `Clone: git clone --depth 1 https://github.com/Trata-Inc/trata-hedge-bench ${root}`,
464
- )
465
- }
466
- // Validate judge router connectivity.
467
- judgeRouter()
468
- const ids = listTaskIds(root)
469
- if (ids.length === 0) throw new Error(`No task directories found under ${envDir}`)
470
- console.warn(
471
- `[trata-hedge] ${ids.length} tasks loaded from ${root}. ` +
472
- `Worker model reads embedded data inline (Harbor/Docker not required). ` +
473
- `Judge uses ${process.env.JUDGE_MODEL ?? JUDGE_MODEL} via Tangle router.`,
474
- )
475
- },
453
+ export function createTrataHedgeAdapter(): RuntimeBenchmark {
454
+ return runtimeBenchmark({
455
+ id: 'trata-hedge',
476
456
 
477
- async loadTasks(opts: LoadOptions = {}): Promise<BenchTask[]> {
457
+ async loadAll(opts: LoadOptions = {}): Promise<BenchTask[]> {
478
458
  const root = benchRoot()
479
459
  let ids = listTaskIds(root)
480
460
  if (opts.ids) {
@@ -486,17 +466,42 @@ export function createTrataHedgeAdapter(): BenchmarkAdapter {
486
466
  return ids.map((id) => loadTask(id).task)
487
467
  },
488
468
 
489
- async goldArtifact(_task: BenchTask): Promise<string | undefined> {
490
- // No single gold answer: the score comes from rubric theme coverage, not
491
- // string-match against a reference response. Return undefined — the bench
492
- // harness will skip judge self-verification for this adapter.
493
- return undefined
494
- },
495
-
496
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
469
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
497
470
  const meta = readMeta(task)
498
471
  const answer = extractAnalysis(artifact)
499
472
  return runTriataJudge(meta, answer, judgeRouter())
500
473
  },
501
- }
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
+ })
502
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
  }