@tangle-network/agent-bench 2.0.0 → 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 (215) hide show
  1. package/CHANGELOG.md +20 -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 +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 +9 -8
  120. package/dist/index.js +61 -56
  121. package/dist/index.js.map +1 -1
  122. package/package.json +7 -4
  123. package/scripts/enterpriseops-gym-run.sh +82 -0
  124. package/scripts/grade-recorded-evidence.mjs +6 -6
  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/benchmarks/_harness.test.mts +18 -1
  137. package/src/benchmarks/_harness.ts +12 -7
  138. package/src/benchmarks/aec-bench.test.mts +14 -14
  139. package/src/benchmarks/aec-bench.ts +62 -56
  140. package/src/benchmarks/agent-eval-contract.test.mts +38 -0
  141. package/src/benchmarks/agentbench.ts +44 -37
  142. package/src/benchmarks/appworld.test.mts +7 -7
  143. package/src/benchmarks/appworld.ts +88 -75
  144. package/src/benchmarks/bfcl.ts +60 -53
  145. package/src/benchmarks/cad-design.ts +34 -32
  146. package/src/benchmarks/cadbench.ts +34 -32
  147. package/src/benchmarks/cadgenbench.ts +30 -28
  148. package/src/benchmarks/commit0.test.mts +9 -9
  149. package/src/benchmarks/commit0.ts +50 -43
  150. package/src/benchmarks/crag.ts +45 -40
  151. package/src/benchmarks/dabstep-official.test.mts +8 -8
  152. package/src/benchmarks/dabstep.test.mts +11 -11
  153. package/src/benchmarks/dabstep.ts +47 -40
  154. package/src/benchmarks/external-adapters.test.mts +43 -44
  155. package/src/benchmarks/finresearchbench.ts +57 -47
  156. package/src/benchmarks/finsearchcomp.ts +72 -67
  157. package/src/benchmarks/frames.ts +76 -69
  158. package/src/benchmarks/hotpotqa.ts +69 -64
  159. package/src/benchmarks/humaneval.ts +37 -35
  160. package/src/benchmarks/mcad-bench.test.mts +30 -30
  161. package/src/benchmarks/mcad-bench.ts +66 -60
  162. package/src/benchmarks/mcad-cq-bench.ts +69 -63
  163. package/src/benchmarks/mcad-cq-golds.ts +1 -1
  164. package/src/benchmarks/mcad-cq.test.mts +40 -40
  165. package/src/benchmarks/mcad-golds.ts +1 -1
  166. package/src/benchmarks/mind2web.ts +66 -58
  167. package/src/benchmarks/nomiracl.ts +53 -46
  168. package/src/benchmarks/open-rag-bench.ts +47 -42
  169. package/src/benchmarks/programbench.test.mts +10 -10
  170. package/src/benchmarks/programbench.ts +38 -33
  171. package/src/benchmarks/rag-benchmarks.test.mts +31 -31
  172. package/src/benchmarks/rag-shared.ts +13 -16
  173. package/src/benchmarks/ragbench.ts +44 -39
  174. package/src/benchmarks/simpleqa.ts +78 -73
  175. package/src/benchmarks/swe-bench.test.mts +3 -3
  176. package/src/benchmarks/swe-bench.ts +66 -61
  177. package/src/benchmarks/t2-ragbench.ts +47 -42
  178. package/src/benchmarks/tau-bench-shared.ts +51 -44
  179. package/src/benchmarks/tau-pin.test.mts +1 -1
  180. package/src/benchmarks/tau2-bench.ts +2 -2
  181. package/src/benchmarks/tau3-banking.ts +2 -2
  182. package/src/benchmarks/terminal-bench.test.mts +3 -3
  183. package/src/benchmarks/terminal-bench.ts +41 -36
  184. package/src/benchmarks/toollm.ts +54 -47
  185. package/src/benchmarks/trata-hedge.ts +57 -52
  186. package/src/benchmarks/types.ts +70 -59
  187. package/src/benchmarks/webarena-verified.ts +49 -42
  188. package/src/cli.ts +74 -0
  189. package/src/corpus-replay.mts +9 -9
  190. package/src/examples/benchmark-matrix.mts +13 -10
  191. package/src/gate-cli.mts +5 -5
  192. package/src/gate.test.mts +14 -12
  193. package/src/gate.ts +23 -22
  194. package/src/index.ts +17 -11
  195. package/src/published.test.mts +534 -0
  196. package/src/published.ts +524 -0
  197. package/src/run-benchmarks-cli.mts +2 -2
  198. package/src/run-benchmarks.test.mts +58 -48
  199. package/src/run-benchmarks.ts +64 -57
  200. package/src/swe-bench-env.ts +6 -6
  201. package/src/worker.ts +1 -1
  202. package/dist/benchmarks/enterpriseops-gym.d.ts +0 -6
  203. package/dist/benchmarks/enterpriseops-gym.js +0 -236
  204. package/dist/benchmarks/enterpriseops-gym.js.map +0 -1
  205. package/dist/cadbench-Byr5gO1M.js.map +0 -1
  206. package/dist/cadgenbench-Tvk16YKT.js.map +0 -1
  207. package/fixtures/enterpriseops-gym.json +0 -103
  208. package/scripts/enterpriseops_gym_judge.py +0 -281
  209. package/src/benchmarks/enterpriseops-gym.test.mts +0 -77
  210. package/src/benchmarks/enterpriseops-gym.ts +0 -343
  211. package/src/eops-skills/address-every-subtask.md +0 -5
  212. package/src/eops-skills/exact-tools-and-args.md +0 -5
  213. package/src/eops-skills/full-sequence-to-goal.md +0 -5
  214. package/src/eops-skills/ground-every-value.md +0 -5
  215. package/src/eops-skills/honor-the-policies.md +0 -5
