@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,534 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutomationBench through its publisher's own runner and grader, at the registry's pinned commit, through `runPublished`.
|
|
3
|
+
* A local OpenAI-compatible endpoint stands in for the target model: it plays the gold tool call for
|
|
4
|
+
* `simple.email_sf_contact_phone_update` (update contact 003001's phone to +1-555-0101) or answers with no tool call. The
|
|
5
|
+
* `limited_zapier` toolset offers the task's own tools directly (`zapier` puts them behind search and execute meta-tools).
|
|
6
|
+
* The publisher's grader must pass the first and fail the second. Needs uv and network for the publisher's checkout.
|
|
7
|
+
*/
|
|
8
|
+
import assert from 'node:assert/strict'
|
|
9
|
+
import { execFileSync, spawn } from 'node:child_process'
|
|
10
|
+
import { createServer, type IncomingMessage, type ServerResponse } from 'node:http'
|
|
11
|
+
import type { AddressInfo } from 'node:net'
|
|
12
|
+
import { chmod, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
|
|
13
|
+
import { tmpdir } from 'node:os'
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
import test from 'node:test'
|
|
16
|
+
import { validateRunRecord } from '@tangle-network/agent-eval'
|
|
17
|
+
import { runPublished, PUBLISHED_BENCHMARKS } from './published'
|
|
18
|
+
|
|
19
|
+
const TASK = 'simple.email_sf_contact_phone_update'
|
|
20
|
+
let uv = true
|
|
21
|
+
try { execFileSync('uv', ['--version'], { stdio: 'ignore' }) } catch { uv = false }
|
|
22
|
+
|
|
23
|
+
/** One chat-completions answer: the gold tool call first, then a closing message; or a closing message alone. */
|
|
24
|
+
function standIn(gold: boolean) {
|
|
25
|
+
const requests: Array<{ tools: number; messages: number }> = []
|
|
26
|
+
const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
|
|
27
|
+
let raw = ''
|
|
28
|
+
for await (const chunk of req) raw += chunk
|
|
29
|
+
const body = JSON.parse(raw || '{}') as { model?: string; stream?: boolean; tools?: unknown[]; messages?: Array<{ role: string }> }
|
|
30
|
+
requests.push({ tools: body.tools?.length ?? 0, messages: body.messages?.length ?? 0 })
|
|
31
|
+
const answered = body.messages?.some((message) => message.role === 'tool') ?? false
|
|
32
|
+
const message = gold && !answered
|
|
33
|
+
? { role: 'assistant', content: null, tool_calls: [{ id: 'call_gold_1', type: 'function',
|
|
34
|
+
function: { name: 'salesforce_contact_update', arguments: JSON.stringify({ id: '003001', phone: '+1-555-0101' }) } }] }
|
|
35
|
+
: { role: 'assistant', content: 'Done.' }
|
|
36
|
+
const choice = { index: 0, message, finish_reason: message.tool_calls ? 'tool_calls' : 'stop' }
|
|
37
|
+
const usage = { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 }
|
|
38
|
+
if (body.stream) {
|
|
39
|
+
res.writeHead(200, { 'content-type': 'text/event-stream' })
|
|
40
|
+
const delta = message.tool_calls
|
|
41
|
+
? { role: 'assistant', tool_calls: message.tool_calls.map((call, index) => ({ index, ...call })) }
|
|
42
|
+
: { role: 'assistant', content: message.content }
|
|
43
|
+
res.write(`data: ${JSON.stringify({ id: 'chatcmpl-stand-in', object: 'chat.completion.chunk', model: body.model, choices: [{ index: 0, delta, finish_reason: null }] })}\n\n`)
|
|
44
|
+
res.write(`data: ${JSON.stringify({ id: 'chatcmpl-stand-in', object: 'chat.completion.chunk', model: body.model, choices: [{ index: 0, delta: {}, finish_reason: choice.finish_reason }], usage })}\n\n`)
|
|
45
|
+
res.end('data: [DONE]\n\n')
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
res.writeHead(200, { 'content-type': 'application/json' })
|
|
49
|
+
res.end(JSON.stringify({ id: 'chatcmpl-stand-in', object: 'chat.completion', created: 0, model: body.model, choices: [choice], usage }))
|
|
50
|
+
})
|
|
51
|
+
return { server, requests }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function run(gold: boolean, cacheDir: string) {
|
|
55
|
+
const { server, requests } = standIn(gold)
|
|
56
|
+
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
|
|
57
|
+
const out = await mkdtemp(path.join(tmpdir(), 'agent-bench-automationbench-'))
|
|
58
|
+
try {
|
|
59
|
+
const result = await runPublished('automationbench', 'model:stand-in-model', {
|
|
60
|
+
taskIds: [TASK], out, cacheDir,
|
|
61
|
+
args: ['--domains', 'simple', '--toolset', 'limited_zapier', '--input-cost', '0', '--output-cost', '0'],
|
|
62
|
+
env: { AGENT_BENCH_ROUTER_URL: `http://127.0.0.1:${(server.address() as AddressInfo).port}/v1`, TANGLE_API_KEY: 'local-stand-in' },
|
|
63
|
+
})
|
|
64
|
+
const runRecords = (await readFile(result.runRecords, 'utf8')).trim().split('\n').map((line) => JSON.parse(line) as Record<string, unknown>)
|
|
65
|
+
return { result, requests, record: JSON.parse(await readFile(path.join(out, 'automationbench-run.json'), 'utf8')), runRecords }
|
|
66
|
+
} finally {
|
|
67
|
+
server.close()
|
|
68
|
+
await rm(out, { recursive: true, force: true })
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
test('AutomationBench: the publisher\'s grader passes the gold tool call and fails an answer with none', { skip: uv ? false : 'uv is not installed', timeout: 15 * 60_000 }, async () => {
|
|
73
|
+
const cacheDir = await mkdtemp(path.join(tmpdir(), 'agent-bench-published-cache-'))
|
|
74
|
+
try {
|
|
75
|
+
const gold = await run(true, cacheDir)
|
|
76
|
+
assert.equal(gold.result.tasks, 1)
|
|
77
|
+
assert.deepEqual(gold.result.taskScores, [{ id: TASK, passed: true, score: 1 }])
|
|
78
|
+
assert.equal(gold.result.measured, 'model-shaped')
|
|
79
|
+
assert.equal(gold.result.official, true)
|
|
80
|
+
assert.equal(gold.result.ref, PUBLISHED_BENCHMARKS.automationbench!.ref)
|
|
81
|
+
assert.ok(gold.requests.some((request) => request.tools > 0), 'the publisher runner offered its tools to the endpoint')
|
|
82
|
+
assert.equal(gold.record.passed, 1)
|
|
83
|
+
// One agent-eval RunRecord per task, valid by agent-eval's own validator. The stand-in reports no served snapshot,
|
|
84
|
+
// so the row records the model as unknown rather than inventing one, and keeps the target as its candidate.
|
|
85
|
+
assert.equal(gold.runRecords.length, 1)
|
|
86
|
+
const row = validateRunRecord(gold.runRecords[0])
|
|
87
|
+
assert.equal(row.scenarioId, `automationbench:${TASK}`)
|
|
88
|
+
assert.equal(row.outcome.holdoutScore, 1)
|
|
89
|
+
assert.equal(row.outcome.raw.passed, 1)
|
|
90
|
+
assert.equal(row.candidateId, 'model:stand-in-model')
|
|
91
|
+
assert.deepEqual([row.model, row.terminalOutcome, row.costUsd], ['unknown', 'unknown', null])
|
|
92
|
+
|
|
93
|
+
const none = await run(false, cacheDir)
|
|
94
|
+
assert.equal(none.result.tasks, 1)
|
|
95
|
+
assert.equal(none.result.passed, 0)
|
|
96
|
+
assert.equal(none.result.taskScores[0]!.passed, false)
|
|
97
|
+
} finally {
|
|
98
|
+
await rm(cacheDir, { recursive: true, force: true })
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
test('agent-bench run refuses an app target without the harness that runs its profile', () => {
|
|
103
|
+
const cli = path.join(path.dirname(new URL(import.meta.url).pathname), 'cli.ts')
|
|
104
|
+
let failure: { status: number | null; stderr: string } | undefined
|
|
105
|
+
try {
|
|
106
|
+
execFileSync(process.execPath, ['--import', 'tsx', cli, 'run', 'automationbench', '--target', 'app:gtm-agent'], { stdio: 'pipe', env: { ...process.env, AGENT_BENCH_BRIDGE_KEY: 'unused' } })
|
|
107
|
+
} catch (error) {
|
|
108
|
+
failure = { status: (error as { status: number | null }).status, stderr: String((error as { stderr: Buffer }).stderr) }
|
|
109
|
+
}
|
|
110
|
+
assert.equal(failure?.status, 1)
|
|
111
|
+
assert.match(failure!.stderr, /app:gtm-agent needs @<harness\/model>/)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
/** The CLI Bridge commit that serves caller-executed tools (#397) and cataloged profiles at /profiles/<id>/v1 (#408, #410). */
|
|
115
|
+
const BRIDGE_REF = '857673f6e36cb53b353d0d1c8006bef812669eec'
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A stand-in `claude`: it calls the gold tool through the Bridge's caller MCP server, then finishes the turn. Started as
|
|
119
|
+
* `app-peer`, it first requires the system prompt the app serves, so an app run passes only when the app's profile ran.
|
|
120
|
+
*/
|
|
121
|
+
const standInHarness = (appPrompt: string) => String.raw`#!/usr/bin/env node
|
|
122
|
+
const fs = require('node:fs')
|
|
123
|
+
if (process.argv.includes('--version')) { console.log('own-loop-peer 1.0'); process.exit(0) }
|
|
124
|
+
async function main() {
|
|
125
|
+
const argv = process.argv.slice(2)
|
|
126
|
+
const prompt = argv.includes('--system-prompt') ? argv[argv.indexOf('--system-prompt') + 1] : ''
|
|
127
|
+
if (argv[argv.indexOf('--model') + 1] === 'app-peer' && !prompt.startsWith(${JSON.stringify(appPrompt)})) throw new Error('the app profile did not reach the harness')
|
|
128
|
+
const caller = JSON.parse(fs.readFileSync(argv[argv.indexOf('--mcp-config') + 1], 'utf8')).mcpServers.caller
|
|
129
|
+
const rpc = async (id, method, params) => (await (await fetch(caller.url, { method: 'POST',
|
|
130
|
+
headers: { 'content-type': 'application/json', accept: 'application/json, text/event-stream' },
|
|
131
|
+
body: JSON.stringify({ jsonrpc: '2.0', id, method, params }) })).json()).result
|
|
132
|
+
console.log(JSON.stringify({ type: 'system', subtype: 'init', session_id: 'own-loop-peer' }))
|
|
133
|
+
await rpc(1, 'initialize', { protocolVersion: '2025-03-26', capabilities: {}, clientInfo: { name: 'peer', version: '1' } })
|
|
134
|
+
const tools = (await rpc(2, 'tools/list', {})).tools.map((tool) => tool.name)
|
|
135
|
+
if (!tools.includes('salesforce_contact_update')) throw new Error('the benchmark tools were not offered: ' + tools.join(','))
|
|
136
|
+
const result = await rpc(3, 'tools/call', { name: 'salesforce_contact_update', arguments: { id: '003001', phone: '+1-555-0101' } })
|
|
137
|
+
console.log(JSON.stringify({ type: 'assistant', message: { id: 'msg_done', content: [{ type: 'text', text: 'Updated: ' + result.content[0].text.slice(0, 80) }] } }))
|
|
138
|
+
console.log(JSON.stringify({ type: 'result', subtype: 'success', session_id: 'own-loop-peer', usage: { input_tokens: 0, output_tokens: 0 }, total_cost_usd: 0 }))
|
|
139
|
+
}
|
|
140
|
+
main().catch((error) => { console.error('own-loop peer failed: ' + error.message); process.exitCode = 1 })
|
|
141
|
+
`
|
|
142
|
+
|
|
143
|
+
async function freePort(): Promise<number> {
|
|
144
|
+
const probe = createServer()
|
|
145
|
+
await new Promise<void>((resolve) => probe.listen(0, '127.0.0.1', resolve))
|
|
146
|
+
const { port } = probe.address() as AddressInfo
|
|
147
|
+
await new Promise<void>((resolve) => probe.close(() => resolve()))
|
|
148
|
+
return port
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
test('AutomationBench on profile and app targets: its runner drives a harness loop through a CLI Bridge, and the publisher\'s grader passes the gold tool call', { skip: uv ? false : 'uv is not installed', timeout: 20 * 60_000 }, async () => {
|
|
152
|
+
const root = await mkdtemp(path.join(tmpdir(), 'agent-bench-profile-'))
|
|
153
|
+
const bridge = path.join(root, 'cli-bridge')
|
|
154
|
+
execFileSync('git', ['clone', '--quiet', '--filter=blob:none', '--no-checkout', 'https://github.com/drewstone/cli-bridge.git', bridge])
|
|
155
|
+
execFileSync('git', ['checkout', '--quiet', '--detach', BRIDGE_REF], { cwd: bridge })
|
|
156
|
+
execFileSync('pnpm', ['install', '--frozen-lockfile', '--silent'], { cwd: bridge, stdio: 'inherit' })
|
|
157
|
+
// A stand-in app deployment serving its AgentProfile the way gtm-agent does (/api/tools/profile?definition): a Router
|
|
158
|
+
// model and an MCP server of its own, which an app target records and leaves out, and a skill it keeps.
|
|
159
|
+
const appPrompt = 'You are the bench app, a revenue operations agent.'
|
|
160
|
+
const served = {
|
|
161
|
+
name: 'bench-app', version: '1.0.0', model: { default: 'gemini-3.7-flash' }, prompt: { systemPrompt: `${appPrompt} Keep CRM records exact.` },
|
|
162
|
+
mcp: { 'crm-sync': { transport: 'stdio', command: 'node', args: ['./scripts/mcp/crm-sync.mjs'] } },
|
|
163
|
+
resources: { skills: [{ kind: 'inline', name: 'crm-hygiene', content: '---\nname: crm-hygiene\ndescription: Keep CRM fields exact\n---\nCheck ids before updating.\n' }] },
|
|
164
|
+
}
|
|
165
|
+
const appServer = createServer((_req, res) => { res.writeHead(200, { 'content-type': 'application/json' }); res.end(JSON.stringify(served)) })
|
|
166
|
+
await new Promise<void>((resolve) => appServer.listen(0, '127.0.0.1', resolve))
|
|
167
|
+
const claude = path.join(root, 'claude')
|
|
168
|
+
await writeFile(claude, standInHarness(appPrompt))
|
|
169
|
+
await chmod(claude, 0o755)
|
|
170
|
+
const profiles = path.join(root, 'profiles')
|
|
171
|
+
const port = await freePort()
|
|
172
|
+
// Its own process group, so the whole pnpm -> tsx -> node chain stops with it; no pipe keeps this test's process alive.
|
|
173
|
+
const server = spawn('pnpm', ['exec', 'tsx', 'src/server.ts'], { cwd: bridge, detached: true, stdio: ['ignore', 'ignore', 'inherit'], env: { ...process.env,
|
|
174
|
+
TSX_TSCONFIG_PATH: path.join(bridge, 'tsconfig.json'), SANDBOX_PROFILES_DIR: profiles,
|
|
175
|
+
BRIDGE_HOST: '127.0.0.1', BRIDGE_PORT: String(port), BRIDGE_DATA_DIR: path.join(root, 'state'), BRIDGE_BACKENDS: 'claude', BRIDGE_JAIL_MODE: 'off', CLAUDE_BIN: claude } })
|
|
176
|
+
const cacheDir = await mkdtemp(path.join(tmpdir(), 'agent-bench-published-cache-'))
|
|
177
|
+
const out = await mkdtemp(path.join(tmpdir(), 'agent-bench-profile-out-'))
|
|
178
|
+
try {
|
|
179
|
+
for (let ready = false, attempt = 0; !ready; attempt++) {
|
|
180
|
+
assert.ok(attempt < 120, 'the CLI Bridge did not answer /health within 60 s')
|
|
181
|
+
ready = await fetch(`http://127.0.0.1:${port}/health`).then((response) => response.ok, () => false)
|
|
182
|
+
if (!ready) await new Promise((resolve) => setTimeout(resolve, 500))
|
|
183
|
+
}
|
|
184
|
+
const options = {
|
|
185
|
+
taskIds: [TASK], cacheDir,
|
|
186
|
+
args: ['--domains', 'simple', '--toolset', 'limited_zapier', '--input-cost', '0', '--output-cost', '0'],
|
|
187
|
+
env: { AGENT_BENCH_BRIDGE_URL: `http://127.0.0.1:${port}/v1`, AGENT_BENCH_BRIDGE_KEY: 'loopback', AGENT_BENCH_BRIDGE_PROFILES_DIR: profiles },
|
|
188
|
+
}
|
|
189
|
+
const result = await runPublished('automationbench', 'profile:claude-code/own-loop-peer', { ...options, out: path.join(out, 'profile') })
|
|
190
|
+
assert.equal(result.measured, 'own-loop')
|
|
191
|
+
assert.deepEqual(result.taskScores, [{ id: TASK, passed: true, score: 1 }])
|
|
192
|
+
|
|
193
|
+
const apps = JSON.stringify({ 'bench-app': `http://127.0.0.1:${(appServer.address() as AddressInfo).port}/api/tools/profile?definition` })
|
|
194
|
+
const app = await runPublished('automationbench', 'app:bench-app@claude-code/app-peer', { ...options, env: { ...options.env, AGENT_BENCH_APPS: apps }, out: path.join(out, 'app') })
|
|
195
|
+
assert.equal(app.measured, 'own-loop')
|
|
196
|
+
assert.deepEqual(app.taskScores, [{ id: TASK, passed: true, score: 1 }])
|
|
197
|
+
assert.equal(app.model, 'claude-code/app-peer')
|
|
198
|
+
assert.equal(app.app?.app, 'bench-app')
|
|
199
|
+
assert.equal(app.app?.profileVersion, '1.0.0')
|
|
200
|
+
assert.deepEqual(app.app?.productionModel, served.model)
|
|
201
|
+
assert.deepEqual(app.app?.omittedMcp, ['crm-sync'])
|
|
202
|
+
assert.match(app.app!.profileDigest, /^sha256:[0-9a-f]{64}$/)
|
|
203
|
+
|
|
204
|
+
// The same profile from a file (an export from a checkout, or an optimizer's candidate) runs as the same profile.
|
|
205
|
+
const file = path.join(root, 'bench-app-profile.json')
|
|
206
|
+
await writeFile(file, JSON.stringify(served))
|
|
207
|
+
const fromFile = await runPublished('automationbench', 'app:bench-app@claude-code/app-peer', { ...options, env: { ...options.env, AGENT_BENCH_APPS: JSON.stringify({ 'bench-app': file }) }, out: path.join(out, 'app-file') })
|
|
208
|
+
assert.deepEqual(fromFile.taskScores, [{ id: TASK, passed: true, score: 1 }])
|
|
209
|
+
assert.equal(fromFile.app?.profileDigest, app.app?.profileDigest)
|
|
210
|
+
assert.equal(fromFile.app?.profileUrl, file)
|
|
211
|
+
} finally {
|
|
212
|
+
appServer.close()
|
|
213
|
+
const exited = new Promise((resolve) => server.once('exit', resolve))
|
|
214
|
+
try { process.kill(-server.pid!, 'SIGTERM') } catch { /* already gone */ }
|
|
215
|
+
const stopped = await Promise.race([exited.then(() => true), new Promise((resolve) => setTimeout(() => resolve(false), 10_000))])
|
|
216
|
+
if (!stopped) try { process.kill(-server.pid!, 'SIGKILL') } catch { /* already gone */ }
|
|
217
|
+
server.unref()
|
|
218
|
+
await rm(root, { recursive: true, force: true })
|
|
219
|
+
await rm(cacheDir, { recursive: true, force: true })
|
|
220
|
+
await rm(out, { recursive: true, force: true })
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
/** teams/oracle: an audio call from James Wilson to Alice Johnson, and a 'Project Updates' channel; two SQL state verifiers. */
|
|
225
|
+
const EOG_TASK = 'task_20251121_134729_533_464ee3e0_2dcf2712'
|
|
226
|
+
let docker = true
|
|
227
|
+
try { execFileSync('docker', ['info'], { stdio: 'ignore' }) } catch { docker = false }
|
|
228
|
+
|
|
229
|
+
/** The gold calls one at a time (create_call, then create_channel), named from the tools the runner offers; or no tool call. */
|
|
230
|
+
function gymStandIn(gold: boolean) {
|
|
231
|
+
const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
|
|
232
|
+
let raw = ''
|
|
233
|
+
for await (const chunk of req) raw += chunk
|
|
234
|
+
const body = JSON.parse(raw || '{}') as { model?: string; tools?: Array<{ function?: { name?: string } }>; messages?: Array<{ role: string }> }
|
|
235
|
+
const names = (body.tools ?? []).map((tool) => tool.function?.name ?? '')
|
|
236
|
+
const done = body.messages?.filter((message) => message.role === 'tool').length ?? 0
|
|
237
|
+
const step = gold ? [
|
|
238
|
+
{ name: names.find((name) => name.endsWith('create_call')), args: { callbackUri: 'https://example.com/callback', requestedModalities: ['audio'],
|
|
239
|
+
mediaConfig: { _odata_type: '#microsoft.graph.serviceHostedMediaConfig' }, targets: [{ identity: { user: { id: 'alice.johnson', displayName: 'Alice Johnson' } } }],
|
|
240
|
+
// The gym stores `source` as given (null when omitted); its seeded calls name the caller as a user identity.
|
|
241
|
+
source: { identity: { user: { id: 'james.wilson', displayName: 'James Wilson' } } } } },
|
|
242
|
+
{ name: names.find((name) => name.endsWith('create_channel')), args: { teamId: 'team_techcorp_001', displayName: 'Project Updates', membershipType: 'standard' } },
|
|
243
|
+
][done] : undefined
|
|
244
|
+
const message = step?.name
|
|
245
|
+
? { role: 'assistant', content: null, tool_calls: [{ id: `call_gold_${done}`, type: 'function', function: { name: step.name, arguments: JSON.stringify(step.args) } }] }
|
|
246
|
+
: { role: 'assistant', content: 'Done.' }
|
|
247
|
+
res.writeHead(200, { 'content-type': 'application/json' })
|
|
248
|
+
res.end(JSON.stringify({ id: 'chatcmpl-gym', object: 'chat.completion', created: 0, model: body.model,
|
|
249
|
+
choices: [{ index: 0, message, finish_reason: 'tool_calls' in message ? 'tool_calls' : 'stop' }], usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 } }))
|
|
250
|
+
})
|
|
251
|
+
return server
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
test('EnterpriseOps-Gym: the publisher\'s SQL verifiers pass the gold calls and fail an answer with none', { skip: uv && docker ? false : 'uv and docker are required', timeout: 40 * 60_000 }, async () => {
|
|
255
|
+
const cacheDir = await mkdtemp(path.join(tmpdir(), 'agent-bench-published-cache-'))
|
|
256
|
+
try {
|
|
257
|
+
for (const gold of [true, false]) {
|
|
258
|
+
const server = gymStandIn(gold)
|
|
259
|
+
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
|
|
260
|
+
const out = await mkdtemp(path.join(tmpdir(), 'agent-bench-eog-'))
|
|
261
|
+
try {
|
|
262
|
+
const result = await runPublished('enterpriseops-gym', 'model:stand-in-model', {
|
|
263
|
+
taskIds: [EOG_TASK], out, cacheDir, args: ['--domain', 'teams', '--mode', 'oracle', '--concurrency', '1'],
|
|
264
|
+
env: { AGENT_BENCH_ROUTER_URL: `http://127.0.0.1:${(server.address() as AddressInfo).port}/v1`, TANGLE_API_KEY: 'local-stand-in' },
|
|
265
|
+
})
|
|
266
|
+
assert.equal(result.tasks, 1, JSON.stringify(result.taskScores))
|
|
267
|
+
assert.equal(result.taskScores[0]!.id, EOG_TASK)
|
|
268
|
+
assert.equal(result.taskScores[0]!.passed, gold, JSON.stringify(result.taskScores[0]))
|
|
269
|
+
assert.equal(result.measured, 'model-shaped')
|
|
270
|
+
} finally {
|
|
271
|
+
server.closeAllConnections()
|
|
272
|
+
server.close()
|
|
273
|
+
await rm(out, { recursive: true, force: true })
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
} finally {
|
|
277
|
+
await rm(cacheDir, { recursive: true, force: true })
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
/** firm-knowledge/tasks/012: one criterion, graded by the judge on the agent's response.md. */
|
|
282
|
+
const HARVEY_TASK = 'firm-knowledge/tasks/012'
|
|
283
|
+
const HARVEY_ANSWER = 'The firm has not done a financing with a springing lien.'
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* One local endpoint plays the target and the substituted judge. A request offering tools is the target in Harvey's agent
|
|
287
|
+
* loop: with `gold` it writes response.md through Harvey's `write` tool, then calls `finish`; without, it finishes at once.
|
|
288
|
+
* A request with no tools is the judge (bridge/stand-in-judge): it passes the criterion only when the publisher's grader
|
|
289
|
+
* put the agent's answer into its prompt.
|
|
290
|
+
*/
|
|
291
|
+
function harveyStandIn(gold: boolean) {
|
|
292
|
+
const seen = { target: 0, judge: 0, answerJudged: false }
|
|
293
|
+
const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
|
|
294
|
+
let raw = ''
|
|
295
|
+
for await (const chunk of req) raw += chunk
|
|
296
|
+
const body = JSON.parse(raw || '{}') as { model?: string; tools?: Array<{ function?: { name?: string } }>; messages?: Array<{ role: string; content?: unknown }> }
|
|
297
|
+
let message: Record<string, unknown>
|
|
298
|
+
if (body.tools?.length) {
|
|
299
|
+
seen.target++
|
|
300
|
+
const done = body.messages?.filter((entry) => entry.role === 'tool').length ?? 0
|
|
301
|
+
const calls = gold ? [['write', { file_path: 'response.md', content: HARVEY_ANSWER }], ['finish', { summary: 'answered', deliverables: ['response.md'] }]] : [['finish', { summary: 'no answer' }]]
|
|
302
|
+
const [name, args] = calls[Math.min(done, calls.length - 1)]!
|
|
303
|
+
message = { role: 'assistant', content: null, tool_calls: [{ id: `call_${done}`, type: 'function', function: { name, arguments: JSON.stringify(args) } }] }
|
|
304
|
+
} else {
|
|
305
|
+
seen.judge++
|
|
306
|
+
const prompt = JSON.stringify(body.messages ?? [])
|
|
307
|
+
seen.answerJudged ||= prompt.includes(HARVEY_ANSWER)
|
|
308
|
+
message = { role: 'assistant', content: JSON.stringify({ reasoning: 'stand-in judge', verdict: prompt.includes(HARVEY_ANSWER) ? 'pass' : 'fail' }) }
|
|
309
|
+
}
|
|
310
|
+
res.writeHead(200, { 'content-type': 'application/json' })
|
|
311
|
+
res.end(JSON.stringify({ id: 'chatcmpl-harvey', object: 'chat.completion', created: 0, model: body.model,
|
|
312
|
+
choices: [{ index: 0, message, finish_reason: 'tool_calls' in message ? 'tool_calls' : 'stop' }], usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 } }))
|
|
313
|
+
})
|
|
314
|
+
return { server, seen }
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// The publisher checkout is about 5 GB with its sandbox image, so this test uses the shared cache (~/.cache/agent-bench/published).
|
|
318
|
+
test('Harvey LAB: the publisher\'s harness and rubric grader, with a substituted judge, pass the written answer and fail none', { skip: uv && docker ? false : 'uv and docker are required', timeout: 40 * 60_000 }, async () => {
|
|
319
|
+
for (const gold of [true, false]) {
|
|
320
|
+
const { server, seen } = harveyStandIn(gold)
|
|
321
|
+
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
|
|
322
|
+
const out = await mkdtemp(path.join(tmpdir(), 'agent-bench-harvey-'))
|
|
323
|
+
const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}/v1`
|
|
324
|
+
try {
|
|
325
|
+
const result = await runPublished('harvey-lab', 'model:stand-in-model', {
|
|
326
|
+
taskIds: [HARVEY_TASK], out, judge: 'bridge/stand-in-judge', args: ['--max-turns', '5'],
|
|
327
|
+
env: { AGENT_BENCH_ROUTER_URL: url, TANGLE_API_KEY: 'local-stand-in', AGENT_BENCH_JUDGE_URL: url },
|
|
328
|
+
})
|
|
329
|
+
assert.equal(result.tasks, 1, JSON.stringify(result.taskScores))
|
|
330
|
+
assert.equal(result.taskScores[0]!.id, HARVEY_TASK)
|
|
331
|
+
assert.equal(result.taskScores[0]!.passed, gold, JSON.stringify(result.taskScores[0]))
|
|
332
|
+
assert.equal(result.official, false)
|
|
333
|
+
assert.equal(result.judge, 'bridge/stand-in-judge')
|
|
334
|
+
assert.equal(result.publisherJudge, PUBLISHED_BENCHMARKS['harvey-lab']!.judge)
|
|
335
|
+
// Without a deliverable the grader may fail the criterion before any judge call.
|
|
336
|
+
assert.ok(seen.target > 0 && (!gold || seen.judge > 0), JSON.stringify(seen))
|
|
337
|
+
assert.equal(seen.answerJudged, gold, 'the judge saw the agent\'s answer only when the agent wrote one')
|
|
338
|
+
// The publisher's per-criterion verdict reaches the run's raw detail and its RunRecord (what an optimizer reads).
|
|
339
|
+
assert.equal(result.taskScores[0]!.raw?.['crit.C-001'], gold ? 1 : 0)
|
|
340
|
+
const row = validateRunRecord(JSON.parse((await readFile(result.runRecords, 'utf8')).trim()))
|
|
341
|
+
assert.equal(row.outcome.raw['crit.C-001'], gold ? 1 : 0)
|
|
342
|
+
} finally {
|
|
343
|
+
server.closeAllConnections()
|
|
344
|
+
server.close()
|
|
345
|
+
await rm(out, { recursive: true, force: true })
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* PRBench: one local Responses API endpoint plays the target (stand-in-model) and the substituted judge (stand-in-judge).
|
|
352
|
+
* The target answers the first legal task with a marked answer, or with none; the judge, called once per rubric criterion
|
|
353
|
+
* by the publisher's grader, meets a criterion only when the conversation it grades holds the marked answer.
|
|
354
|
+
*/
|
|
355
|
+
const PRBENCH_ANSWER = 'AGENT-BENCH-PRBENCH-ANSWER: the analysis the client asked for.'
|
|
356
|
+
|
|
357
|
+
function prbenchStandIn(answered: boolean) {
|
|
358
|
+
const seen = { target: 0, judge: 0 }
|
|
359
|
+
const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
|
|
360
|
+
let raw = ''
|
|
361
|
+
for await (const chunk of req) raw += chunk
|
|
362
|
+
const body = JSON.parse(raw || '{}') as { model?: string; input?: unknown }
|
|
363
|
+
let text: string
|
|
364
|
+
if (body.model === 'stand-in-judge') {
|
|
365
|
+
seen.judge++
|
|
366
|
+
text = `{"explanation": "stand-in judge", "criteria_met": ${JSON.stringify(body.input).includes('AGENT-BENCH-PRBENCH-ANSWER')}}`
|
|
367
|
+
} else {
|
|
368
|
+
seen.target++
|
|
369
|
+
text = answered ? PRBENCH_ANSWER : 'I cannot help with that.'
|
|
370
|
+
}
|
|
371
|
+
res.writeHead(200, { 'content-type': 'application/json' })
|
|
372
|
+
res.end(JSON.stringify({ id: 'resp_stand_in', object: 'response', created_at: 0, model: body.model, status: 'completed',
|
|
373
|
+
output: [{ type: 'message', id: 'msg_stand_in', role: 'assistant', status: 'completed', content: [{ type: 'output_text', text, annotations: [] }] }],
|
|
374
|
+
usage: { input_tokens: 10, output_tokens: 5, total_tokens: 15 } }))
|
|
375
|
+
})
|
|
376
|
+
return { server, seen }
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
test('PRBench: the publisher\'s rubric grader, with a substituted judge, scores the answered task above zero and the unanswered at zero', { skip: uv ? false : 'uv is not installed', timeout: 30 * 60_000 }, async () => {
|
|
380
|
+
const cacheDir = await mkdtemp(path.join(tmpdir(), 'agent-bench-published-cache-'))
|
|
381
|
+
try {
|
|
382
|
+
const scores: number[] = []
|
|
383
|
+
for (const answered of [true, false]) {
|
|
384
|
+
const { server, seen } = prbenchStandIn(answered)
|
|
385
|
+
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
|
|
386
|
+
const out = await mkdtemp(path.join(tmpdir(), 'agent-bench-prbench-'))
|
|
387
|
+
const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}/v1`
|
|
388
|
+
try {
|
|
389
|
+
const result = await runPublished('prbench', 'model:stand-in-model', {
|
|
390
|
+
tasks: 1, out, cacheDir, judge: 'bridge/stand-in-judge', args: ['--split', 'legal', '--concurrency', '2'],
|
|
391
|
+
env: { AGENT_BENCH_ROUTER_URL: url, TANGLE_API_KEY: 'local-stand-in', AGENT_BENCH_JUDGE_URL: url },
|
|
392
|
+
})
|
|
393
|
+
assert.equal(result.tasks, 1, JSON.stringify(result.taskScores))
|
|
394
|
+
assert.equal(result.official, false)
|
|
395
|
+
assert.equal(result.publisherJudge, PUBLISHED_BENCHMARKS.prbench!.judge)
|
|
396
|
+
assert.ok(seen.target === 1 && seen.judge > 1, JSON.stringify(seen))
|
|
397
|
+
scores.push(result.taskScores[0]!.score)
|
|
398
|
+
} finally {
|
|
399
|
+
server.closeAllConnections()
|
|
400
|
+
server.close()
|
|
401
|
+
await rm(out, { recursive: true, force: true })
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
assert.ok(scores[0]! > 0, `the answered task scored ${scores[0]}`)
|
|
405
|
+
assert.equal(scores[1], 0)
|
|
406
|
+
} finally {
|
|
407
|
+
await rm(cacheDir, { recursive: true, force: true })
|
|
408
|
+
}
|
|
409
|
+
})
|
|
410
|
+
|
|
411
|
+
/** Chat completions for both the target and a substituted judge. The judge meets each rubric item the answered run should
|
|
412
|
+
* meet (positive points) and, for the unanswered run, only the undesirable ones (negative points). The rubric item is the
|
|
413
|
+
* last `[points] criterion` line of the publisher's grader prompt. */
|
|
414
|
+
function healthbenchStandIn(answered: boolean) {
|
|
415
|
+
const seen = { target: 0, judge: 0 }
|
|
416
|
+
const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
|
|
417
|
+
let raw = ''
|
|
418
|
+
for await (const chunk of req) raw += chunk
|
|
419
|
+
const body = JSON.parse(raw || '{}') as { model?: string; messages?: Array<{ content?: unknown }> }
|
|
420
|
+
let text: string
|
|
421
|
+
if (body.model === 'stand-in-judge') {
|
|
422
|
+
seen.judge++
|
|
423
|
+
const prompt = String(body.messages?.at(-1)?.content ?? '')
|
|
424
|
+
const points = Number([...prompt.matchAll(/\n\[(-?\d+(?:\.\d+)?)\] /g)].at(-1)?.[1] ?? Number.NaN)
|
|
425
|
+
text = `{"explanation": "stand-in judge", "criteria_met": ${answered ? points > 0 : points < 0}}`
|
|
426
|
+
} else {
|
|
427
|
+
seen.target++
|
|
428
|
+
text = answered ? 'A considered clinical answer.' : 'I cannot help with that.'
|
|
429
|
+
}
|
|
430
|
+
res.writeHead(200, { 'content-type': 'application/json' })
|
|
431
|
+
res.end(JSON.stringify({ id: 'chatcmpl-stand-in', object: 'chat.completion', created: 0, model: body.model,
|
|
432
|
+
choices: [{ index: 0, message: { role: 'assistant', content: text }, finish_reason: 'stop' }],
|
|
433
|
+
// Usage as a CLI Bridge answers it, without OpenAI's cached and reasoning token details.
|
|
434
|
+
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 } }))
|
|
435
|
+
})
|
|
436
|
+
return { server, seen }
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
test('HealthBench Professional: the publisher\'s rubric grader, with a substituted judge, passes the answer that meets every criterion and scores the other at zero', { skip: uv ? false : 'uv is not installed', timeout: 30 * 60_000 }, async () => {
|
|
440
|
+
const cacheDir = await mkdtemp(path.join(tmpdir(), 'agent-bench-published-cache-'))
|
|
441
|
+
try {
|
|
442
|
+
const scores: Array<{ passed: boolean; score: number }> = []
|
|
443
|
+
for (const answered of [true, false]) {
|
|
444
|
+
const { server, seen } = healthbenchStandIn(answered)
|
|
445
|
+
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
|
|
446
|
+
const out = await mkdtemp(path.join(tmpdir(), 'agent-bench-healthbench-'))
|
|
447
|
+
const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}/v1`
|
|
448
|
+
try {
|
|
449
|
+
const result = await runPublished('healthbench-professional', 'model:stand-in-model', {
|
|
450
|
+
tasks: 1, out, cacheDir, judge: 'bridge/stand-in-judge',
|
|
451
|
+
env: { AGENT_BENCH_ROUTER_URL: url, TANGLE_API_KEY: 'local-stand-in', AGENT_BENCH_JUDGE_URL: url },
|
|
452
|
+
})
|
|
453
|
+
assert.equal(result.tasks, 1, JSON.stringify(result.taskScores))
|
|
454
|
+
assert.equal(result.official, false)
|
|
455
|
+
assert.equal(result.unofficial, PUBLISHED_BENCHMARKS['healthbench-professional']!.unofficial)
|
|
456
|
+
assert.equal(result.publisherJudge, PUBLISHED_BENCHMARKS['healthbench-professional']!.judge)
|
|
457
|
+
assert.ok(seen.target === 1 && seen.judge >= 1, JSON.stringify(seen))
|
|
458
|
+
const [row] = (await readFile(result.runRecords, 'utf8')).trim().split('\n').map((line) => JSON.parse(line) as { scenarioId: string })
|
|
459
|
+
assert.equal(row!.scenarioId, `healthbench-professional:${result.taskScores[0]!.id}`)
|
|
460
|
+
scores.push(result.taskScores[0]!)
|
|
461
|
+
} finally {
|
|
462
|
+
server.closeAllConnections()
|
|
463
|
+
server.close()
|
|
464
|
+
await rm(out, { recursive: true, force: true })
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
assert.equal(scores[0]!.passed, true, JSON.stringify(scores[0]))
|
|
468
|
+
assert.equal(scores[0]!.score, 1)
|
|
469
|
+
assert.equal(scores[1]!.passed, false)
|
|
470
|
+
assert.equal(scores[1]!.score, 0)
|
|
471
|
+
} finally {
|
|
472
|
+
await rm(cacheDir, { recursive: true, force: true })
|
|
473
|
+
}
|
|
474
|
+
})
|
|
475
|
+
|
|
476
|
+
/** Chat completions for the MLCR target and a substituted jury: each member finds the answered run complete and accurate,
|
|
477
|
+
* and the other neither. The target answers briefly, inside the publisher's conciseness gate. */
|
|
478
|
+
function mlcrStandIn(answered: boolean) {
|
|
479
|
+
const seen = { target: 0, judge: 0 }
|
|
480
|
+
const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
|
|
481
|
+
let raw = ''
|
|
482
|
+
for await (const chunk of req) raw += chunk
|
|
483
|
+
const body = JSON.parse(raw || '{}') as { model?: string }
|
|
484
|
+
let text: string
|
|
485
|
+
if (body.model === 'stand-in-judge') {
|
|
486
|
+
seen.judge++
|
|
487
|
+
text = JSON.stringify({ complete: answered, accurate: answered, rationale: 'stand-in judge' })
|
|
488
|
+
} else {
|
|
489
|
+
seen.target++
|
|
490
|
+
text = answered ? 'A brief answer.' : 'I cannot help.'
|
|
491
|
+
}
|
|
492
|
+
res.writeHead(200, { 'content-type': 'application/json' })
|
|
493
|
+
res.end(JSON.stringify({ id: 'chatcmpl-stand-in', object: 'chat.completion', created: 0, model: body.model,
|
|
494
|
+
choices: [{ index: 0, message: { role: 'assistant', content: text }, finish_reason: 'stop' }],
|
|
495
|
+
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 } }))
|
|
496
|
+
})
|
|
497
|
+
return { server, seen }
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
test('MLCR: the publisher\'s runner and scorer, with a substituted judge, pass the row the jury finds correct and fail the other', { skip: uv ? false : 'uv is not installed', timeout: 30 * 60_000 }, async () => {
|
|
501
|
+
const cacheDir = await mkdtemp(path.join(tmpdir(), 'agent-bench-published-cache-'))
|
|
502
|
+
try {
|
|
503
|
+
const verdicts: Array<{ passed: boolean; score: number }> = []
|
|
504
|
+
for (const answered of [true, false]) {
|
|
505
|
+
const { server, seen } = mlcrStandIn(answered)
|
|
506
|
+
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
|
|
507
|
+
const out = await mkdtemp(path.join(tmpdir(), 'agent-bench-mlcr-'))
|
|
508
|
+
const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}/v1`
|
|
509
|
+
try {
|
|
510
|
+
const result = await runPublished('mlcr', 'model:stand-in-model', {
|
|
511
|
+
tasks: 1, out, cacheDir, judge: 'bridge/stand-in-judge',
|
|
512
|
+
env: { AGENT_BENCH_ROUTER_URL: url, TANGLE_API_KEY: 'local-stand-in', AGENT_BENCH_JUDGE_URL: url },
|
|
513
|
+
})
|
|
514
|
+
assert.equal(result.tasks, 1, JSON.stringify(result.taskScores))
|
|
515
|
+
assert.equal(result.official, false)
|
|
516
|
+
assert.equal(result.publisherJudge, PUBLISHED_BENCHMARKS.mlcr!.judge)
|
|
517
|
+
assert.ok(seen.target === 1 && seen.judge === 3, `a substituted jury has three members: ${JSON.stringify(seen)}`)
|
|
518
|
+
const [row] = (await readFile(result.runRecords, 'utf8')).trim().split('\n').map((line) => JSON.parse(line) as { scenarioId: string })
|
|
519
|
+
assert.equal(row!.scenarioId, `mlcr:${result.taskScores[0]!.id}`)
|
|
520
|
+
verdicts.push(result.taskScores[0]!)
|
|
521
|
+
} finally {
|
|
522
|
+
server.closeAllConnections()
|
|
523
|
+
server.close()
|
|
524
|
+
await rm(out, { recursive: true, force: true })
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
assert.equal(verdicts[0]!.passed, true, JSON.stringify(verdicts[0]))
|
|
528
|
+
assert.equal(verdicts[0]!.score, 1)
|
|
529
|
+
assert.equal(verdicts[1]!.passed, false)
|
|
530
|
+
assert.equal(verdicts[1]!.score, 0)
|
|
531
|
+
} finally {
|
|
532
|
+
await rm(cacheDir, { recursive: true, force: true })
|
|
533
|
+
}
|
|
534
|
+
})
|