@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.
- package/CHANGELOG.md +20 -0
- package/README.md +24 -2
- package/dist/adapters.d.ts +3 -3
- package/dist/adapters.js +3 -5
- package/dist/adapters.js.map +1 -1
- package/dist/benchmarks/_harness.d.ts +4 -4
- package/dist/benchmarks/_harness.js +5 -2
- package/dist/benchmarks/_harness.js.map +1 -1
- package/dist/benchmarks/aec-bench.d.ts +2 -2
- package/dist/benchmarks/aec-bench.js +49 -42
- package/dist/benchmarks/aec-bench.js.map +1 -1
- package/dist/benchmarks/agentbench.d.ts +2 -2
- package/dist/benchmarks/agentbench.js +41 -34
- package/dist/benchmarks/agentbench.js.map +1 -1
- package/dist/benchmarks/appworld.d.ts +4 -4
- package/dist/benchmarks/appworld.js +67 -53
- package/dist/benchmarks/appworld.js.map +1 -1
- package/dist/benchmarks/bfcl.d.ts +2 -2
- package/dist/benchmarks/bfcl.js +52 -44
- package/dist/benchmarks/bfcl.js.map +1 -1
- package/dist/benchmarks/cad-design.d.ts +2 -2
- package/dist/benchmarks/cad-design.js +53 -44
- package/dist/benchmarks/cad-design.js.map +1 -1
- package/dist/benchmarks/cadbench.d.ts +2 -2
- package/dist/benchmarks/cadbench.js +1 -1
- package/dist/benchmarks/cadgenbench.d.ts +2 -2
- package/dist/benchmarks/cadgenbench.js +1 -1
- package/dist/benchmarks/commit0.d.ts +2 -2
- package/dist/benchmarks/commit0.js +38 -31
- package/dist/benchmarks/commit0.js.map +1 -1
- package/dist/benchmarks/crag.d.ts +2 -2
- package/dist/benchmarks/crag.js +37 -32
- package/dist/benchmarks/crag.js.map +1 -1
- package/dist/benchmarks/dabstep.d.ts +2 -2
- package/dist/benchmarks/dabstep.js +41 -34
- package/dist/benchmarks/dabstep.js.map +1 -1
- package/dist/benchmarks/finresearchbench.d.ts +4 -4
- package/dist/benchmarks/finresearchbench.js +61 -48
- package/dist/benchmarks/finresearchbench.js.map +1 -1
- package/dist/benchmarks/finsearchcomp.d.ts +3 -3
- package/dist/benchmarks/finsearchcomp.js +54 -43
- package/dist/benchmarks/finsearchcomp.js.map +1 -1
- package/dist/benchmarks/frames.d.ts +2 -2
- package/dist/benchmarks/frames.js +66 -51
- package/dist/benchmarks/frames.js.map +1 -1
- package/dist/benchmarks/hotpotqa.d.ts +2 -2
- package/dist/benchmarks/hotpotqa.js +59 -47
- package/dist/benchmarks/hotpotqa.js.map +1 -1
- package/dist/benchmarks/humaneval.d.ts +3 -3
- package/dist/benchmarks/humaneval.js +39 -35
- package/dist/benchmarks/humaneval.js.map +1 -1
- package/dist/benchmarks/mcad-bench.d.ts +2 -2
- package/dist/benchmarks/mcad-bench.js +68 -56
- package/dist/benchmarks/mcad-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-bench.d.ts +2 -2
- package/dist/benchmarks/mcad-cq-bench.js +69 -57
- package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-golds.d.ts +1 -1
- package/dist/benchmarks/mcad-cq-golds.js +1 -1
- package/dist/benchmarks/mcad-cq-golds.js.map +1 -1
- package/dist/benchmarks/mcad-golds.d.ts +1 -1
- package/dist/benchmarks/mcad-golds.js.map +1 -1
- package/dist/benchmarks/mind2web.d.ts +3 -3
- package/dist/benchmarks/mind2web.js +62 -49
- package/dist/benchmarks/mind2web.js.map +1 -1
- package/dist/benchmarks/nomiracl.d.ts +2 -2
- package/dist/benchmarks/nomiracl.js +43 -36
- package/dist/benchmarks/nomiracl.js.map +1 -1
- package/dist/benchmarks/open-rag-bench.d.ts +2 -2
- package/dist/benchmarks/open-rag-bench.js +37 -32
- package/dist/benchmarks/open-rag-bench.js.map +1 -1
- package/dist/benchmarks/programbench.d.ts +2 -2
- package/dist/benchmarks/programbench.js +28 -23
- package/dist/benchmarks/programbench.js.map +1 -1
- package/dist/benchmarks/rag-shared.d.ts +2 -2
- package/dist/benchmarks/rag-shared.js +15 -13
- package/dist/benchmarks/rag-shared.js.map +1 -1
- package/dist/benchmarks/ragbench.d.ts +2 -2
- package/dist/benchmarks/ragbench.js +34 -29
- package/dist/benchmarks/ragbench.js.map +1 -1
- package/dist/benchmarks/simpleqa.d.ts +2 -2
- package/dist/benchmarks/simpleqa.js +62 -51
- package/dist/benchmarks/simpleqa.js.map +1 -1
- package/dist/benchmarks/swe-bench.d.ts +4 -4
- package/dist/benchmarks/swe-bench.js +47 -41
- package/dist/benchmarks/swe-bench.js.map +1 -1
- package/dist/benchmarks/t2-ragbench.d.ts +2 -2
- package/dist/benchmarks/t2-ragbench.js +37 -32
- package/dist/benchmarks/t2-ragbench.js.map +1 -1
- package/dist/benchmarks/tau-bench-shared.d.ts +2 -2
- package/dist/benchmarks/tau-bench-shared.js +43 -36
- package/dist/benchmarks/tau-bench-shared.js.map +1 -1
- package/dist/benchmarks/tau2-bench.d.ts +2 -2
- package/dist/benchmarks/tau2-bench.js.map +1 -1
- package/dist/benchmarks/tau3-banking.d.ts +2 -2
- package/dist/benchmarks/tau3-banking.js.map +1 -1
- package/dist/benchmarks/terminal-bench.d.ts +2 -2
- package/dist/benchmarks/terminal-bench.js +29 -23
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/benchmarks/toollm.d.ts +2 -2
- package/dist/benchmarks/toollm.js +40 -34
- package/dist/benchmarks/toollm.js.map +1 -1
- package/dist/benchmarks/trata-hedge.d.ts +2 -2
- package/dist/benchmarks/trata-hedge.js +46 -38
- package/dist/benchmarks/trata-hedge.js.map +1 -1
- package/dist/benchmarks/types.d.ts +33 -63
- package/dist/benchmarks/types.js +36 -1
- package/dist/benchmarks/types.js.map +1 -0
- package/dist/benchmarks/webarena-verified.d.ts +2 -2
- package/dist/benchmarks/webarena-verified.js +29 -24
- package/dist/benchmarks/webarena-verified.js.map +1 -1
- package/dist/{cadbench-Byr5gO1M.js → cadbench-htzAmMaI.js} +39 -32
- package/dist/cadbench-htzAmMaI.js.map +1 -0
- package/dist/{cadgenbench-Tvk16YKT.js → cadgenbench-BLvEtnxU.js} +28 -22
- package/dist/cadgenbench-BLvEtnxU.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +667 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +9 -8
- package/dist/index.js +61 -56
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
- package/scripts/enterpriseops-gym-run.sh +82 -0
- package/scripts/grade-recorded-evidence.mjs +6 -6
- package/scripts/harvey-lab-judge.py +50 -0
- package/scripts/harvey-lab-run.sh +53 -0
- package/scripts/harvey-lab-sandbox.sh +21 -0
- package/scripts/healthbench-professional-run.sh +30 -0
- package/scripts/healthbench_professional_run.py +112 -0
- package/scripts/mlcr-run.sh +17 -0
- package/scripts/mlcr_run.py +133 -0
- package/scripts/prbench-run.sh +39 -0
- package/scripts/prbench_run.py +53 -0
- package/scripts/verify-packed-consumer.mjs +32 -27
- package/src/adapters.ts +5 -7
- package/src/benchmarks/_harness.test.mts +18 -1
- package/src/benchmarks/_harness.ts +12 -7
- package/src/benchmarks/aec-bench.test.mts +14 -14
- package/src/benchmarks/aec-bench.ts +62 -56
- package/src/benchmarks/agent-eval-contract.test.mts +38 -0
- package/src/benchmarks/agentbench.ts +44 -37
- package/src/benchmarks/appworld.test.mts +7 -7
- package/src/benchmarks/appworld.ts +88 -75
- package/src/benchmarks/bfcl.ts +60 -53
- package/src/benchmarks/cad-design.ts +34 -32
- package/src/benchmarks/cadbench.ts +34 -32
- package/src/benchmarks/cadgenbench.ts +30 -28
- package/src/benchmarks/commit0.test.mts +9 -9
- package/src/benchmarks/commit0.ts +50 -43
- package/src/benchmarks/crag.ts +45 -40
- package/src/benchmarks/dabstep-official.test.mts +8 -8
- package/src/benchmarks/dabstep.test.mts +11 -11
- package/src/benchmarks/dabstep.ts +47 -40
- package/src/benchmarks/external-adapters.test.mts +43 -44
- package/src/benchmarks/finresearchbench.ts +57 -47
- package/src/benchmarks/finsearchcomp.ts +72 -67
- package/src/benchmarks/frames.ts +76 -69
- package/src/benchmarks/hotpotqa.ts +69 -64
- package/src/benchmarks/humaneval.ts +37 -35
- package/src/benchmarks/mcad-bench.test.mts +30 -30
- package/src/benchmarks/mcad-bench.ts +66 -60
- package/src/benchmarks/mcad-cq-bench.ts +69 -63
- package/src/benchmarks/mcad-cq-golds.ts +1 -1
- package/src/benchmarks/mcad-cq.test.mts +40 -40
- package/src/benchmarks/mcad-golds.ts +1 -1
- package/src/benchmarks/mind2web.ts +66 -58
- package/src/benchmarks/nomiracl.ts +53 -46
- package/src/benchmarks/open-rag-bench.ts +47 -42
- package/src/benchmarks/programbench.test.mts +10 -10
- package/src/benchmarks/programbench.ts +38 -33
- package/src/benchmarks/rag-benchmarks.test.mts +31 -31
- package/src/benchmarks/rag-shared.ts +13 -16
- package/src/benchmarks/ragbench.ts +44 -39
- package/src/benchmarks/simpleqa.ts +78 -73
- package/src/benchmarks/swe-bench.test.mts +3 -3
- package/src/benchmarks/swe-bench.ts +66 -61
- package/src/benchmarks/t2-ragbench.ts +47 -42
- package/src/benchmarks/tau-bench-shared.ts +51 -44
- package/src/benchmarks/tau-pin.test.mts +1 -1
- package/src/benchmarks/tau2-bench.ts +2 -2
- package/src/benchmarks/tau3-banking.ts +2 -2
- package/src/benchmarks/terminal-bench.test.mts +3 -3
- package/src/benchmarks/terminal-bench.ts +41 -36
- package/src/benchmarks/toollm.ts +54 -47
- package/src/benchmarks/trata-hedge.ts +57 -52
- package/src/benchmarks/types.ts +70 -59
- package/src/benchmarks/webarena-verified.ts +49 -42
- package/src/cli.ts +74 -0
- package/src/corpus-replay.mts +9 -9
- package/src/examples/benchmark-matrix.mts +13 -10
- package/src/gate-cli.mts +5 -5
- package/src/gate.test.mts +14 -12
- package/src/gate.ts +23 -22
- package/src/index.ts +17 -11
- package/src/published.test.mts +534 -0
- package/src/published.ts +524 -0
- package/src/run-benchmarks-cli.mts +2 -2
- package/src/run-benchmarks.test.mts +58 -48
- package/src/run-benchmarks.ts +64 -57
- package/src/swe-bench-env.ts +6 -6
- package/src/worker.ts +1 -1
- package/dist/benchmarks/enterpriseops-gym.d.ts +0 -6
- package/dist/benchmarks/enterpriseops-gym.js +0 -236
- package/dist/benchmarks/enterpriseops-gym.js.map +0 -1
- package/dist/cadbench-Byr5gO1M.js.map +0 -1
- package/dist/cadgenbench-Tvk16YKT.js.map +0 -1
- package/fixtures/enterpriseops-gym.json +0 -103
- package/scripts/enterpriseops_gym_judge.py +0 -281
- package/src/benchmarks/enterpriseops-gym.test.mts +0 -77
- package/src/benchmarks/enterpriseops-gym.ts +0 -343
- package/src/eops-skills/address-every-subtask.md +0 -5
- package/src/eops-skills/exact-tools-and-args.md +0 -5
- package/src/eops-skills/full-sequence-to-goal.md +0 -5
- package/src/eops-skills/ground-every-value.md +0 -5
- 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
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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 —
|
|
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():
|
|
125
|
+
export function createAgentBenchAdapter(): RuntimeBenchmark {
|
|
124
126
|
const fixturesMode = process.env.AGENTBENCH_FIXTURES === '1'
|
|
125
127
|
|
|
126
|
-
return {
|
|
127
|
-
|
|
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
|
|
140
|
-
const split = opts.
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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('
|
|
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.
|
|
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;
|
|
9
|
+
* passes / num_tests — GRADED; passed = success. Fully deterministic — no LLM judge.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
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 +
|
|
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
|
|
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 —
|
|
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():
|
|
95
|
-
return {
|
|
96
|
-
|
|
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
|
|
112
|
-
const split = opts.
|
|
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
|
|
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
|
-
|
|
127
|
-
|
|
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
|
|
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 `
|
|
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
|
-
|
|
150
|
+
passed: out.success === true,
|
|
164
151
|
score,
|
|
165
|
-
|
|
166
|
-
|
|
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);
|
|
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():
|
|
498
|
+
export function createAppWorldReactAdapter(): RuntimeBenchmark {
|
|
492
499
|
const base = createAppWorldAdapter()
|
|
493
|
-
return {
|
|
494
|
-
|
|
495
|
-
output: reactEpisodeOutput,
|
|
496
|
-
preflight: () => base.preflight(),
|
|
500
|
+
return runtimeBenchmark({
|
|
501
|
+
id: 'appworld-react',
|
|
497
502
|
|
|
498
|
-
async
|
|
499
|
-
const tasks = await base.
|
|
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
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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
|
-
|
|
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
|
-
|
|
548
|
+
passed: out.success === true,
|
|
533
549
|
score: total > 0 ? passes / total : 0,
|
|
534
|
-
|
|
535
|
-
|
|
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
|
-
|
|
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
|
}
|
package/src/benchmarks/bfcl.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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 —
|
|
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.
|
|
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):
|
|
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
|
-
|
|
301
|
+
passed: recall === 1 && precision === 1,
|
|
291
302
|
score,
|
|
292
|
-
|
|
293
|
-
|
|
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():
|
|
308
|
+
export function createBfclAdapter(): RuntimeBenchmark {
|
|
305
309
|
const fixturesMode = process.env.BFCL_FIXTURES === '1'
|
|
306
310
|
|
|
307
|
-
return {
|
|
308
|
-
|
|
309
|
-
output: bfclOutput,
|
|
311
|
+
return runtimeBenchmark({
|
|
312
|
+
id: 'bfcl',
|
|
310
313
|
|
|
311
|
-
async
|
|
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
|
|
333
|
-
|
|
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
|
-
|
|
343
|
-
|
|
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
|
}
|