@@ -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', 'agentbench-dbbench.json')
17
17
  const DEFAULT_SPLIT = 'dev'
@@ -69,18 +69,20 @@ function rowToTask(row: AgentBenchDbRow, index: number, split: string): BenchTas
69
69
  }
70
70
  return {
71
71
  id: `dbbench-${split}-${index}`,
72
- split,
73
- prompt: [
74
- 'Answer this AgentBench DBBench question using the table below.',
75
- 'Return only the answer value.',
76
- '',
77
- `Question: ${row.description}`,
78
- row.table?.table_name ? `Table: ${row.table.table_name}` : undefined,
79
- columns ? `Columns: ${columns}` : undefined,
80
- sampleRows ? `Rows JSON: ${JSON.stringify(sampleRows)}` : undefined,
81
- ]
82
- .filter(Boolean)
83
- .join('\n'),
72
+ payload: {
73
+ subset: split,
74
+ prompt: [
75
+ 'Answer this AgentBench DBBench question using the table below.',
76
+ 'Return only the answer value.',
77
+ '',
78
+ `Question: ${row.description}`,
79
+ row.table?.table_name ? `Table: ${row.table.table_name}` : undefined,
80
+ columns ? `Columns: ${columns}` : undefined,
81
+ sampleRows ? `Rows JSON: ${JSON.stringify(sampleRows)}` : undefined,
82
+ ]
83
+ .filter(Boolean)
84
+ .join('\n'),
85
+ },
84
86
  metadata: meta as unknown as Record<string, unknown>,
85
87
  }
86
88
  }
@@ -88,7 +90,7 @@ function rowToTask(row: AgentBenchDbRow, index: number, split: string): BenchTas
88
90
  function readMeta(task: BenchTask): AgentBenchMeta {
89
91
  const md = task.metadata
90
92
  if (!md || !Array.isArray(md.labels)) {
91
- throw new Error(`agentbench task ${task.id} missing metadata — loadTasks did not populate it`)
93
+ throw new Error(`agentbench task ${task.id} missing metadata — loadAll did not populate it`)
92
94
  }
93
95
  return md as unknown as AgentBenchMeta
94
96
  }
@@ -120,44 +122,49 @@ async function loadFixtures(opts: LoadOptions, split: string): Promise<BenchTask
120
122
  return selectRows(rows, opts, split)
121
123
  }
122
124
 
