@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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""PRBench's own runner (evals.run_evals_off_platform), with a task sample and, when substituted, a judge on its own endpoint.
|
|
2
|
+
|
|
3
|
+
The publisher's runner grades every row of a split (its only limit, `debug`, keeps rows 10:12) and sends the target and the
|
|
4
|
+
judge through one client. Here a sample keeps the first N rows, or the given task ids, of the publisher's own dataset; and a
|
|
5
|
+
substituted judge gets its own client at <judge url>, so the target endpoint never answers as the judge. With
|
|
6
|
+
AGENT_BENCH_MAX_CONCURRENCY the publisher's 64 concurrent requests are capped: its client retries a refused request five
|
|
7
|
+
times within about 20 s and then grades the answer as "N/A", criterion not met, so an endpoint with fewer slots would
|
|
8
|
+
lower the score silently. Loading, prompts, rubric grading and scoring are the publisher's code. Results and caches land in
|
|
9
|
+
the working directory.
|
|
10
|
+
|
|
11
|
+
Usage, with the PRBench checkout on PYTHONPATH: python prbench_run.py <config.yaml> <task count|all> <task ids,> <judge url|->
|
|
12
|
+
"""
|
|
13
|
+
import asyncio
|
|
14
|
+
import os
|
|
15
|
+
import sys
|
|
16
|
+
|
|
17
|
+
import evals
|
|
18
|
+
from config import Config
|
|
19
|
+
from openai import AsyncOpenAI
|
|
20
|
+
|
|
21
|
+
config_path, limit, ids, judge_url = sys.argv[1:5]
|
|
22
|
+
cap = int(os.environ.get('AGENT_BENCH_MAX_CONCURRENCY') or 0)
|
|
23
|
+
if cap > 0:
|
|
24
|
+
publisher_semaphore = asyncio.Semaphore
|
|
25
|
+
|
|
26
|
+
class CappedSemaphore(publisher_semaphore):
|
|
27
|
+
def __init__(self, value=1):
|
|
28
|
+
super().__init__(min(value, cap))
|
|
29
|
+
|
|
30
|
+
asyncio.Semaphore = CappedSemaphore
|
|
31
|
+
wanted = {task for task in ids.split(',') if task}
|
|
32
|
+
publisher_load, publisher_points = evals.load_dataset, evals.get_total_points
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def load_dataset(*args, **kwargs):
|
|
36
|
+
rows = publisher_load(*args, **kwargs)
|
|
37
|
+
if wanted:
|
|
38
|
+
rows = rows.filter(lambda row: row['task'] in wanted)
|
|
39
|
+
if len(rows) != len(wanted):
|
|
40
|
+
sys.exit(f'only {len(rows)} of {len(wanted)} task ids exist in this split')
|
|
41
|
+
return rows
|
|
42
|
+
return rows if limit == 'all' else rows.select(range(min(int(limit), len(rows))))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
judge_client = None if judge_url == '-' else AsyncOpenAI(base_url=judge_url, api_key=os.environ.get('AGENT_BENCH_JUDGE_KEY') or 'loopback')
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
async def get_total_points(client, *args, **kwargs):
|
|
49
|
+
return await publisher_points(judge_client or client, *args, **kwargs)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
evals.load_dataset, evals.get_total_points = load_dataset, get_total_points
|
|
53
|
+
asyncio.run(evals.run_evals_off_platform(Config.from_yaml(config_path)))
|
|
@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os'
|
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
import { fileURLToPath } from 'node:url'
|
|
6
6
|
import { promisify } from 'node:util'
|
|
7
|
+
import { installAcrossPropagation } from '../../scripts/lib/npm-registry.mjs'
|
|
7
8
|
|
|
8
9
|
const execFileAsync = promisify(execFile)
|
|
9
10
|
const benchDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
@@ -163,12 +164,12 @@ writeFileSync(
|
|
|
163
164
|
)
|
|
164
165
|
await writeFile(
|
|
165
166
|
path.join(consumerDir, 'index.ts'),
|
|
166
|
-
"import { createSweBenchAdapter, executePreparedPierCandidate, FilePierCandidateTrialController, resolveAdapter, runBenchmarks, runStagedJudge, StagedJudgeError, type
|
|
167
|
+
"import { createSweBenchAdapter, executePreparedPierCandidate, FilePierCandidateTrialController, resolveAdapter, runBenchmarks, runStagedJudge, StagedJudgeError, type RuntimeBenchmark, type JudgeArtifactReceipt, type PierCandidateTrialController, type PierCandidateTrialHandle, type PierDockerConnection, type StagedPierCandidateExecution } from '@tangle-network/agent-bench'\n\nconst adapter: RuntimeBenchmark = resolveAdapter('swe-bench')\nconst captureAdapter: RuntimeBenchmark = createSweBenchAdapter({ captureEvaluatorArtifacts: ({ taskId, attemptSequence }) => ({ destination: `/tmp/${taskId}/${attemptSequence}` }) })\nconst receipt = undefined as JudgeArtifactReceipt | undefined\nconst staged = undefined as StagedPierCandidateExecution | undefined\nconst trial = undefined as PierCandidateTrialHandle | undefined\nconst controller = undefined as PierCandidateTrialController | undefined\nconst dockerConnection = undefined as PierDockerConnection | undefined\nvoid adapter\nvoid captureAdapter\nvoid receipt\nvoid staged\nvoid trial\nvoid controller\nvoid dockerConnection\nvoid executePreparedPierCandidate\nvoid FilePierCandidateTrialController\nvoid runBenchmarks\nvoid runStagedJudge\nvoid StagedJudgeError\n",
|
|
167
168
|
)
|
|
168
169
|
await writeFile(
|
|
169
170
|
path.join(consumerDir, 'managed-execution.ts'),
|
|
170
171
|
`import assert from 'node:assert/strict'
|
|
171
|
-
import { runBenchmarks, type BenchExecution, type BenchExecutionContext, type BenchPromptResult } from '@tangle-network/agent-bench'
|
|
172
|
+
import { runBenchmarks, runtimeBenchmark, type BenchExecution, type BenchExecutionContext, type BenchPromptResult } from '@tangle-network/agent-bench'
|
|
172
173
|
|
|
173
174
|
const sessions: Array<string | undefined> = []
|
|
174
175
|
let closed = 0
|
|
@@ -179,11 +180,11 @@ const execute: BenchExecution = async (context: BenchExecutionContext) => {
|
|
|
179
180
|
const report = await runBenchmarks({
|
|
180
181
|
benchmarks: ['fixture'], cells: [{ label: 'worker', model: 'fixture' }],
|
|
181
182
|
routerBaseUrl: 'unused', routerKey: 'unused', verifyJudge: false, execute,
|
|
182
|
-
resolveAdapter: () => ({
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
resolveAdapter: () => runtimeBenchmark({
|
|
184
|
+
id: 'fixture',
|
|
185
|
+
loadAll: async () => [{ id: 'task', payload: { prompt: 'initial' } }],
|
|
186
|
+
evaluate: async (_task, artifact) => ({ passed: artifact === 'corrected', score: artifact === 'corrected' ? 1 : 0, raw: {} }),
|
|
187
|
+
runtime: { preflight: async () => {}, goldArtifact: async () => undefined },
|
|
187
188
|
}),
|
|
188
189
|
resolveClient: () => ({
|
|
189
190
|
create: async () => ({
|
|
@@ -211,19 +212,19 @@ assert.deepEqual(report.perTask[0]?.usage, { input: 4, output: 2, costUsd: 0.02
|
|
|
211
212
|
)
|
|
212
213
|
await writeFile(
|
|
213
214
|
path.join(consumerDir, 'index.mjs'),
|
|
214
|
-
"import { resolveAdapter, runBenchmarks } from '@tangle-network/agent-bench'\nimport { ADAPTERS } from '@tangle-network/agent-bench/adapters'\nimport { createCragAdapter } from '@tangle-network/agent-bench/benchmarks/crag'\n\nif (typeof resolveAdapter !== 'function' || typeof runBenchmarks !== 'function') throw new Error('root exports are not executable')\nif (typeof ADAPTERS !== 'object' || typeof createCragAdapter !== 'function') throw new Error('subpath exports are not executable')\nif (resolveAdapter('crag').
|
|
215
|
+
"import { resolveAdapter, runBenchmarks } from '@tangle-network/agent-bench'\nimport { ADAPTERS } from '@tangle-network/agent-bench/adapters'\nimport { createCragAdapter } from '@tangle-network/agent-bench/benchmarks/crag'\n\nif (typeof resolveAdapter !== 'function' || typeof runBenchmarks !== 'function') throw new Error('root exports are not executable')\nif (typeof ADAPTERS !== 'object' || typeof createCragAdapter !== 'function') throw new Error('subpath exports are not executable')\nif (resolveAdapter('crag').id !== 'crag') throw new Error('compiled adapter registry returned the wrong adapter')\nprocess.env.TOOLLM_FIXTURES = '1'\nconst toolLlmTasks = await resolveAdapter('toollm').loadAll({ limit: 1 })\nif (toolLlmTasks.length !== 1 || toolLlmTasks[0]?.id !== '1') throw new Error('packed ToolLLM fixture loading failed')\n",
|
|
215
216
|
)
|
|
216
217
|
await writeFile(
|
|
217
218
|
path.join(consumerDir, 'terminal-bench-absolute-venv.mjs'),
|
|
218
219
|
`import { createTerminalBenchAdapter } from '@tangle-network/agent-bench/benchmarks/terminal-bench'
|
|
219
220
|
|
|
220
221
|
const adapter = createTerminalBenchAdapter()
|
|
221
|
-
const tasks = await adapter.
|
|
222
|
+
const tasks = await adapter.loadAll({ ids: ['installed-absolute-venv'] })
|
|
222
223
|
if (tasks.length !== 1 || tasks[0]?.id !== 'installed-absolute-venv') {
|
|
223
224
|
throw new Error('packed Terminal-Bench adapter did not load through the absolute venv')
|
|
224
225
|
}
|
|
225
|
-
const score = await adapter.
|
|
226
|
-
if (!score.
|
|
226
|
+
const score = await adapter.evaluate(tasks[0], 'echo installed-package-path')
|
|
227
|
+
if (!score.passed || score.score !== 1) {
|
|
227
228
|
throw new Error(\`packed Terminal-Bench adapter did not judge through the absolute venv: \${JSON.stringify(score)}\`)
|
|
228
229
|
}
|
|
229
230
|
`,
|
|
@@ -265,10 +266,12 @@ for name in sorted(expected):
|
|
|
265
266
|
|
|
266
267
|
// Intentionally resolve the declared ranges like a brand-new registry consumer.
|
|
267
268
|
// The preceding frozen install + public typecheck cover the exact bench lockfile.
|
|
268
|
-
await
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
await installAcrossPropagation(() =>
|
|
270
|
+
run(
|
|
271
|
+
'npm',
|
|
272
|
+
['install', '--ignore-scripts', '--no-audit', '--no-fund', '--package-lock=false'],
|
|
273
|
+
consumerDir,
|
|
274
|
+
),
|
|
272
275
|
)
|
|
273
276
|
await run('node', ['index.mjs'], consumerDir)
|
|
274
277
|
await run('node', ['terminal-bench-absolute-venv.mjs'], consumerDir, {
|
|
@@ -280,18 +283,20 @@ for name in sorted(expected):
|
|
|
280
283
|
if (typescript5.stdout.trim() !== `Version ${TYPESCRIPT_5}`) {
|
|
281
284
|
throw new Error(`expected TypeScript ${TYPESCRIPT_5}, received ${typescript5.stdout.trim()}`)
|
|
282
285
|
}
|
|
283
|
-
await
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
286
|
+
await installAcrossPropagation(() =>
|
|
287
|
+
run(
|
|
288
|
+
'npm',
|
|
289
|
+
[
|
|
290
|
+
'install',
|
|
291
|
+
'--ignore-scripts',
|
|
292
|
+
'--no-audit',
|
|
293
|
+
'--no-fund',
|
|
294
|
+
'--no-save',
|
|
295
|
+
'--package-lock=false',
|
|
296
|
+
`typescript@${TYPESCRIPT_6}`,
|
|
297
|
+
],
|
|
298
|
+
consumerDir,
|
|
299
|
+
),
|
|
295
300
|
)
|
|
296
301
|
await run('npm', ['exec', '--', 'tsc', '-p', 'tsconfig.json'], consumerDir)
|
|
297
302
|
const typescript6 = await run('npm', ['exec', '--', 'tsc', '--version'], consumerDir)
|
package/src/adapters.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The benchmark registry — the single source of truth for every wired benchmark.
|
|
3
|
-
* One key per benchmark; the value is its `
|
|
3
|
+
* One key per benchmark; the value is its `RuntimeBenchmark` factory (an agent-eval `BenchmarkAdapter`). `runBenchmarks`
|
|
4
4
|
* (the unifier) maps over this; `run.ts`, `rsi.ts`, and `corpus-replay.mts` all read it
|
|
5
5
|
* here rather than each keeping their own copy.
|
|
6
6
|
*/
|
|
@@ -15,7 +15,6 @@ import { createCadGenBenchAdapter } from './benchmarks/cadgenbench'
|
|
|
15
15
|
import { createCommit0Adapter } from './benchmarks/commit0'
|
|
16
16
|
import { createCragAdapter } from './benchmarks/crag'
|
|
17
17
|
import { createDabstepAdapter } from './benchmarks/dabstep'
|
|
18
|
-
import { createEnterpriseOpsGymAdapter } from './benchmarks/enterpriseops-gym'
|
|
19
18
|
import { createFinResearchBenchAdapter } from './benchmarks/finresearchbench'
|
|
20
19
|
import { createFinsearchcompAdapter } from './benchmarks/finsearchcomp'
|
|
21
20
|
import { createFramesAdapter } from './benchmarks/frames'
|
|
@@ -37,13 +36,13 @@ import { createTerminalBenchAdapter } from './benchmarks/terminal-bench'
|
|
|
37
36
|
import { createToolLlmAdapter } from './benchmarks/toollm'
|
|
38
37
|
import { createTrataHedgeAdapter } from './benchmarks/trata-hedge'
|
|
39
38
|
import { createWebArenaVerifiedAdapter } from './benchmarks/webarena-verified'
|
|
40
|
-
import type {
|
|
39
|
+
import type { RuntimeBenchmark } from './benchmarks/types'
|
|
41
40
|
|
|
42
|
-
export const ADAPTERS: Record<string, () =>
|
|
41
|
+
export const ADAPTERS: Record<string, () => RuntimeBenchmark> = {
|
|
43
42
|
'swe-bench': createSweBenchAdapter,
|
|
44
43
|
'terminal-bench': createTerminalBenchAdapter,
|
|
45
44
|
// Code-benches sharing ./benchmarks/_harness (stage → external evaluator → report).
|
|
46
|
-
//
|
|
45
|
+
// loadAll fetches the REAL dataset (committed fixtures fallback offline); evaluate
|
|
47
46
|
// delegates to the benchmark's own harness and fails loud when it/Docker is absent.
|
|
48
47
|
'aec-bench': createAecBenchAdapter,
|
|
49
48
|
commit0: createCommit0Adapter,
|
|
@@ -59,7 +58,6 @@ export const ADAPTERS: Record<string, () => BenchmarkAdapter> = {
|
|
|
59
58
|
// AppWorld's native interactive protocol — the worker is the in-engine ReAct
|
|
60
59
|
// episode (execution feedback every turn), the mode published baselines use.
|
|
61
60
|
'appworld-react': createAppWorldReactAdapter,
|
|
62
|
-
'enterpriseops-gym': createEnterpriseOpsGymAdapter,
|
|
63
61
|
'cad-design': createCadDesignAdapter,
|
|
64
62
|
// Dimensioned mechanical parts: same OpenSCAD+xvfb judge deps as cad-design, but
|
|
65
63
|
// the spec is metric (bbox / volume / body count / point-in-solid hole probes)
|
|
@@ -90,7 +88,7 @@ export const ADAPTERS: Record<string, () => BenchmarkAdapter> = {
|
|
|
90
88
|
}
|
|
91
89
|
|
|
92
90
|
/** Resolve a benchmark key to its adapter, failing loud with the known keys. */
|
|
93
|
-
export function resolveAdapter(key: string):
|
|
91
|
+
export function resolveAdapter(key: string): RuntimeBenchmark {
|
|
94
92
|
const make = ADAPTERS[key]
|
|
95
93
|
if (!make) throw new Error(`unknown benchmark ${JSON.stringify(key)} (have: ${Object.keys(ADAPTERS).join(', ')})`)
|
|
96
94
|
return make()
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
benchRoot,
|
|
9
9
|
resolveBenchPython,
|
|
10
10
|
runStagedJudge,
|
|
11
|
+
runVenvScriptStdin,
|
|
11
12
|
venvBin,
|
|
12
13
|
venvBinAt,
|
|
13
14
|
} from './_harness'
|
|
@@ -94,7 +95,7 @@ test('runStagedJudge durably captures exact evaluator and process bytes with has
|
|
|
94
95
|
await readFile(join(dir, 'logs/run_evaluation/run/model/task/test_output.txt')),
|
|
95
96
|
perTestBytes,
|
|
96
97
|
)
|
|
97
|
-
return {
|
|
98
|
+
return { passed: true, score: 1, raw: {} }
|
|
98
99
|
},
|
|
99
100
|
})
|
|
100
101
|
|
|
@@ -191,3 +192,19 @@ test('runStagedJudge captures partial evaluator evidence before throwing', async
|
|
|
191
192
|
await rm(scratch, { recursive: true, force: true })
|
|
192
193
|
}
|
|
193
194
|
})
|
|
195
|
+
|
|
196
|
+
test('runVenvScriptStdin reports a driver that exits before reading its input, not the closed pipe', async () => {
|
|
197
|
+
const dir = await mkdtemp(join(tmpdir(), 'stdin-closed-'))
|
|
198
|
+
try {
|
|
199
|
+
const driver = join(dir, 'exits-at-once.mjs')
|
|
200
|
+
await writeFile(driver, "process.stderr.write('engine is not installed'); process.exit(3)\n")
|
|
201
|
+
// Larger than a pipe buffer, so the write is still pending when the driver exits.
|
|
202
|
+
const input = 'x'.repeat(8 * 1024 * 1024)
|
|
203
|
+
await assert.rejects(
|
|
204
|
+
() => runVenvScriptStdin(driver, [], input, { python: process.execPath }),
|
|
205
|
+
/engine is not installed/,
|
|
206
|
+
)
|
|
207
|
+
} finally {
|
|
208
|
+
await rm(dir, { recursive: true, force: true })
|
|
209
|
+
}
|
|
210
|
+
})
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared code-bench harness. The "stage the artifact → run the benchmark's own
|
|
3
3
|
* evaluator in an external process (mkdtemp / execFile / .venv python / Docker)
|
|
4
|
-
* → read its JSON report → {
|
|
4
|
+
* → read its JSON report → { passed, score }" spine that swe-bench,
|
|
5
5
|
* terminal-bench, commit0, programbench and aec-bench all need. Factored out so
|
|
6
6
|
* the Docker/venv/report-reading logic lives in ONE place instead of being
|
|
7
7
|
* copy-pasted per adapter.
|
|
8
8
|
*
|
|
9
9
|
* It owns NO benchmark policy: each adapter passes the argv for its evaluator
|
|
10
|
-
* and a `parseReport` that maps that evaluator's report JSON → a
|
|
10
|
+
* and a `parseReport` that maps that evaluator's report JSON → a BenchEvaluation. The
|
|
11
11
|
* harness owns process spawning, temp-dir lifecycle, large-buffer/timeout config
|
|
12
12
|
* and fail-loud diagnostics.
|
|
13
13
|
*
|
|
@@ -36,7 +36,7 @@ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'nod
|
|
|
36
36
|
import { fileURLToPath } from 'node:url'
|
|
37
37
|
import { promisify } from 'node:util'
|
|
38
38
|
import type {
|
|
39
|
-
|
|
39
|
+
BenchEvaluation,
|
|
40
40
|
JudgeArtifactFileReceipt,
|
|
41
41
|
JudgeArtifactReceipt,
|
|
42
42
|
} from './types'
|
|
@@ -175,6 +175,11 @@ export function runVenvScriptStdin(
|
|
|
175
175
|
stderr += c.toString('utf8')
|
|
176
176
|
})
|
|
177
177
|
child.on('error', (err) => reject(err))
|
|
178
|
+
// A driver that exits before reading its input closes the pipe under a pending write. Its
|
|
179
|
+
// exit code and output, read at close, are the failure; the closed pipe is not a second one.
|
|
180
|
+
child.stdin.on('error', (err: NodeJS.ErrnoException) => {
|
|
181
|
+
if (err.code !== 'EPIPE') reject(err)
|
|
182
|
+
})
|
|
178
183
|
child.on('close', (code) => {
|
|
179
184
|
if (code === 0) resolve(stdout)
|
|
180
185
|
else reject(new Error((stderr || stdout || `exit ${code}`).slice(0, 1500)))
|
|
@@ -200,10 +205,10 @@ export interface StagedRunSpec {
|
|
|
200
205
|
/** Hard timeout for the evaluator (ms); 0 = none. */
|
|
201
206
|
timeoutMs?: number
|
|
202
207
|
/**
|
|
203
|
-
* Read the evaluator's report(s) out of `dir` and map to a
|
|
208
|
+
* Read the evaluator's report(s) out of `dir` and map to a BenchEvaluation. Throws
|
|
204
209
|
* if the expected report is absent/malformed (fail loud — no default score).
|
|
205
210
|
*/
|
|
206
|
-
parseReport(dir: string): Promise<
|
|
211
|
+
parseReport(dir: string): Promise<BenchEvaluation>
|
|
207
212
|
/**
|
|
208
213
|
* Copy the complete evaluator directory plus raw process stdout/stderr to this
|
|
209
214
|
* caller-owned directory before cleanup. The destination must not exist.
|
|
@@ -363,12 +368,12 @@ function processBytes(value: unknown): Buffer {
|
|
|
363
368
|
* cleanup. The evaluator's stdout/stderr is surfaced on failure; the temp dir is
|
|
364
369
|
* always removed in `finally` unless `keepTmp`.
|
|
365
370
|
*/
|
|
366
|
-
export async function runStagedJudge(spec: StagedRunSpec): Promise<
|
|
371
|
+
export async function runStagedJudge(spec: StagedRunSpec): Promise<BenchEvaluation> {
|
|
367
372
|
const dir = await mkdtemp(join(tmpdir(), spec.tmpPrefix))
|
|
368
373
|
let stdout: Buffer<ArrayBufferLike> = Buffer.alloc(0)
|
|
369
374
|
let stderr: Buffer<ArrayBufferLike> = Buffer.alloc(0)
|
|
370
375
|
let evaluatorSucceeded = false
|
|
371
|
-
let score:
|
|
376
|
+
let score: BenchEvaluation | undefined
|
|
372
377
|
let failure: unknown
|
|
373
378
|
try {
|
|
374
379
|
try {
|
|
@@ -12,42 +12,42 @@ process.env.AEC_FIXTURES = '1'
|
|
|
12
12
|
|
|
13
13
|
const id = 'electrical/catenary-sag'
|
|
14
14
|
|
|
15
|
-
test('
|
|
15
|
+
test('loadAll (fixtures) yields self-contained tasks with verifier metadata', async () => {
|
|
16
16
|
const a = createAecBenchAdapter()
|
|
17
|
-
const tasks = await a.
|
|
17
|
+
const tasks = await a.loadAll({ ids: [id] })
|
|
18
18
|
assert.equal(tasks.length, 1)
|
|
19
19
|
const t = tasks[0]
|
|
20
20
|
assert.equal(t.id, id)
|
|
21
|
-
assert.equal(t.
|
|
22
|
-
assert.ok(t.prompt.length > 0, 'prompt is the instruction.md')
|
|
21
|
+
assert.equal(t.payload.subset, 'electrical')
|
|
22
|
+
assert.ok(t.payload.prompt.length > 0, 'prompt is the instruction.md')
|
|
23
23
|
const md = t.metadata as Record<string, unknown>
|
|
24
24
|
assert.equal(typeof md.verifyPy, 'string')
|
|
25
25
|
assert.ok((md.verifyPy as string).length > 0)
|
|
26
26
|
assert.equal(typeof md.goldenPassMd, 'string')
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
test('
|
|
29
|
+
test('loadAll limit slices the fixture set', async () => {
|
|
30
30
|
const a = createAecBenchAdapter()
|
|
31
|
-
const tasks = await a.
|
|
31
|
+
const tasks = await a.loadAll({ limit: 1 })
|
|
32
32
|
assert.equal(tasks.length, 1)
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
test('judge: REAL verify.py — gold resolves with full per-field credit', async () => {
|
|
36
36
|
const a = createAecBenchAdapter()
|
|
37
|
-
const [t] = await a.
|
|
38
|
-
const gold = await a.goldArtifact(t)
|
|
37
|
+
const [t] = await a.loadAll({ ids: [id] })
|
|
38
|
+
const gold = await a.runtime.goldArtifact!(t)
|
|
39
39
|
assert.equal(typeof gold, 'string')
|
|
40
|
-
const score = await a.
|
|
41
|
-
assert.equal(score.
|
|
40
|
+
const score = await a.evaluate(t, gold as string)
|
|
41
|
+
assert.equal(score.passed, true)
|
|
42
42
|
assert.equal(score.score, 1)
|
|
43
|
-
const detail = JSON.parse(score.
|
|
43
|
+
const detail = JSON.parse(score.notes as string) as { fields: Record<string, number> }
|
|
44
44
|
for (const v of Object.values(detail.fields)) assert.equal(v, 1)
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
test('judge: REAL verify.py — empty artifact fails closed to 0 (no fabricated score)', async () => {
|
|
48
48
|
const a = createAecBenchAdapter()
|
|
49
|
-
const [t] = await a.
|
|
50
|
-
const score = await a.
|
|
51
|
-
assert.equal(score.
|
|
49
|
+
const [t] = await a.loadAll({ ids: [id] })
|
|
50
|
+
const score = await a.evaluate(t, '')
|
|
51
|
+
assert.equal(score.passed, false)
|
|
52
52
|
assert.equal(score.score, 0)
|
|
53
53
|
})
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import { readFile } from 'node:fs/promises'
|
|
23
23
|
import { join } from 'node:path'
|
|
24
24
|
import { benchRoot, preflightVenvImports, readJsonReport, runStagedJudge, stageFile, venvPython } from './_harness'
|
|
25
|
-
import
|
|
25
|
+
import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
|
|
26
26
|
|
|
27
27
|
const FIXTURES = join(benchRoot, 'fixtures', 'aec-bench.json')
|
|
28
28
|
|
|
@@ -70,11 +70,13 @@ function recordToTask(rec: AecRecord): BenchTask {
|
|
|
70
70
|
}
|
|
71
71
|
return {
|
|
72
72
|
id: rec.id,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
payload: {
|
|
74
|
+
subset: rec.discipline,
|
|
75
|
+
// instruction.md is fully self-contained and already specifies the exact JSON
|
|
76
|
+
// output schema + the "write to /workspace/output.md" contract the verifier
|
|
77
|
+
// keys off — we pass it through verbatim so the verify.py extractor matches.
|
|
78
|
+
prompt: rec.instruction,
|
|
79
|
+
},
|
|
78
80
|
metadata: meta as unknown as Record<string, unknown>,
|
|
79
81
|
}
|
|
80
82
|
}
|
|
@@ -83,7 +85,7 @@ function readMeta(task: BenchTask): AecMeta {
|
|
|
83
85
|
const md = task.metadata
|
|
84
86
|
// Gold is optional (goldenPassMd may be null) — only the verifier + id are required.
|
|
85
87
|
if (!md || typeof md.verifyPy !== 'string' || typeof md.taskId !== 'string') {
|
|
86
|
-
throw new Error(`aec-bench task ${task.id} missing verifier metadata —
|
|
88
|
+
throw new Error(`aec-bench task ${task.id} missing verifier metadata — loadAll did not populate it`)
|
|
87
89
|
}
|
|
88
90
|
return md as unknown as AecMeta
|
|
89
91
|
}
|
|
@@ -153,7 +155,7 @@ async function fetchInstance(id: string): Promise<AecRecord | null> {
|
|
|
153
155
|
|
|
154
156
|
function selectFixtures(records: AecRecord[], opts: LoadOptions): BenchTask[] {
|
|
155
157
|
let tasks = records.map(recordToTask)
|
|
156
|
-
if (opts.
|
|
158
|
+
if (opts.subset) tasks = tasks.filter((t) => t.payload.subset === opts.subset)
|
|
157
159
|
if (opts.ids) {
|
|
158
160
|
const want = new Set(opts.ids)
|
|
159
161
|
tasks = tasks.filter((t) => want.has(t.id))
|
|
@@ -187,7 +189,7 @@ async function loadLive(opts: LoadOptions): Promise<BenchTask[]> {
|
|
|
187
189
|
}
|
|
188
190
|
const limit = opts.limit ?? DEFAULT_LIMIT
|
|
189
191
|
let ids = await listAllInstances()
|
|
190
|
-
if (opts.
|
|
192
|
+
if (opts.subset) ids = ids.filter((id) => id.startsWith(`${opts.subset}/`))
|
|
191
193
|
const records: AecRecord[] = []
|
|
192
194
|
for (const id of ids) {
|
|
193
195
|
if (records.length >= limit) break
|
|
@@ -201,7 +203,7 @@ async function loadLive(opts: LoadOptions): Promise<BenchTask[]> {
|
|
|
201
203
|
}
|
|
202
204
|
if (records.length === 0) {
|
|
203
205
|
throw new Error(
|
|
204
|
-
`aec-bench
|
|
206
|
+
`aec-bench loadAll found no runnable instances for ${JSON.stringify(opts)} ` +
|
|
205
207
|
`(no tests/verify.py matched the requested split). Set AEC_FIXTURES=1 to run offline.`,
|
|
206
208
|
)
|
|
207
209
|
}
|
|
@@ -217,7 +219,7 @@ async function loadLive(opts: LoadOptions): Promise<BenchTask[]> {
|
|
|
217
219
|
* NOT a silent 0 — verify.py's own except-trap writes reward 0.0, so an absent /
|
|
218
220
|
* non-numeric reward.json is a real bug, surfaced by readJsonReport).
|
|
219
221
|
*/
|
|
220
|
-
async function runVerifier(meta: AecMeta, artifact: string): Promise<
|
|
222
|
+
async function runVerifier(meta: AecMeta, artifact: string): Promise<BenchEvaluation> {
|
|
221
223
|
return runStagedJudge({
|
|
222
224
|
tmpPrefix: 'aecbench-',
|
|
223
225
|
timeoutMs: 120_000,
|
|
@@ -240,51 +242,25 @@ async function runVerifier(meta: AecMeta, artifact: string): Promise<BenchScore>
|
|
|
240
242
|
() => ({}),
|
|
241
243
|
)
|
|
242
244
|
const score = Math.max(0, Math.min(1, reward))
|
|
245
|
+
const raw = { taskId: meta.taskId, discipline: meta.discipline, reward, fields: details }
|
|
243
246
|
return {
|
|
244
|
-
//
|
|
245
|
-
|
|
247
|
+
// passed = full credit (all fields within tolerance), matching aec-bench's perfect_rate.
|
|
248
|
+
passed: score >= 1,
|
|
246
249
|
score,
|
|
247
|
-
|
|
250
|
+
notes: JSON.stringify(raw),
|
|
251
|
+
raw,
|
|
248
252
|
}
|
|
249
253
|
},
|
|
250
254
|
})
|
|
251
255
|
}
|
|
252
256
|
|
|
253
|
-
export function createAecBenchAdapter():
|
|
257
|
+
export function createAecBenchAdapter(): RuntimeBenchmark {
|
|
254
258
|
const fixturesMode = process.env.AEC_FIXTURES === '1'
|
|
255
259
|
|
|
256
|
-
return {
|
|
257
|
-
|
|
260
|
+
return runtimeBenchmark({
|
|
261
|
+
id: 'aec-bench',
|
|
258
262
|
|
|
259
|
-
async
|
|
260
|
-
// The verifier is python3 over the stdlib (math/json/re) — no pip install.
|
|
261
|
-
// Reuse the shared import-probe so the bench venv interpreter is proven to
|
|
262
|
-
// exist + run before any judge spawns verify.py.
|
|
263
|
-
await preflightVenvImports({
|
|
264
|
-
modules: ['math', 'json', 're'],
|
|
265
|
-
requireDocker: false,
|
|
266
|
-
fix: 'Fix: python3 -m venv bench/.venv (verify.py only needs the stdlib — no pip install).',
|
|
267
|
-
})
|
|
268
|
-
if (fixturesMode) {
|
|
269
|
-
await readFile(FIXTURES, 'utf8').catch((err) => {
|
|
270
|
-
throw new Error(`AEC_FIXTURES=1 but ${FIXTURES} unreadable: ${err instanceof Error ? err.message : err}`)
|
|
271
|
-
})
|
|
272
|
-
return
|
|
273
|
-
}
|
|
274
|
-
const res = await fetch(`${RAW}/README.md`, { method: 'HEAD' }).catch((err) => {
|
|
275
|
-
throw new Error(
|
|
276
|
-
`aec-bench preflight failed reaching ${RAW}: ${err instanceof Error ? err.message : err}\n` +
|
|
277
|
-
`Fix: ensure network access to raw.githubusercontent.com, or set AEC_FIXTURES=1 to run offline.`,
|
|
278
|
-
)
|
|
279
|
-
})
|
|
280
|
-
if (!res.ok) {
|
|
281
|
-
throw new Error(
|
|
282
|
-
`aec-bench preflight: ${REPO} README HEAD ${res.status}. Set AEC_FIXTURES=1 to run against committed fixtures.`,
|
|
283
|
-
)
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
|
|
287
|
-
async loadTasks(opts: LoadOptions = {}) {
|
|
263
|
+
async loadAll(opts: LoadOptions = {}) {
|
|
288
264
|
if (fixturesMode) return loadFixtures(opts)
|
|
289
265
|
try {
|
|
290
266
|
return await loadLive(opts)
|
|
@@ -301,19 +277,49 @@ export function createAecBenchAdapter(): BenchmarkAdapter {
|
|
|
301
277
|
}
|
|
302
278
|
},
|
|
303
279
|
|
|
304
|
-
async
|
|
305
|
-
// Gold = the task's own golden_pass.md (scores reward 1.0 through the SAME
|
|
306
|
-
// verify.py the real artifact takes), proving the judge end-to-end. Tasks
|
|
307
|
-
// without a golden_pass.md (non-md ground truth) have no oracle artifact.
|
|
308
|
-
const meta = readMeta(task)
|
|
309
|
-
return meta.goldenPassMd ?? undefined
|
|
310
|
-
},
|
|
311
|
-
|
|
312
|
-
async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
|
|
280
|
+
async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
|
|
313
281
|
const meta = readMeta(task)
|
|
314
282
|
// verify.py fail-closes an empty/unparseable artifact to reward 0.0 itself,
|
|
315
283
|
// so we pass it straight through (no pre-judging here).
|
|
316
284
|
return runVerifier(meta, artifact)
|
|
317
285
|
},
|
|
318
|
-
|
|
286
|
+
|
|
287
|
+
runtime: {
|
|
288
|
+
async preflight() {
|
|
289
|
+
// The verifier is python3 over the stdlib (math/json/re) — no pip install.
|
|
290
|
+
// Reuse the shared import-probe so the bench venv interpreter is proven to
|
|
291
|
+
// exist + run before any judge spawns verify.py.
|
|
292
|
+
await preflightVenvImports({
|
|
293
|
+
modules: ['math', 'json', 're'],
|
|
294
|
+
requireDocker: false,
|
|
295
|
+
fix: 'Fix: python3 -m venv bench/.venv (verify.py only needs the stdlib — no pip install).',
|
|
296
|
+
})
|
|
297
|
+
if (fixturesMode) {
|
|
298
|
+
await readFile(FIXTURES, 'utf8').catch((err) => {
|
|
299
|
+
throw new Error(`AEC_FIXTURES=1 but ${FIXTURES} unreadable: ${err instanceof Error ? err.message : err}`)
|
|
300
|
+
})
|
|
301
|
+
return
|
|
302
|
+
}
|
|
303
|
+
const res = await fetch(`${RAW}/README.md`, { method: 'HEAD' }).catch((err) => {
|
|
304
|
+
throw new Error(
|
|
305
|
+
`aec-bench preflight failed reaching ${RAW}: ${err instanceof Error ? err.message : err}\n` +
|
|
306
|
+
`Fix: ensure network access to raw.githubusercontent.com, or set AEC_FIXTURES=1 to run offline.`,
|
|
307
|
+
)
|
|
308
|
+
})
|
|
309
|
+
if (!res.ok) {
|
|
310
|
+
throw new Error(
|
|
311
|
+
`aec-bench preflight: ${REPO} README HEAD ${res.status}. Set AEC_FIXTURES=1 to run against committed fixtures.`,
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
async goldArtifact(task: BenchTask) {
|
|
317
|
+
// Gold = the task's own golden_pass.md (scores reward 1.0 through the SAME
|
|
318
|
+
// verify.py the real artifact takes), proving the judge end-to-end. Tasks
|
|
319
|
+
// without a golden_pass.md (non-md ground truth) have no oracle artifact.
|
|
320
|
+
const meta = readMeta(task)
|
|
321
|
+
return meta.goldenPassMd ?? undefined
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
})
|
|
319
325
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A ported adapter is agent-eval's `BenchmarkAdapter`: agent-eval's own runner takes it as is, and a real
|
|
3
|
+
* HotpotQA validation item (hotpotqa/hotpot_qa distractor, committed in bench/fixtures) runs through its
|
|
4
|
+
* runtime hooks and the published EM/F1 metric. No model, network or Docker.
|
|
5
|
+
*/
|
|
6
|
+
import assert from 'node:assert/strict'
|
|
7
|
+
import { test } from 'node:test'
|
|
8
|
+
import { benchmarkScenarios } from '@tangle-network/agent-eval/benchmarks'
|
|
9
|
+
import { createHotpotqaAdapter } from './hotpotqa'
|
|
10
|
+
|
|
11
|
+
process.env.HOTPOTQA_FIXTURES = '1'
|
|
12
|
+
|
|
13
|
+
test('a real HotpotQA item runs through the agent-eval contract and the runtime hooks', async () => {
|
|
14
|
+
const adapter = createHotpotqaAdapter()
|
|
15
|
+
await adapter.runtime.preflight!()
|
|
16
|
+
const all = await adapter.loadAll()
|
|
17
|
+
assert.ok(all.length > 1, 'the committed validation rows load')
|
|
18
|
+
|
|
19
|
+
// agent-eval's runner reads the same tasks through loadDataset, each once, in the split assignSplit names.
|
|
20
|
+
const scenarios = await benchmarkScenarios(adapter)
|
|
21
|
+
assert.deepEqual(scenarios.map((s) => s.item.id).sort(), all.map((t) => t.id).sort())
|
|
22
|
+
for (const s of scenarios) assert.equal(s.splitTag, adapter.assignSplit(s.item.id))
|
|
23
|
+
|
|
24
|
+
const id = 'hotpotqa-5a8c7595554299585d9e36b6'
|
|
25
|
+
const [task] = await adapter.loadAll({ ids: [id] })
|
|
26
|
+
assert.equal(task?.id, id)
|
|
27
|
+
assert.match(adapter.runtime.prompt(task!), /Corliss Archer/)
|
|
28
|
+
|
|
29
|
+
const gold = await adapter.runtime.goldArtifact!(task!)
|
|
30
|
+
assert.ok(gold, 'the gold answer serializes through the worker contract')
|
|
31
|
+
const right = await adapter.evaluate(task!, gold!)
|
|
32
|
+
assert.equal(right.passed, true)
|
|
33
|
+
assert.equal(right.score, 1)
|
|
34
|
+
|
|
35
|
+
const wrong = await adapter.evaluate(task!, 'FINAL ANSWER: Secretary of State')
|
|
36
|
+
assert.equal(wrong.passed, false)
|
|
37
|
+
assert.ok(wrong.score < 1)
|
|
38
|
+
})
|