123
- export function createAgentBenchAdapter(): BenchmarkAdapter {
125
+ export function createAgentBenchAdapter(): RuntimeBenchmark {
124
126
  const fixturesMode = process.env.AGENTBENCH_FIXTURES === '1'
125
127
 
126
- return {
127
- name: 'agentbench',
128
- output: agentbenchAnswerOutput,
129
-
130
- async preflight() {
131
- if (fixturesMode) return
132
- const dir = agentbenchDir()
133
- if (!dir) {
134
- throw new Error('AGENTBENCH_DIR is required. Fix: clone https://github.com/THUDM/AgentBench and set AGENTBENCH_DIR=/path/to/AgentBench.')
135
- }
136
- await loadJsonl(join(dir, 'data', 'dbbench', `${DEFAULT_SPLIT}.jsonl`))
137
- },
128
+ return runtimeBenchmark({
129
+ id: 'agentbench',
138
130
 
139
- async loadTasks(opts: LoadOptions = {}) {
140
- const split = opts.split ?? DEFAULT_SPLIT
131
+ async loadAll(opts: LoadOptions = {}) {
132
+ const split = opts.subset ?? DEFAULT_SPLIT
141
133
  if (fixturesMode) return loadFixtures(opts, split)
142
134
  const dir = agentbenchDir()
143
135
  if (!dir) throw new Error('AGENTBENCH_DIR is required to load AgentBench DBBench tasks')
144
136
  return selectRows(await loadJsonl(join(dir, 'data', 'dbbench', `${split}.jsonl`)), opts, split)
145
137
  },
146
138
 
147
- async goldArtifact(task: BenchTask) {
148
- return readMeta(task).labels[0]
149
- },
150
-
151
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
139
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
152
140
  const meta = readMeta(task)
153
141
  const got = normalizeAnswer(artifact)
154
142
  const expected = meta.labels.map(normalizeAnswer)
155
143
  const resolved = expected.includes(got)
144
+ const raw = { subset: meta.subset, split: meta.split, expected: meta.labels, got: artifact }
156
145
  return {
157
- resolved,
146
+ passed: resolved,
158
147
  score: resolved ? 1 : 0,
159
- detail: JSON.stringify({ subset: meta.subset, split: meta.split, expected: meta.labels, got: artifact }),
148
+ notes: JSON.stringify(raw),
149
+ raw,
160
150
  }
161
151
  },
162
- }
152
+
153
+ runtime: {
154
+ output: agentbenchAnswerOutput,
155
+
156
+ async preflight() {
157
+ if (fixturesMode) return
158
+ const dir = agentbenchDir()
159
+ if (!dir) {
160
+ throw new Error('AGENTBENCH_DIR is required. Fix: clone https://github.com/THUDM/AgentBench and set AGENTBENCH_DIR=/path/to/AgentBench.')
161
+ }
162
+ await loadJsonl(join(dir, 'data', 'dbbench', `${DEFAULT_SPLIT}.jsonl`))
163
+ },
164
+
165
+ async goldArtifact(task: BenchTask) {
166
+ return readMeta(task).labels[0]
167
+ },
168
+ },
169
+ })
163
170
  }
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Offline AppWorld adapter test. AppWorld has NO committed fixture (task data
3
3
  * exists only after `appworld download data`; fabricating a task would be a fake),
4
- * so loadTasks/judge both require the live engine. This exercises the only offline
4
+ * so loadAll/evaluate both require the live engine. This exercises the only offline
5
5
  * surface (the solution OutputAdapter, goldArtifact) and asserts preflight + the
6
- * engine-backed loadTasks FAIL LOUD with the documented install steps — never a
6
+ * engine-backed loadAll FAIL LOUD with the documented install steps — never a
7
7
  * fabricated task or score. Run: npx tsx --test src/benchmarks/appworld.test.mts
8
8
  */
9
9
  import assert from 'node:assert/strict'
@@ -30,13 +30,13 @@ test('solution OutputAdapter: last fenced ```python wins; fence-less falls back
30
30
 
31
31
  test('goldArtifact is undefined — reference solution ships only inside the engine bundle, not portable', async () => {
32
32
  const a = createAppWorldAdapter()
33
- assert.equal(await a.goldArtifact({ id: 't', prompt: '', metadata: { taskId: 't', split: 'dev' } }), undefined)
33
+ assert.equal(await a.runtime.goldArtifact!({ id: 't', payload: { prompt: '' }, metadata: { taskId: 't', split: 'dev' } }), undefined)
34
34
  })
35
35
 
36
36
  test('preflight passes when installed or FAILS LOUD with the install + download-data fix', async () => {
37
37
  const a = createAppWorldAdapter()
38
38
  try {
39
- await a.preflight()
39
+ await a.runtime.preflight!()
40
40
  } catch (err) {
41
41
  const e = err as Error
42
42
  assert.match(e.message, /pip install appworld/)
@@ -44,13 +44,13 @@ test('preflight passes when installed or FAILS LOUD with the install + download-
44
44
  }
45
45
  })
46
46
 
47
- test('loadTasks either enumerates live engine rows or FAILS LOUD without fabricating tasks', async () => {
47
+ test('loadAll either enumerates live engine rows or FAILS LOUD without fabricating tasks', async () => {
48
48
  const a = createAppWorldAdapter()
49
49
  try {
50
- const tasks = await a.loadTasks({ limit: 1 })
50
+ const tasks = await a.loadAll({ limit: 1 })
51
51
  assert.equal(tasks.length, 1)
52
52
  assert.ok(tasks[0].id.length > 0)
53
- assert.match(tasks[0].prompt, /Solve this by writing Python/)
53
+ assert.match(tasks[0].payload.prompt, /Solve this by writing Python/)
54
54
  } catch (err) {
55
55
  assert.match((err as Error).message, /appworld driver failed|appworld import failed/)
56
56
  }
@@ -6,16 +6,16 @@
6
6
  * evaluator: a driver runs the solution in a fresh `AppWorld(task_id=...)` world,
7
7
  * then `world.evaluate().to_dict()` reports `success` (binary TGC), `num_tests`
8
8
  * (per-requirement total) and the `passes`/`failures` lists. Score =
9
- * passes / num_tests — GRADED; resolved = success. Fully deterministic — no LLM judge.
9
+ * passes / num_tests — GRADED; passed = success. Fully deterministic — no LLM judge.
10
10
  *
11
- * loadTasks enumerates the real task suite via `load_task_ids(split)`
11
+ * loadAll enumerates the real task suite via `load_task_ids(split)`
12
12
  * (train|dev|test_normal|test_challenge); the prompt = `world.task.instruction`.
13
13
  * The OutputAdapter is stream-only, so the worker emits its solution as a fenced
14
14
  * ```python block which the driver executes.
15
15
  *
16
16
  * Requires for a live run: the bench `.venv` with `appworld` installed + the
17
17
  * unpacked engine + downloaded data (`appworld install` ; `appworld download
18
- * data`). preflight + loadTasks + judge all fail loud with the exact step when the
18
+ * data`). preflight + loadAll + evaluate all fail loud with the exact step when the
19
19
  * engine/data is absent — never a fabricated score.
20
20
  */
21
21
 
@@ -30,7 +30,7 @@ import {
30
30
  type ToolSpec,
31
31
  } from '@tangle-network/agent-runtime/kernel'
32
32
  import { benchRoot, preflightVenvImports, runVenvScriptStdin, venvPython } from './_harness'
33
- import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
33
+ import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
34
34
 
35
35
  const DRIVER = join(benchRoot, 'scripts', 'appworld_driver.py')
36
36
 
@@ -66,7 +66,7 @@ const WORKER_CONTRACT = [
66
66
  function readMeta(task: BenchTask): AppWorldMeta {
67
67
  const md = task.metadata
68
68
  if (!md || typeof md.taskId !== 'string') {
69
- throw new Error(`appworld task ${task.id} missing metadata.taskId — loadTasks did not populate it`)
69
+ throw new Error(`appworld task ${task.id} missing metadata.taskId — loadAll did not populate it`)
70
70
  }
71
71
  return md as unknown as AppWorldMeta
72
72
  }
@@ -91,25 +91,12 @@ async function driver(args: string[], input = ''): Promise<unknown> {
91
91
  return parsed
92
92
  }
93
93
 
94
- export function createAppWorldAdapter(): BenchmarkAdapter {
95
- return {
96
- name: 'appworld',
97
- output: appworldSolutionOutput,
98
-
99
- async preflight() {
100
- await preflightVenvImports({
101
- modules: ['appworld'],
102
- requireDocker: false,
103
- fix:
104
- 'Fix: bench/.venv/bin/pip install appworld ; ' +
105
- 'bench/.venv/bin/appworld install ; bench/.venv/bin/appworld download data ' +
106
- '(unpacks the engine + downloads the simulated-app data/tasks). ' +
107
- 'Set APPWORLD_ROOT to the data root if not the default.',
108
- })
109
- },
94
+ export function createAppWorldAdapter(): RuntimeBenchmark {
95
+ return runtimeBenchmark({
96
+ id: 'appworld',
110
97
 
111
- async loadTasks(opts: LoadOptions = {}): Promise<BenchTask[]> {
112
- const split = opts.split ?? DEFAULT_SPLIT
98
+ async loadAll(opts: LoadOptions = {}): Promise<BenchTask[]> {
99
+ const split = opts.subset ?? DEFAULT_SPLIT
113
100
  const out = (await driver([
114
101
  'load',
115
102
  '--split', split,
@@ -118,29 +105,21 @@ export function createAppWorldAdapter(): BenchmarkAdapter {
118
105
  ])) as { tasks?: Array<{ task_id: string; instruction: string }> }
119
106
  const tasks = out.tasks ?? []
120
107
  if (tasks.length === 0) {
121
- throw new Error(`appworld loadTasks returned no tasks for split=${split} ${JSON.stringify(opts)}`)
108
+ throw new Error(`appworld loadAll returned no tasks for split=${split} ${JSON.stringify(opts)}`)
122
109
  }
123
110
  return tasks.map(
124
111
  (t): BenchTask => ({
125
112
  id: t.task_id,
126
- split,
127
- prompt: t.instruction + WORKER_CONTRACT,
113
+ payload: {
114
+ subset: split,
115
+ prompt: t.instruction + WORKER_CONTRACT,
116
+ },
128
117
  metadata: { taskId: t.task_id, split } as unknown as Record<string, unknown>,
129
118
  }),
130
119
  )
131
120
  },
132
121
 
133
- async goldArtifact() {
134
- // Reference solution code ships only for train/dev, and only inside the
135
- // engine's decrypted `.bundle` (it is not a portable string this adapter can
136
- // emit across splits). The test splits are evaluation-only. So verify-judge
137
- // here requires a real solve on a train/dev task through the live engine
138
- // rather than a synthetic gold — returning a fabricated artifact would be a
139
- // fake. Returns undefined.
140
- return undefined
141
- },
142
-
143
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
122
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
144
123
  const meta = readMeta(task)
145
124
  const out = (await driver(['evaluate', '--task-id', meta.taskId, '--split', meta.split], artifact)) as {
146
125
  success?: boolean
@@ -157,22 +136,50 @@ export function createAppWorldAdapter(): BenchmarkAdapter {
157
136
  const total = out.num_tests ?? passes + fails
158
137
  const score = total > 0 ? passes / total : 0
159
138
  // failure_names = WHICH sub-tests failed — the evidence a trace analyst
160
- // steers on. Carried in `detail` so it reaches the verdict's `notes`.
139
+ // steers on. Carried in `raw` (and `notes`) so it reaches the verdict.
161
140
  const failures = Array.isArray(out.failure_names) ? out.failure_names : []
141
+ const raw = {
142
+ taskId: meta.taskId,
143
+ success: out.success,
144
+ passes,
145
+ fails,
146
+ total,
147
+ ...(failures.length ? { failures } : {}),
148
+ }
162
149
  return {
163
- resolved: out.success === true,
150
+ passed: out.success === true,
164
151
  score,
165
- detail: JSON.stringify({
166
- taskId: meta.taskId,
167
- success: out.success,
168
- passes,
169
- fails,
170
- total,
171
- ...(failures.length ? { failures } : {}),
172
- }),
152
+ notes: JSON.stringify(raw),
153
+ raw,
173
154
  }
174
155
  },
175
- }
156
+
157
+ runtime: {
158
+ output: appworldSolutionOutput,
159
+
160
+ async preflight() {
161
+ await preflightVenvImports({
162
+ modules: ['appworld'],
163
+ requireDocker: false,
164
+ fix:
165
+ 'Fix: bench/.venv/bin/pip install appworld ; ' +
166
+ 'bench/.venv/bin/appworld install ; bench/.venv/bin/appworld download data ' +
167
+ '(unpacks the engine + downloads the simulated-app data/tasks). ' +
168
+ 'Set APPWORLD_ROOT to the data root if not the default.',
169
+ })
170
+ },
171
+
172
+ async goldArtifact() {
173
+ // Reference solution code ships only for train/dev, and only inside the
174
+ // engine's decrypted `.bundle` (it is not a portable string this adapter can
175
+ // emit across splits). The test splits are evaluation-only. So verify-judge
176
+ // here requires a real solve on a train/dev task through the live engine
177
+ // rather than a synthetic gold — returning a fabricated artifact would be a
178
+ // fake. Returns undefined.
179
+ return undefined
180
+ },
181
+ },
182
+ })
176
183
  }
177
184
 
178
185
  /**
@@ -193,7 +200,7 @@ export function createAppWorldAdapter(): BenchmarkAdapter {
193
200
  * line 1; everything after line 1 is the steer (an analyst correction, a push
194
201
  * directive) appended to the system prompt — so the existing arms steer this
195
202
  * worker without modification. The artifact is the episode evaluation JSON
196
- * (AppWorld's evaluator ran in-world); judge() parses it, never re-executes.
203
+ * (AppWorld's evaluator ran in-world); evaluate() parses it, never re-executes.
197
204
  */
198
205
 
199
206
  export interface ReactResult {
@@ -488,29 +495,28 @@ const reactEpisodeOutput: OutputAdapter<string> = {
488
495
  },
489
496
  }
490
497
 
491
- export function createAppWorldReactAdapter(): BenchmarkAdapter {
498
+ export function createAppWorldReactAdapter(): RuntimeBenchmark {
492
499
  const base = createAppWorldAdapter()
493
- return {
494
- name: 'appworld-react',
495
- output: reactEpisodeOutput,
496
- preflight: () => base.preflight(),
500
+ return runtimeBenchmark({
501
+ id: 'appworld-react',
497
502
 
498
- async loadTasks(opts: LoadOptions = {}): Promise<BenchTask[]> {
499
- const tasks = await base.loadTasks(opts)
503
+ async loadAll(opts: LoadOptions = {}): Promise<BenchTask[]> {
504
+ const tasks = await base.loadAll(opts)
500
505
  return tasks.map((t) => {
501
506
  const meta = readMeta(t)
502
507
  return {
503
508
  ...t,
504
- // Header carries task identity to the leaf; the body (empty at round 0)
505
- // is the directive slot the arms append their steer into.
506
- prompt: `@appworld-react ${meta.taskId} ${meta.split}\n`,
509
+ payload: {
510
+ ...t.payload,
511
+ // Header carries task identity to the leaf; the body (empty at round 0)
512
+ // is the directive slot the arms append their steer into.
513
+ prompt: `@appworld-react ${meta.taskId} ${meta.split}\n`,
514
+ },
507
515
  }
508
516
  })
509
517
  },
510
518
 
511
- goldArtifact: () => Promise.resolve(undefined),
512
-
513
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
519
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
514
520
  const meta = readMeta(task)
515
521
  let out: ReactResult
516
522
  try {
@@ -528,22 +534,29 @@ export function createAppWorldReactAdapter(): BenchmarkAdapter {
528
534
  const passes = out.passes ?? 0
529
535
  const total = out.num_tests
530
536
  const failures = Array.isArray(out.failure_names) ? out.failure_names : []
537
+ const raw = {
538
+ taskId: meta.taskId,
539
+ success: out.success,
540
+ passes,
541
+ fails: out.fails ?? 0,
542
+ total,
543
+ turns: out.turns,
544
+ ...(failures.length ? { failures } : {}),
545
+ ...(out.transcript ? { transcriptTail: out.transcript.slice(-800) } : {}),
546
+ }
531
547
  return {
532
- resolved: out.success === true,
548
+ passed: out.success === true,
533
549
  score: total > 0 ? passes / total : 0,
534
- detail: JSON.stringify({
535
- taskId: meta.taskId,
536
- success: out.success,
537
- passes,
538
- fails: out.fails ?? 0,
539
- total,
540
- turns: out.turns,
541
- ...(failures.length ? { failures } : {}),
542
- ...(out.transcript ? { transcriptTail: out.transcript.slice(-800) } : {}),
543
- }),
550
+ notes: JSON.stringify(raw),
551
+ raw,
544
552
  }
545
553
  },
546
554
 
547
- leafClient: (c) => appworldToolLoopClient(c),
548
- }
555
+ runtime: {
556
+ output: reactEpisodeOutput,
557
+ preflight: async () => base.runtime.preflight?.(),
558
+ goldArtifact: () => Promise.resolve(undefined),
559
+ worker: (c) => appworldToolLoopClient(c),
560
+ },
561
+ })
549
562
  }
@@ -13,7 +13,7 @@ import { readFile, stat } from 'node:fs/promises'
13
13
  import { join } from 'node:path'
14
14
  import type { OutputAdapter } from '@tangle-network/agent-runtime/kernel'
15
15
  import { benchRoot } from './_harness'
16
- import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
16
+ import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
17
17
 
18
18
  const FIXTURES = join(benchRoot, 'fixtures', 'bfcl.json')
19
19
  const DEFAULT_CATEGORY = 'BFCL_v4_simple_python'
@@ -141,15 +141,17 @@ function rowToTask(row: BfclRow, answer: BfclAnswerRow, category: string): Bench
141
141
  }
142
142
  return {
143
143
  id: row.id,
144
- split: category,
145
- prompt: [
146
- 'Solve this BFCL function-calling task.',
147
- 'Return only JSON: {"function_calls":[{"name":"...","arguments":{...}}]}.',
148
- '',
149
- questionText(row.question),
150
- '',
151
- `Available functions: ${JSON.stringify(row.function, null, 2)}`,
152
- ].join('\n'),
144
+ payload: {
145
+ subset: category,
146
+ prompt: [
147
+ 'Solve this BFCL function-calling task.',
148
+ 'Return only JSON: {"function_calls":[{"name":"...","arguments":{...}}]}.',
149
+ '',
150
+ questionText(row.question),
151
+ '',
152
+ `Available functions: ${JSON.stringify(row.function, null, 2)}`,
153
+ ].join('\n'),
154
+ },
153
155
  metadata: meta as unknown as Record<string, unknown>,
154
156
  }
155
157
  }
@@ -157,14 +159,14 @@ function rowToTask(row: BfclRow, answer: BfclAnswerRow, category: string): Bench
157
159
  function readMeta(task: BenchTask): BfclMeta {
158
160
  const md = task.metadata
159
161
  if (!md || !Array.isArray(md.expected)) {
160
- throw new Error(`BFCL task ${task.id} missing expected calls — loadTasks did not populate metadata`)
162
+ throw new Error(`BFCL task ${task.id} missing expected calls — loadAll did not populate metadata`)
161
163
  }
162
164
  return md as unknown as BfclMeta
163
165
  }
164
166
 
165
167
  function selectTasks(tasks: BenchTask[], opts: LoadOptions): BenchTask[] {
166
168
  let out = tasks
167
- if (opts.split) out = out.filter((task) => task.split === opts.split)
169
+ if (opts.subset) out = out.filter((task) => task.payload.subset === opts.subset)
168
170
  if (opts.ids) {
169
171
  const want = new Set(opts.ids)
170
172
  out = out.filter((task) => want.has(task.id))
@@ -271,7 +273,7 @@ function callMatches(expected: BfclAllowedCall, actual: BfclActualCall): boolean
271
273
  return true
272
274
  }
273
275
 
274
- function scoreCalls(task: BenchTask, artifact: string): BenchScore {
276
+ function scoreCalls(task: BenchTask, artifact: string): BenchEvaluation {
275
277
  const meta = readMeta(task)
276
278
  const actual = extractActualCalls(artifact)
277
279
  const used = new Set<number>()
@@ -286,61 +288,66 @@ function scoreCalls(task: BenchTask, artifact: string): BenchScore {
286
288
  const recall = meta.expected.length === 0 ? 0 : matched / meta.expected.length
287
289
  const precision = actual.length === 0 ? 0 : matched / actual.length
288
290
  const score = recall
291
+ const raw = {
292
+ scoring: meta.scoring,
293
+ category: meta.category,
294
+ expected: meta.expected,
295
+ actual,
296
+ precision,
297
+ recall,
298
+ fullBfclLeaderboardScore: null,
299
+ }
289
300
  return {
290
- resolved: recall === 1 && precision === 1,
301
+ passed: recall === 1 && precision === 1,
291
302
  score,
292
- detail: JSON.stringify({
293
- scoring: meta.scoring,
294
- category: meta.category,
295
- expected: meta.expected,
296
- actual,
297
- precision,
298
- recall,
299
- fullBfclLeaderboardScore: null,
300
- }),
303
+ notes: JSON.stringify(raw),
304
+ raw,
301
305
  }
302
306
  }
303
307
 
304
- export function createBfclAdapter(): BenchmarkAdapter {
308
+ export function createBfclAdapter(): RuntimeBenchmark {
305
309
  const fixturesMode = process.env.BFCL_FIXTURES === '1'
306
310
 
307
- return {
308
- name: 'bfcl',
309
- output: bfclOutput,
311
+ return runtimeBenchmark({
312
+ id: 'bfcl',
310
313
 
311
- async preflight() {
312
- if (fixturesMode) return
313
- const dir = bfclDir()
314
- if (!dir) {
315
- throw new Error(
316
- 'BFCL_DIR is required. Fix: clone https://github.com/ShishirPatil/gorilla, set BFCL_DIR=/path/to/gorilla/berkeley-function-call-leaderboard, and optionally set BFCL_CATEGORY=BFCL_v4_simple_python.',
317
- )
318
- }
319
- const category = bfclCategory()
320
- await assertPath(taskFile(dir, category), 'BFCL task JSONL')
321
- await assertPath(answerFile(dir, category), 'BFCL possible_answer JSONL')
322
- await loadOfficialTasks(dir, { limit: 1 })
323
- },
324
-
325
- async loadTasks(opts: LoadOptions = {}) {
314
+ async loadAll(opts: LoadOptions = {}) {
326
315
  if (fixturesMode) return loadFixtures(opts)
327
316
  const dir = bfclDir()
328
317
  if (!dir) throw new Error('BFCL_DIR is required to load official BFCL rows')
329
318
  return loadOfficialTasks(dir, opts)
330
319
  },
331
320
 
332
- async goldArtifact(task: BenchTask) {
333
- const meta = readMeta(task)
334
- return JSON.stringify({
335
- function_calls: meta.expected.map((call) => ({
336
- name: call.name,
337
- arguments: Object.fromEntries(Object.entries(call.arguments).map(([key, values]) => [key, values[0]])),
338
- })),
339
- }, null, 2)
321
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
322
+ return scoreCalls(task, artifact)
340
323
  },
341
324
 
342
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
343
- return scoreCalls(task, artifact)
325
+ runtime: {
326
+ output: bfclOutput,
327
+
328
+ async preflight() {
329
+ if (fixturesMode) return
330
+ const dir = bfclDir()
331
+ if (!dir) {
332
+ throw new Error(
333
+ 'BFCL_DIR is required. Fix: clone https://github.com/ShishirPatil/gorilla, set BFCL_DIR=/path/to/gorilla/berkeley-function-call-leaderboard, and optionally set BFCL_CATEGORY=BFCL_v4_simple_python.',
334
+ )
335
+ }
336
+ const category = bfclCategory()
337
+ await assertPath(taskFile(dir, category), 'BFCL task JSONL')
338
+ await assertPath(answerFile(dir, category), 'BFCL possible_answer JSONL')
339
+ await loadOfficialTasks(dir, { limit: 1 })
340
+ },
341
+
342
+ async goldArtifact(task: BenchTask) {
343
+ const meta = readMeta(task)
344
+ return JSON.stringify({
345
+ function_calls: meta.expected.map((call) => ({
346
+ name: call.name,
347
+ arguments: Object.fromEntries(Object.entries(call.arguments).map(([key, values]) => [key, values[0]])),
348
+ })),
349
+ }, null, 2)
350
+ },
344
351
  },
345
- }
352
+ })
346
353
  }