@tangle-network/agent-bench 0.14.2 → 1.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 +48 -0
- package/README.md +2 -3
- package/dist/adapters.d.ts +2 -5
- package/dist/adapters.js +3 -4
- package/dist/benchmarks/_harness.d.ts +17 -20
- package/dist/benchmarks/_harness.js +4 -4
- package/dist/benchmarks/_harness.js.map +1 -1
- package/dist/benchmarks/aec-bench.d.ts +1 -4
- package/dist/benchmarks/aec-bench.js +1 -2
- package/dist/benchmarks/agentbench.d.ts +2 -5
- package/dist/benchmarks/agentbench.js +1 -2
- package/dist/benchmarks/appworld.d.ts +8 -10
- package/dist/benchmarks/appworld.js +23 -23
- package/dist/benchmarks/appworld.js.map +1 -1
- package/dist/benchmarks/bfcl.d.ts +2 -5
- package/dist/benchmarks/bfcl.js +1 -2
- package/dist/benchmarks/cad-design.d.ts +2 -5
- package/dist/benchmarks/cad-design.js +2 -3
- package/dist/benchmarks/cad-design.js.map +1 -1
- package/dist/benchmarks/cadbench.d.ts +1 -4
- package/dist/benchmarks/cadbench.js +1 -2
- package/dist/benchmarks/cadgenbench.d.ts +1 -4
- package/dist/benchmarks/cadgenbench.js +1 -2
- package/dist/benchmarks/commit0.d.ts +2 -5
- package/dist/benchmarks/commit0.js +1 -2
- package/dist/benchmarks/crag.d.ts +1 -4
- package/dist/benchmarks/crag.js +3 -3
- package/dist/benchmarks/crag.js.map +1 -1
- package/dist/benchmarks/dabstep.d.ts +2 -5
- package/dist/benchmarks/dabstep.js +2 -3
- package/dist/benchmarks/dabstep.js.map +1 -1
- package/dist/benchmarks/enterpriseops-gym.d.ts +2 -5
- package/dist/benchmarks/enterpriseops-gym.js +1 -2
- package/dist/benchmarks/finresearchbench.d.ts +2 -5
- package/dist/benchmarks/finresearchbench.js +2 -3
- package/dist/benchmarks/finsearchcomp.d.ts +2 -5
- package/dist/benchmarks/finsearchcomp.js +4 -4
- package/dist/benchmarks/finsearchcomp.js.map +1 -1
- package/dist/benchmarks/frames.d.ts +3 -19
- package/dist/benchmarks/frames.js +13 -39
- package/dist/benchmarks/frames.js.map +1 -1
- package/dist/benchmarks/hotpotqa.d.ts +4 -14
- package/dist/benchmarks/hotpotqa.js +12 -32
- package/dist/benchmarks/hotpotqa.js.map +1 -1
- package/dist/benchmarks/humaneval.d.ts +9 -12
- package/dist/benchmarks/humaneval.js +2 -3
- package/dist/benchmarks/humaneval.js.map +1 -1
- package/dist/benchmarks/mcad-bench.d.ts +13 -16
- package/dist/benchmarks/mcad-bench.js +2 -3
- package/dist/benchmarks/mcad-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-bench.d.ts +17 -20
- package/dist/benchmarks/mcad-cq-bench.js +2 -3
- package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-golds.d.ts +2 -5
- package/dist/benchmarks/mcad-cq-golds.js +1 -2
- package/dist/benchmarks/mcad-golds.d.ts +1 -4
- package/dist/benchmarks/mcad-golds.js +0 -1
- package/dist/benchmarks/mcad-tasks.d.ts +5 -8
- package/dist/benchmarks/mcad-tasks.js +7 -8
- package/dist/benchmarks/mcad-tasks.js.map +1 -1
- package/dist/benchmarks/mind2web.d.ts +3 -5
- package/dist/benchmarks/mind2web.js +2 -3
- package/dist/benchmarks/mind2web.js.map +1 -1
- package/dist/benchmarks/nomiracl.d.ts +1 -4
- package/dist/benchmarks/nomiracl.js +1 -2
- package/dist/benchmarks/open-rag-bench.d.ts +1 -4
- package/dist/benchmarks/open-rag-bench.js +3 -3
- package/dist/benchmarks/open-rag-bench.js.map +1 -1
- package/dist/benchmarks/programbench.d.ts +2 -5
- package/dist/benchmarks/programbench.js +1 -2
- package/dist/benchmarks/rag-shared.d.ts +30 -22
- package/dist/benchmarks/rag-shared.js +8 -2
- package/dist/benchmarks/rag-shared.js.map +1 -1
- package/dist/benchmarks/ragbench.d.ts +1 -4
- package/dist/benchmarks/ragbench.js +3 -3
- package/dist/benchmarks/ragbench.js.map +1 -1
- package/dist/benchmarks/simpleqa.d.ts +2 -18
- package/dist/benchmarks/simpleqa.js +5 -31
- package/dist/benchmarks/simpleqa.js.map +1 -1
- package/dist/benchmarks/swe-bench.d.ts +7 -10
- package/dist/benchmarks/swe-bench.js +4 -4
- package/dist/benchmarks/swe-bench.js.map +1 -1
- package/dist/benchmarks/t2-ragbench.d.ts +1 -4
- package/dist/benchmarks/t2-ragbench.js +3 -3
- package/dist/benchmarks/t2-ragbench.js.map +1 -1
- package/dist/benchmarks/tau-bench-shared.d.ts +5 -8
- package/dist/benchmarks/tau-bench-shared.js +4 -4
- package/dist/benchmarks/tau-bench-shared.js.map +1 -1
- package/dist/benchmarks/tau2-bench.d.ts +2 -5
- package/dist/benchmarks/tau2-bench.js +1 -2
- package/dist/benchmarks/tau3-banking.d.ts +1 -4
- package/dist/benchmarks/tau3-banking.js +1 -2
- package/dist/benchmarks/terminal-bench.d.ts +1 -4
- package/dist/benchmarks/terminal-bench.js +4 -4
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/benchmarks/toollm.d.ts +2 -5
- package/dist/benchmarks/toollm.js +1 -2
- package/dist/benchmarks/trata-hedge.d.ts +1 -4
- package/dist/benchmarks/trata-hedge.js +2 -3
- package/dist/benchmarks/types.d.ts +6 -9
- package/dist/benchmarks/webarena-verified.d.ts +2 -5
- package/dist/benchmarks/webarena-verified.js +1 -2
- package/dist/{cadbench-BRF-59Mt.js → cadbench-DhAndllg.js} +4 -6
- package/dist/cadbench-DhAndllg.js.map +1 -0
- package/dist/{cadgenbench-DXtGkuW3.js → cadgenbench-Tvk16YKT.js} +15 -5
- package/dist/cadgenbench-Tvk16YKT.js.map +1 -0
- package/dist/index.d.ts +8 -18
- package/dist/index.js +16 -24
- package/dist/index.js.map +1 -1
- package/dist/{router-turn-uTYO6KQ1.js → router-turn-DNbQ_GjQ.js} +2 -3
- package/dist/router-turn-DNbQ_GjQ.js.map +1 -0
- package/fixtures/pier-agent/no-model-task/pre_artifacts.sh +0 -0
- package/fixtures/pier-agent/no-model-task/tests/test.sh +0 -0
- package/package.json +10 -10
- package/pier_agents/tangle_candidate.py +15 -23
- package/scripts/run-package-tests.mjs +8 -15
- package/scripts/verify-packed-consumer.mjs +0 -1
- package/src/atom-mcp-e2e.mts +16 -4
- package/src/benchmarks/frames.ts +10 -44
- package/src/benchmarks/hotpotqa.ts +9 -29
- package/src/benchmarks/rag-shared.ts +12 -0
- package/src/benchmarks/simpleqa.ts +2 -36
- package/src/commit0-prereqs.sh +0 -0
- package/src/corpus-replay.mts +8 -8
- package/src/corpus-report.mts +21 -21
- package/src/corpus.test.mts +5 -5
- package/src/corpus.ts +16 -16
- package/src/directives.ts +0 -38
- package/src/examples/lean-verify.ts +1 -1
- package/src/gate.ts +8 -8
- package/src/generate-eval/certify.ts +2 -2
- package/src/index.ts +1 -0
- package/src/refine-loop.ts +5 -5
- package/src/resolve-client.ts +1 -1
- package/src/router-turn.ts +3 -11
- package/src/run-benchmarks.test.mts +0 -4
- package/src/run-pool.ts +1 -1
- package/src/runtime-hook-recorder.ts +2 -2
- package/src/search-bench/tasks.ts +1 -1
- package/src/selector.test.mts +13 -13
- package/src/selector.ts +19 -19
- package/src/swe-bench-env.ts +4 -12
- package/src/swe-jail.ts +5 -156
- package/src/swe-structural-judge-policy.ts +3 -3
- package/src/swe-structural-policy.ts +3 -3
- package/src/swe-structural-provenance.ts +4 -4
- package/src/terminal-compare.ts +10 -10
- package/src/worker-blender.ts +2 -106
- package/src/worker-build123d.ts +2 -81
- package/tb_agents/opencode_router_agent.py +1 -1
- package/dist/cadbench-BRF-59Mt.js.map +0 -1
- package/dist/cadgenbench-DXtGkuW3.js.map +0 -1
- package/dist/router-turn-uTYO6KQ1.js.map +0 -1
- package/scripts/cadbench_prepare.py +0 -22
- package/scripts/cadgenbench_hard_parts.py +0 -48
- package/scripts/clbench_codebase_judge.py +0 -73
- package/scripts/render-gate-chart.mjs +0 -176
- package/scripts/trata-hedge/README.md +0 -57
- package/scripts/trata-hedge/run.sh +0 -64
- package/src/browser/adapters/bad-design-audit.ts +0 -153
- package/src/browser/adapters/bad-design-audit.verify.ts +0 -85
- package/src/browser/adapters/bad.ts +0 -165
- package/src/browser/agent-adapter.ts +0 -145
- package/src/browser/process-adapter.ts +0 -146
- package/src/browser/run-to-spans.ts +0 -105
- package/src/browser/run-to-spans.verify.ts +0 -89
- package/src/browser/ui-reviewer.ts +0 -200
- package/src/browser/ui-reviewer.verify.ts +0 -94
- package/src/browser/verify.ts +0 -96
- package/src/clbench-codebase-gate.mts +0 -314
- package/src/clbench-context-gate.mts +0 -341
- package/src/cloud-loop.mts +0 -156
- package/src/commit0-env-run.mts +0 -62
- package/src/commit0-env.ts +0 -172
- package/src/commit0-gate.mts +0 -558
- package/src/coordination-mcp-container-reach.mts +0 -182
- package/src/egress-probe.mts +0 -26
- package/src/fleet.mts +0 -143
- package/src/hev-structural.mts +0 -697
- package/src/humaneval-gate.mts +0 -220
- package/src/humaneval-repair-gate.mts +0 -182
- package/src/mbpp-structural.mts +0 -676
- package/src/mcp-mount-probe.mts +0 -139
- package/src/profile-coordinates.ts +0 -134
- package/src/profiles.ts +0 -128
- package/src/research-gate.mts +0 -132
- package/src/research-shot.ts +0 -144
- package/src/router-executor.ts +0 -51
- package/src/run-benchmarks-report.ts +0 -66
- package/src/sandbox-run.ts +0 -108
- package/src/search-bench/bridge.ts +0 -182
- package/src/search-bench/export.mts +0 -0
- package/src/search-bench/parametric-check.mts +0 -78
- package/src/search-bench/profiles.ts +0 -113
- package/src/search-bench/run.mts +0 -286
- package/src/search-bench/tasks-fresh.ts +0 -688
- package/src/skill-sandbox-smoke.mts +0 -101
- package/src/smoke-structural-rollout.mts +0 -415
- package/src/stats.mts +0 -90
- package/src/supervisor-arena.mts +0 -825
- package/src/swe-code-improve.mts +0 -306
- package/src/swe-emit-patch.mts +0 -125
- package/src/swe-improve.mts +0 -284
- package/src/swe-local-proof.mts +0 -265
- package/src/swe-repro-calibrate.mts +0 -451
- package/src/swe-stream.mts +0 -1561
- package/src/swe-structural.mts +0 -707
- package/src/tb-container-executor.mts +0 -266
- package/src/tb-container-executor.test.mts +0 -134
- package/src/tb-supervisor-sidecar.mts +0 -208
- package/src/trajectory-assemble.mjs +0 -130
- package/src/trata-gepa.mts +0 -381
- package/src/trata-hedge-solve.mts +0 -81
- package/src/worker-browser.ts +0 -115
- package/src/worker-cad.ts +0 -470
- package/src/workspace-loop.mts +0 -133
- package/tb_agents/opencode_refine_agent.py +0 -117
- package/tb_agents/opencode_supervisor_agent.py +0 -239
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { collectAgentTurn, createExecutor, streamAgentTurn } from "@tangle-network/agent-runtime/kernel";
|
|
2
2
|
import "@tangle-network/agent-interface";
|
|
3
|
-
|
|
3
|
+
// src/router-turn.ts
|
|
4
4
|
/**
|
|
5
5
|
* The benchmark-side entry to Runtime's canonical one-turn path.
|
|
6
6
|
* It is only an ergonomic composition: Runtime still parses the exact profile,
|
|
@@ -27,7 +27,6 @@ async function runBenchRouterTurn(config, input) {
|
|
|
27
27
|
if (turn.status !== "completed") throw new Error(turn.error?.message ?? `Router turn ended with status ${turn.status}`);
|
|
28
28
|
return turn;
|
|
29
29
|
}
|
|
30
|
-
//#endregion
|
|
31
30
|
export { runBenchRouterTurn as t };
|
|
32
31
|
|
|
33
|
-
//# sourceMappingURL=router-turn-
|
|
32
|
+
//# sourceMappingURL=router-turn-DNbQ_GjQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-turn-DNbQ_GjQ.js","names":[],"sources":["../src/router-turn.ts"],"sourcesContent":["import {\n type AgentProfile,\n agentProfileSchema,\n type ReasoningEffort,\n} from '@tangle-network/agent-interface'\nimport {\n collectAgentTurn,\n createExecutor,\n streamAgentTurn,\n type AgentTurnInput,\n type CollectedAgentTurn,\n type ToolSpec,\n} from '@tangle-network/agent-runtime/kernel'\n\n/** Bench-local target shorthand; Runtime still executes only the exact profile below. */\ninterface BenchRouterTarget {\n routerBaseUrl: string\n routerKey: string\n profile: AgentProfile\n}\n\ninterface BenchRouterTurnConfig extends BenchRouterTarget {\n tools?: ReadonlyArray<ToolSpec>\n timeoutMs?: number\n signal?: AbortSignal\n}\n\ninterface BenchProfileSettings {\n systemPrompt?: string\n temperature?: number\n maxTokens?: number\n retry?: {\n maxAttempts?: number\n initialBackoffMs?: number\n maxBackoffMs?: number\n jitter?: number\n retryStatuses?: ReadonlyArray<number>\n requestTimeoutMs?: number\n }\n maxTurns?: number\n seed?: number\n reasoningEffort?: ReasoningEffort\n extraBody?: Readonly<Record<string, unknown>>\n toolChoice?: 'auto' | 'required' | 'none'\n}\n\n/** Author an exact direct-Router profile for a benchmark. This is profile construction only;\n * execution still accepts no model or generation fields outside the returned AgentProfile. */\nexport function benchRouterProfile(\n name: string,\n model: string,\n settings: BenchProfileSettings = {},\n): AgentProfile {\n return withBenchProfile(\n {\n name,\n harness: 'cli-base',\n model: { provider: 'tangle-router', default: model },\n },\n settings,\n )\n}\n\n/** Derive another exact profile while preserving all untouched canonical axes. */\nexport function withBenchProfile(\n base: AgentProfile,\n settings: BenchProfileSettings & { name?: string },\n): AgentProfile {\n const metadata = {\n ...(base.model?.metadata ?? {}),\n ...(settings.temperature !== undefined ? { temperature: settings.temperature } : {}),\n ...(settings.retry !== undefined ? { retry: settings.retry } : {}),\n ...(settings.maxTurns !== undefined ? { maxTurns: settings.maxTurns } : {}),\n ...(settings.seed !== undefined ? { seed: settings.seed } : {}),\n ...(settings.extraBody !== undefined ? { extraBody: settings.extraBody } : {}),\n ...(settings.toolChoice !== undefined ? { toolChoice: settings.toolChoice } : {}),\n }\n return agentProfileSchema.parse({\n ...base,\n ...(settings.name ? { name: settings.name } : {}),\n model: {\n ...base.model,\n ...(settings.reasoningEffort !== undefined\n ? { reasoningEffort: settings.reasoningEffort }\n : {}),\n // A bench cap bounds the VISIBLE answer, which the Router lowers as `max_tokens`.\n ...(settings.maxTokens !== undefined\n ? { maxVisibleOutputTokens: settings.maxTokens }\n : {}),\n ...(Object.keys(metadata).length > 0 ? { metadata } : {}),\n },\n ...(settings.systemPrompt !== undefined\n ? { prompt: { ...base.prompt, systemPrompt: settings.systemPrompt } }\n : {}),\n })\n}\n\n/**\n * The benchmark-side entry to Runtime's canonical one-turn path.\n * It is only an ergonomic composition: Runtime still parses the exact profile,\n * materializes the executor, records identity/usage/result events, and refuses\n * profile axes the direct Router backend cannot carry.\n */\nexport async function runBenchRouterTurn(\n config: BenchRouterTurnConfig,\n input: string | { readonly messages: ReadonlyArray<Readonly<Record<string, unknown>>> },\n): Promise<CollectedAgentTurn> {\n if (!config.profile.model?.default) {\n throw new Error('runBenchRouterTurn: profile.model.default is required')\n }\n const factory = createExecutor({\n backend: 'router',\n routerBaseUrl: config.routerBaseUrl,\n routerKey: config.routerKey,\n ...(config.tools ? { tools: config.tools } : {}),\n })\n const turnInput: AgentTurnInput =\n typeof input === 'string'\n ? { prompt: input }\n : {\n providerOptions: {\n messages: input.messages.map((message) => ({ ...message })),\n },\n }\n const turn = await collectAgentTurn(\n streamAgentTurn(\n { kind: 'executor', factory, profile: config.profile },\n turnInput,\n {\n ...(config.timeoutMs === undefined ? {} : { timeoutMs: config.timeoutMs }),\n ...(config.signal ? { signal: config.signal } : {}),\n },\n ),\n )\n if (turn.status !== 'completed') {\n throw new Error(turn.error?.message ?? `Router turn ended with status ${turn.status}`)\n }\n return turn\n}\n"],"mappings":";;;;;;;;;AAuGA,eAAsB,mBACpB,QACA,OAC6B;CAC7B,IAAI,CAAC,OAAO,QAAQ,OAAO,SACzB,MAAM,IAAI,MAAM,uDAAuD;CAEzE,MAAM,UAAU,eAAe;EAC7B,SAAS;EACT,eAAe,OAAO;EACtB,WAAW,OAAO;EAClB,GAAI,OAAO,QAAQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;CAChD,CAAC;CACD,MAAM,YACJ,OAAO,UAAU,WACb,EAAE,QAAQ,MAAM,IAChB,EACE,iBAAiB,EACf,UAAU,MAAM,SAAS,KAAK,aAAa,EAAE,GAAG,QAAQ,EAAE,EAC5D,EACF;CACN,MAAM,OAAO,MAAM,iBACjB,gBACE;EAAE,MAAM;EAAY;EAAS,SAAS,OAAO;CAAQ,GACrD,WACA;EACE,GAAI,OAAO,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,OAAO,UAAU;EACxE,GAAI,OAAO,SAAS,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;CACnD,CACF,CACF;CACA,IAAI,KAAK,WAAW,aAClB,MAAM,IAAI,MAAM,KAAK,OAAO,WAAW,iCAAiC,KAAK,QAAQ;CAEvF,OAAO;AACT"}
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-bench",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Benchmark adapters and execution for agent-runtime across coding, tool-use, RAG, memory, browser, and terminal tasks.",
|
|
6
6
|
"repository": {
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tangle-network/agent-eval": "
|
|
29
|
-
"@tangle-network/agent-interface": "^
|
|
30
|
-
"@tangle-network/agent-knowledge": "^
|
|
31
|
-
"@tangle-network/
|
|
32
|
-
"@tangle-network/
|
|
28
|
+
"@tangle-network/agent-eval": "^1.0.0",
|
|
29
|
+
"@tangle-network/agent-interface": "^5.10.16",
|
|
30
|
+
"@tangle-network/agent-knowledge": "^23.0.0",
|
|
31
|
+
"@tangle-network/agent-runtime": "^8.0.0",
|
|
32
|
+
"@tangle-network/sandbox": "^1.0.233"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@arethetypeswrong/cli": "0.18.5",
|
|
36
|
-
"@types/node": "26.
|
|
37
|
-
"publint": "0.3.
|
|
38
|
-
"tsdown": "0.
|
|
39
|
-
"tsx": "4.23.
|
|
36
|
+
"@types/node": "26.6.5",
|
|
37
|
+
"publint": "0.3.25",
|
|
38
|
+
"tsdown": "0.23.2",
|
|
39
|
+
"tsx": "4.23.15",
|
|
40
40
|
"typescript": "6.0.3"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
@@ -404,29 +404,21 @@ class TangleCandidateAgent(BaseAgent):
|
|
|
404
404
|
await self._assert_real_directory(
|
|
405
405
|
environment, anchor, label="trusted directory anchor"
|
|
406
406
|
)
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
f" mkdir -- {quoted}",
|
|
423
|
-
f" chmod {mode:o} -- {quoted}",
|
|
424
|
-
"fi",
|
|
425
|
-
f'test "$(realpath -e -- {quoted})" = {quoted}',
|
|
426
|
-
]
|
|
427
|
-
),
|
|
428
|
-
user="root",
|
|
429
|
-
)
|
|
407
|
+
parts = parsed.relative_to(parsed_anchor).parts
|
|
408
|
+
if parts:
|
|
409
|
+
await self._exec(environment, f"""set -eu
|
|
410
|
+
current={shlex.quote(str(parsed_anchor).rstrip('/'))}
|
|
411
|
+
for part in {shlex.join(parts)}; do
|
|
412
|
+
current="$current/$part"
|
|
413
|
+
if test -e "$current" || test -L "$current"; then
|
|
414
|
+
test -d "$current"
|
|
415
|
+
test ! -L "$current"
|
|
416
|
+
else
|
|
417
|
+
mkdir -- "$current"
|
|
418
|
+
chmod {mode:o} -- "$current"
|
|
419
|
+
fi
|
|
420
|
+
test "$(realpath -e -- "$current")" = "$current"
|
|
421
|
+
done""", user="root")
|
|
430
422
|
|
|
431
423
|
async def _write_verified_file(
|
|
432
424
|
self,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process'
|
|
2
|
-
import {
|
|
2
|
+
import { readdir, readFile, realpath } from 'node:fs/promises'
|
|
3
3
|
import { tmpdir } from 'node:os'
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
import { fileURLToPath } from 'node:url'
|
|
@@ -7,7 +7,6 @@ import { promisify } from 'node:util'
|
|
|
7
7
|
|
|
8
8
|
const execFileAsync = promisify(execFile)
|
|
9
9
|
const benchDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
10
|
-
const sourceDir = path.join(benchDir, 'src')
|
|
11
10
|
|
|
12
11
|
export function packageNodeTestArgs(files, env = process.env) {
|
|
13
12
|
const raw = env.AGENT_BENCH_PACKAGE_TEST_CONCURRENCY
|
|
@@ -59,9 +58,8 @@ export async function run(command, args, env = process.env) {
|
|
|
59
58
|
} catch (error) {
|
|
60
59
|
if (error?.stdout) process.stdout.write(error.stdout)
|
|
61
60
|
if (error?.stderr) process.stderr.write(error.stderr)
|
|
62
|
-
const invocation = [command, ...args].join(' ')
|
|
63
61
|
const message = error instanceof Error ? error.message : String(error)
|
|
64
|
-
throw new Error(`${
|
|
62
|
+
throw new Error(`${[command, ...args].join(' ')} failed: ${message}`, { cause: error })
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
65
|
|
|
@@ -75,14 +73,9 @@ export async function runPythonTests(python, env = process.env) {
|
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
async function main() {
|
|
78
|
-
const python =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} catch {
|
|
82
|
-
await run('python3', ['-m', 'venv', '.venv'])
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const tests = await collectTests(sourceDir)
|
|
76
|
+
const python = (await execFileAsync('python3', ['-c', 'import sys; print(sys.executable)'])).stdout.trim()
|
|
77
|
+
const testEnv = { ...process.env, AGENT_BENCH_PYTHON: process.env.AGENT_BENCH_PYTHON ?? python }
|
|
78
|
+
const tests = await collectTests(path.join(benchDir, 'src'))
|
|
86
79
|
if (tests.length === 0) throw new Error('no package tests found under src/')
|
|
87
80
|
|
|
88
81
|
// Two test runtimes coexist under src/: node:test files run under `node --test`;
|
|
@@ -101,17 +94,17 @@ async function main() {
|
|
|
101
94
|
process.execPath,
|
|
102
95
|
packageNodeTestArgs(nodeTests.map((file) => path.relative(benchDir, file))),
|
|
103
96
|
{
|
|
104
|
-
...
|
|
97
|
+
...testEnv,
|
|
105
98
|
TSX_TSCONFIG_PATH: 'tsconfig.public.json',
|
|
106
99
|
},
|
|
107
100
|
)
|
|
108
101
|
}
|
|
109
102
|
|
|
110
103
|
if (vitestTests.length > 0) {
|
|
111
|
-
await run('npx', ['vitest', 'run', ...vitestTests.map((file) => path.relative(benchDir, file))])
|
|
104
|
+
await run('npx', ['vitest', 'run', ...vitestTests.map((file) => path.relative(benchDir, file))], testEnv)
|
|
112
105
|
}
|
|
113
106
|
|
|
114
|
-
await runPythonTests(python)
|
|
107
|
+
await runPythonTests(python, testEnv)
|
|
115
108
|
|
|
116
109
|
console.log(
|
|
117
110
|
`package tests passed: ${tests.length}/${tests.length} TypeScript files (${nodeTests.length} node:test + ${vitestTests.length} vitest) + Pier bridge`,
|
|
@@ -186,7 +186,6 @@ const report = await runBenchmarks({
|
|
|
186
186
|
judge: async (_task, artifact) => ({ resolved: artifact === 'corrected', score: artifact === 'corrected' ? 1 : 0 }),
|
|
187
187
|
}),
|
|
188
188
|
resolveClient: () => ({
|
|
189
|
-
criuStatus: async () => ({ available: false }),
|
|
190
189
|
create: async () => ({
|
|
191
190
|
id: 'packed-fixture',
|
|
192
191
|
async *streamPrompt(prompt: string, options?: { sessionId?: string }) {
|
package/src/atom-mcp-e2e.mts
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
streamAgentTurn,
|
|
37
37
|
type Workspace,
|
|
38
38
|
} from '../../src/runtime/index'
|
|
39
|
-
import { asAuthoredProfile } from '../../src/runtime/supervise/authoring'
|
|
39
|
+
import { asAuthoredProfile, assessAuthoredProfile } from '../../src/runtime/supervise/authoring'
|
|
40
40
|
import { serveCoordinationMcp } from '../../src/runtime/supervise/coordination-mcp'
|
|
41
41
|
|
|
42
42
|
const BRIDGE = (process.env.ROUTER_BASE ?? 'http://127.0.0.1:3355/v1').replace(/\/$/, '')
|
|
@@ -123,7 +123,7 @@ function makeWorker(rawProfile: unknown, ws: Workspace, n: number): Agent<unknow
|
|
|
123
123
|
const inner: Executor<unknown> = {
|
|
124
124
|
runtime: 'router',
|
|
125
125
|
async execute() {
|
|
126
|
-
const sys = p
|
|
126
|
+
const sys = p ? assessAuthoredProfile(p).systemPrompt : TASK
|
|
127
127
|
const run = await runInWorkspace(
|
|
128
128
|
ws,
|
|
129
129
|
async (cwd) => {
|
|
@@ -171,12 +171,18 @@ async function main(): Promise<void> {
|
|
|
171
171
|
const root: Agent<unknown, unknown> = {
|
|
172
172
|
name: 'supervisor',
|
|
173
173
|
async act(_t, scope: Scope<unknown>) {
|
|
174
|
+
let awaitSettlement = undefined as
|
|
175
|
+
| ((workerIds: ReadonlyArray<string>) => Promise<ReadonlyArray<string>>)
|
|
176
|
+
| undefined
|
|
174
177
|
const mcp = await serveCoordinationMcp({
|
|
175
178
|
scope,
|
|
176
179
|
blobs,
|
|
177
180
|
makeWorkerAgent: (raw) => makeWorker(raw, ws, n++),
|
|
178
181
|
perWorker: { maxIterations: 2, maxTokens: 200_000 },
|
|
179
|
-
toolNames: ['spawn_worker'
|
|
182
|
+
toolNames: ['spawn_worker'],
|
|
183
|
+
onCoordinationTools: (_tools, coordination) => {
|
|
184
|
+
awaitSettlement = coordination.awaitSettlement
|
|
185
|
+
},
|
|
180
186
|
})
|
|
181
187
|
// The supervisor's cwd carries the REAL skill file (opencode loads it from the cwd skill dirs).
|
|
182
188
|
const supCwd = mkdtempSync(join(tmpdir(), 'e2e-sup-'))
|
|
@@ -190,13 +196,19 @@ async function main(): Promise<void> {
|
|
|
190
196
|
messages: [
|
|
191
197
|
{
|
|
192
198
|
role: 'user',
|
|
193
|
-
content: `${TASK}\n\nYou are a SUPERVISOR. You have the "supervise" skill and a "coordination" MCP with
|
|
199
|
+
content: `${TASK}\n\nYou are a SUPERVISOR. You have the "supervise" skill and a "coordination" MCP with the tool spawn_worker. Do NOT write code yourself. Author a worker profile (a JSON object with name + a rich systemPrompt telling the worker exactly what to implement) and call spawn_worker with it, then end your turn; the worker runs after you finish and its result is checked there.`,
|
|
194
200
|
},
|
|
195
201
|
],
|
|
196
202
|
cwd: supCwd,
|
|
197
203
|
mcpUrl: mcp.url,
|
|
198
204
|
})
|
|
199
205
|
transcripts.push({ who: 'supervisor', said: said.slice(0, 400) })
|
|
206
|
+
// The harness ended its turn after spawning. This bare coordination server has no manager
|
|
207
|
+
// loop to wake it, so wait here for the workers to settle into the ledger.
|
|
208
|
+
const workerIds = scope.view.nodes
|
|
209
|
+
.filter((node) => node.id !== scope.view.root)
|
|
210
|
+
.map((node) => node.id)
|
|
211
|
+
await awaitSettlement?.(workerIds)
|
|
200
212
|
const settled = mcp.settled()
|
|
201
213
|
const delivered = settled.filter((w) => w.status === 'done' && w.valid === true)
|
|
202
214
|
console.error(`[e2e] supervisor spawned ${settled.length} worker(s), ${delivered.length} delivered`)
|
package/src/benchmarks/frames.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { join } from 'node:path'
|
|
|
26
26
|
import { fileURLToPath } from 'node:url'
|
|
27
27
|
import { promisify } from 'node:util'
|
|
28
28
|
import { runBenchRouterTurn } from '../router-turn'
|
|
29
|
+
import { FINAL_ANSWER_SENTINEL, parseCitations, parseFinalAnswer } from './rag-shared'
|
|
29
30
|
import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
|
|
30
31
|
|
|
31
32
|
const execFileAsync = promisify(execFile)
|
|
@@ -37,7 +38,6 @@ const DATASET = 'google/frames-benchmark'
|
|
|
37
38
|
/** Pin the dataset revision: ids are derived from row order (no native id column),
|
|
38
39
|
* so a reorder would break opts.ids selection + scorecard joins. */
|
|
39
40
|
const DATASET_REVISION = 'main'
|
|
40
|
-
const FINAL_ANSWER_SENTINEL = 'FINAL ANSWER:'
|
|
41
41
|
|
|
42
42
|
/** Worker contract appended to every task prompt. Tier-1 parsing keys off the sentinel. */
|
|
43
43
|
const WORKER_CONTRACT = [
|
|
@@ -54,7 +54,7 @@ const WORKER_CONTRACT = [
|
|
|
54
54
|
* loop worker decodes its agent runs into a {@link ResearchAnswer} and serializes
|
|
55
55
|
* `finalAnswer` (+ optional `CITATIONS:` block) into that string before judging.
|
|
56
56
|
*/
|
|
57
|
-
export interface
|
|
57
|
+
export interface FramesTask {
|
|
58
58
|
id: string
|
|
59
59
|
question: string
|
|
60
60
|
/** Gold short answer — judge resolves strictly against this. */
|
|
@@ -65,11 +65,6 @@ export interface ResearchTask {
|
|
|
65
65
|
reasoningTypes: string
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export interface ResearchAnswer {
|
|
69
|
-
finalAnswer: string
|
|
70
|
-
citations: string[]
|
|
71
|
-
}
|
|
72
|
-
|
|
73
68
|
interface FramesRow {
|
|
74
69
|
Prompt: string
|
|
75
70
|
Answer: string
|
|
@@ -216,7 +211,7 @@ function canonicalizeDates(s: string): string {
|
|
|
216
211
|
}
|
|
217
212
|
|
|
218
213
|
/** Port of the SQuAD/GAIA normalize_answer routine, plus number/date canonicalization. */
|
|
219
|
-
export function
|
|
214
|
+
export function normalizeFramesAnswer(input: string): string {
|
|
220
215
|
let s = input.toLowerCase()
|
|
221
216
|
s = canonicalizeDates(s)
|
|
222
217
|
s = canonicalizeNumbers(s)
|
|
@@ -233,8 +228,8 @@ export function normalizeAnswer(input: string): string {
|
|
|
233
228
|
|
|
234
229
|
/** Tier-1 match: normalized equality OR normalized gold as a token-boundary substring. */
|
|
235
230
|
function tier1Match(candidate: string, gold: string): boolean {
|
|
236
|
-
const nc =
|
|
237
|
-
const ng =
|
|
231
|
+
const nc = normalizeFramesAnswer(candidate)
|
|
232
|
+
const ng = normalizeFramesAnswer(gold)
|
|
238
233
|
if (ng.length === 0) return false
|
|
239
234
|
if (nc === ng) return true
|
|
240
235
|
// token-boundary containment: gold appears as a whole-token run inside candidate
|
|
@@ -242,35 +237,6 @@ function tier1Match(candidate: string, gold: string): boolean {
|
|
|
242
237
|
return re.test(nc)
|
|
243
238
|
}
|
|
244
239
|
|
|
245
|
-
/**
|
|
246
|
-
* Parse the worker artifact into the final answer string.
|
|
247
|
-
* Order: the `FINAL ANSWER:` sentinel first (deterministic-extraction discipline);
|
|
248
|
-
* fall back to the last non-empty line. Returns '' when nothing is parseable
|
|
249
|
-
* (fail-closed — never guess), which judge() counts as resolved=false.
|
|
250
|
-
*/
|
|
251
|
-
export function parseFinalAnswer(artifact: string): string {
|
|
252
|
-
const lines = artifact.split(/\r?\n/)
|
|
253
|
-
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
254
|
-
const line = lines[i] ?? ''
|
|
255
|
-
const idx = line.toUpperCase().indexOf(FINAL_ANSWER_SENTINEL)
|
|
256
|
-
if (idx !== -1) return line.slice(idx + FINAL_ANSWER_SENTINEL.length).trim()
|
|
257
|
-
}
|
|
258
|
-
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
259
|
-
const t = (lines[i] ?? '').trim()
|
|
260
|
-
if (t.length > 0) return t
|
|
261
|
-
}
|
|
262
|
-
return ''
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/** Extract cited URLs from a `CITATIONS:` block and any bare URLs in the artifact. */
|
|
266
|
-
export function parseCitations(artifact: string): string[] {
|
|
267
|
-
const urls = new Set<string>()
|
|
268
|
-
for (const m of artifact.matchAll(/https?:\/\/[^\s)<>"']+/g)) {
|
|
269
|
-
urls.add(m[0].replace(/[.,;]+$/, ''))
|
|
270
|
-
}
|
|
271
|
-
return [...urls]
|
|
272
|
-
}
|
|
273
|
-
|
|
274
240
|
/** Fraction of gold Wikipedia article slugs touched by the candidate's citations. SOFT signal. */
|
|
275
241
|
function citationCoverage(citations: string[], goldSources: string[]): number {
|
|
276
242
|
if (goldSources.length === 0) return 1
|
|
@@ -483,7 +449,7 @@ print(json.dumps(out))
|
|
|
483
449
|
detail: JSON.stringify({
|
|
484
450
|
tier: 'none',
|
|
485
451
|
reason: 'no parseable answer',
|
|
486
|
-
normalizedGold:
|
|
452
|
+
normalizedGold: normalizeFramesAnswer(meta.gold),
|
|
487
453
|
citationCoverage: coverage,
|
|
488
454
|
}),
|
|
489
455
|
}
|
|
@@ -496,8 +462,8 @@ print(json.dumps(out))
|
|
|
496
462
|
score: 1,
|
|
497
463
|
detail: JSON.stringify({
|
|
498
464
|
tier: 1,
|
|
499
|
-
normalizedAnswer:
|
|
500
|
-
normalizedGold:
|
|
465
|
+
normalizedAnswer: normalizeFramesAnswer(finalAnswer),
|
|
466
|
+
normalizedGold: normalizeFramesAnswer(meta.gold),
|
|
501
467
|
citationCoverage: coverage,
|
|
502
468
|
}),
|
|
503
469
|
}
|
|
@@ -510,8 +476,8 @@ print(json.dumps(out))
|
|
|
510
476
|
score: verdict ? 1 : 0,
|
|
511
477
|
detail: JSON.stringify({
|
|
512
478
|
tier: 2,
|
|
513
|
-
normalizedAnswer:
|
|
514
|
-
normalizedGold:
|
|
479
|
+
normalizedAnswer: normalizeFramesAnswer(finalAnswer),
|
|
480
|
+
normalizedGold: normalizeFramesAnswer(meta.gold),
|
|
515
481
|
judgeVerdict: verdict ? 'correct' : 'incorrect',
|
|
516
482
|
citationCoverage: coverage,
|
|
517
483
|
}),
|
|
@@ -23,6 +23,7 @@ import { readFile } from 'node:fs/promises'
|
|
|
23
23
|
import { join } from 'node:path'
|
|
24
24
|
import { fileURLToPath } from 'node:url'
|
|
25
25
|
import { promisify } from 'node:util'
|
|
26
|
+
import { FINAL_ANSWER_SENTINEL, parseFinalAnswer } from './rag-shared'
|
|
26
27
|
import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
|
|
27
28
|
|
|
28
29
|
const execFileAsync = promisify(execFile)
|
|
@@ -33,7 +34,6 @@ const FIXTURES = join(BENCH_ROOT, 'fixtures', 'hotpotqa.json')
|
|
|
33
34
|
const DATASET = 'hotpotqa/hotpot_qa'
|
|
34
35
|
const DATASET_CONFIG = 'distractor'
|
|
35
36
|
const DATASET_SPLIT = 'validation'
|
|
36
|
-
const FINAL_ANSWER_SENTINEL = 'FINAL ANSWER:'
|
|
37
37
|
|
|
38
38
|
/** Default F1 pass threshold; HotpotQA's leaderboard reports EM and F1 separately. */
|
|
39
39
|
const DEFAULT_F1_PASS = 0.6
|
|
@@ -83,7 +83,7 @@ const ARTICLES = new Set(['a', 'an', 'the'])
|
|
|
83
83
|
* drop articles (a/an/the), collapse whitespace. Token comparisons run on the
|
|
84
84
|
* output of this exactly as the published evaluator does.
|
|
85
85
|
*/
|
|
86
|
-
export function
|
|
86
|
+
export function normalizeHotpotAnswer(input: string): string {
|
|
87
87
|
const lower = input.toLowerCase()
|
|
88
88
|
// strip punctuation: keep word chars + whitespace only
|
|
89
89
|
const noPunct = lower.replace(/[^\w\s]/g, ' ')
|
|
@@ -96,13 +96,13 @@ export function normalizeAnswer(input: string): string {
|
|
|
96
96
|
|
|
97
97
|
/** Normalized-token list (the F1 bag-of-tokens unit). */
|
|
98
98
|
function answerTokens(input: string): string[] {
|
|
99
|
-
const n =
|
|
99
|
+
const n = normalizeHotpotAnswer(input)
|
|
100
100
|
return n.length === 0 ? [] : n.split(' ')
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/** Exact match on the normalized strings. */
|
|
104
104
|
export function exactMatch(prediction: string, gold: string): boolean {
|
|
105
|
-
return
|
|
105
|
+
return normalizeHotpotAnswer(prediction) === normalizeHotpotAnswer(gold)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
@@ -111,7 +111,7 @@ export function exactMatch(prediction: string, gold: string): boolean {
|
|
|
111
111
|
* yes/no/noanswer and empty bags: if either side is empty, F1 is 1 only when both
|
|
112
112
|
* are empty, else 0.
|
|
113
113
|
*/
|
|
114
|
-
export function
|
|
114
|
+
export function hotpotTokenF1(prediction: string, gold: string): number {
|
|
115
115
|
const predTokens = answerTokens(prediction)
|
|
116
116
|
const goldTokens = answerTokens(gold)
|
|
117
117
|
if (predTokens.length === 0 || goldTokens.length === 0) {
|
|
@@ -144,26 +144,6 @@ function f1PassThreshold(): number {
|
|
|
144
144
|
return v
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
/**
|
|
148
|
-
* Parse the worker artifact into the final answer string.
|
|
149
|
-
* Order: the `FINAL ANSWER:` sentinel first (deterministic-extraction discipline);
|
|
150
|
-
* fall back to the trimmed last non-empty line. Returns '' when nothing is
|
|
151
|
-
* parseable (fail-closed — never guess), which judge() counts as resolved=false.
|
|
152
|
-
*/
|
|
153
|
-
export function parseFinalAnswer(artifact: string): string {
|
|
154
|
-
const lines = artifact.split(/\r?\n/)
|
|
155
|
-
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
156
|
-
const line = lines[i] ?? ''
|
|
157
|
-
const idx = line.toUpperCase().indexOf(FINAL_ANSWER_SENTINEL)
|
|
158
|
-
if (idx !== -1) return line.slice(idx + FINAL_ANSWER_SENTINEL.length).trim()
|
|
159
|
-
}
|
|
160
|
-
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
161
|
-
const t = (lines[i] ?? '').trim()
|
|
162
|
-
if (t.length > 0) return t
|
|
163
|
-
}
|
|
164
|
-
return ''
|
|
165
|
-
}
|
|
166
|
-
|
|
167
147
|
function rowToTask(row: HotpotRow): BenchTask {
|
|
168
148
|
const meta: HotpotMeta = {
|
|
169
149
|
gold: row.answer,
|
|
@@ -292,13 +272,13 @@ print(json.dumps(out))
|
|
|
292
272
|
reason: 'no parseable answer',
|
|
293
273
|
em: false,
|
|
294
274
|
f1: 0,
|
|
295
|
-
normalizedGold:
|
|
275
|
+
normalizedGold: normalizeHotpotAnswer(meta.gold),
|
|
296
276
|
}),
|
|
297
277
|
}
|
|
298
278
|
}
|
|
299
279
|
|
|
300
280
|
const em = exactMatch(finalAnswer, meta.gold)
|
|
301
|
-
const f1 =
|
|
281
|
+
const f1 = hotpotTokenF1(finalAnswer, meta.gold)
|
|
302
282
|
const threshold = f1PassThreshold()
|
|
303
283
|
const resolved = em || f1 >= threshold
|
|
304
284
|
return {
|
|
@@ -308,8 +288,8 @@ print(json.dumps(out))
|
|
|
308
288
|
em,
|
|
309
289
|
f1,
|
|
310
290
|
threshold,
|
|
311
|
-
normalizedAnswer:
|
|
312
|
-
normalizedGold:
|
|
291
|
+
normalizedAnswer: normalizeHotpotAnswer(finalAnswer),
|
|
292
|
+
normalizedGold: normalizeHotpotAnswer(meta.gold),
|
|
313
293
|
type: meta.type,
|
|
314
294
|
level: meta.level,
|
|
315
295
|
supportingFacts: meta.supportingFacts,
|
|
@@ -4,6 +4,11 @@ import type { BenchScore, BenchTask, LoadOptions } from './types'
|
|
|
4
4
|
|
|
5
5
|
export const FINAL_ANSWER_SENTINEL = 'FINAL ANSWER:'
|
|
6
6
|
|
|
7
|
+
export interface ResearchAnswer {
|
|
8
|
+
finalAnswer: string
|
|
9
|
+
citations: string[]
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
export interface RagContext {
|
|
8
13
|
id: string
|
|
9
14
|
text: string
|
|
@@ -35,6 +40,12 @@ export const ragAnswerOutput: OutputAdapter<string> = {
|
|
|
35
40
|
},
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Parse the worker artifact into the final answer string.
|
|
45
|
+
* Order: the `FINAL ANSWER:` sentinel first (deterministic-extraction discipline);
|
|
46
|
+
* fall back to the last non-empty line. Returns '' when nothing is parseable
|
|
47
|
+
* (fail-closed — never guess), which judge() counts as resolved=false.
|
|
48
|
+
*/
|
|
38
49
|
export function parseFinalAnswer(artifact: string): string {
|
|
39
50
|
const lines = artifact.split(/\r?\n/)
|
|
40
51
|
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
@@ -49,6 +60,7 @@ export function parseFinalAnswer(artifact: string): string {
|
|
|
49
60
|
return ''
|
|
50
61
|
}
|
|
51
62
|
|
|
63
|
+
/** Extract cited URLs from a `CITATIONS:` block and any bare URLs in the artifact. */
|
|
52
64
|
export function parseCitations(artifact: string): string[] {
|
|
53
65
|
const urls = new Set<string>()
|
|
54
66
|
for (const match of artifact.matchAll(/https?:\/\/[^\s)<>"']+/g)) {
|
|
@@ -31,6 +31,7 @@ import { join } from 'node:path'
|
|
|
31
31
|
import { fileURLToPath } from 'node:url'
|
|
32
32
|
import { promisify } from 'node:util'
|
|
33
33
|
import { runBenchRouterTurn } from '../router-turn'
|
|
34
|
+
import { FINAL_ANSWER_SENTINEL, parseCitations, parseFinalAnswer } from './rag-shared'
|
|
34
35
|
import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
|
|
35
36
|
|
|
36
37
|
const execFileAsync = promisify(execFile)
|
|
@@ -40,7 +41,6 @@ const FIXTURES = join(BENCH_ROOT, 'fixtures', 'simpleqa.json')
|
|
|
40
41
|
|
|
41
42
|
const DATASET_URL =
|
|
42
43
|
'https://openaipublic.blob.core.windows.net/simple-evals/simple_qa_test_set.csv'
|
|
43
|
-
const FINAL_ANSWER_SENTINEL = 'FINAL ANSWER:'
|
|
44
44
|
|
|
45
45
|
/** Worker contract appended to every task prompt. Answer extraction keys off the sentinel. */
|
|
46
46
|
const WORKER_CONTRACT = [
|
|
@@ -58,7 +58,7 @@ const WORKER_CONTRACT = [
|
|
|
58
58
|
* agent runs into a {@link ResearchAnswer} and serializes `finalAnswer` (+ an
|
|
59
59
|
* optional `CITATIONS:` block) into that string before judging.
|
|
60
60
|
*/
|
|
61
|
-
export interface
|
|
61
|
+
export interface SimpleQaTask {
|
|
62
62
|
id: string
|
|
63
63
|
question: string
|
|
64
64
|
/** Gold short answer — the grader's target. */
|
|
@@ -71,11 +71,6 @@ export interface ResearchTask {
|
|
|
71
71
|
answerType: string
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export interface ResearchAnswer {
|
|
75
|
-
finalAnswer: string
|
|
76
|
-
citations: string[]
|
|
77
|
-
}
|
|
78
|
-
|
|
79
74
|
/** Normalized fixture/loader row — the single shape both the CSV loader and fixtures emit. */
|
|
80
75
|
interface SimpleQaRow {
|
|
81
76
|
problem: string
|
|
@@ -104,35 +99,6 @@ async function py(script: string, args: string[] = []): Promise<string> {
|
|
|
104
99
|
return stdout
|
|
105
100
|
}
|
|
106
101
|
|
|
107
|
-
/**
|
|
108
|
-
* Parse the worker artifact into the final answer string.
|
|
109
|
-
* Order: the `FINAL ANSWER:` sentinel first (deterministic-extraction discipline);
|
|
110
|
-
* fall back to the last non-empty line. Returns '' when nothing is parseable
|
|
111
|
-
* (fail-closed — never guess); judge() grades '' as NOT_ATTEMPTED.
|
|
112
|
-
*/
|
|
113
|
-
export function parseFinalAnswer(artifact: string): string {
|
|
114
|
-
const lines = artifact.split(/\r?\n/)
|
|
115
|
-
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
116
|
-
const line = lines[i] ?? ''
|
|
117
|
-
const idx = line.toUpperCase().indexOf(FINAL_ANSWER_SENTINEL)
|
|
118
|
-
if (idx !== -1) return line.slice(idx + FINAL_ANSWER_SENTINEL.length).trim()
|
|
119
|
-
}
|
|
120
|
-
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
121
|
-
const t = (lines[i] ?? '').trim()
|
|
122
|
-
if (t.length > 0) return t
|
|
123
|
-
}
|
|
124
|
-
return ''
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** Extract every bare URL in the artifact (CITATIONS: block + inline). SOFT provenance signal. */
|
|
128
|
-
export function parseCitations(artifact: string): string[] {
|
|
129
|
-
const urls = new Set<string>()
|
|
130
|
-
for (const m of artifact.matchAll(/https?:\/\/[^\s)<>"']+/g)) {
|
|
131
|
-
urls.add(m[0].replace(/[.,;]+$/, ''))
|
|
132
|
-
}
|
|
133
|
-
return [...urls]
|
|
134
|
-
}
|
|
135
|
-
|
|
136
102
|
/**
|
|
137
103
|
* The official SimpleQA grader prompt (faithful paraphrase of OpenAI's
|
|
138
104
|
* simple-evals GRADER_TEMPLATE). Classifies the predicted answer against the
|
package/src/commit0-prereqs.sh
CHANGED
|
File without changes
|
package/src/corpus-replay.mts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Two jobs, both READ-ONLY against the corpus:
|
|
7
7
|
*
|
|
8
|
-
* 1. REPLAY - for each
|
|
8
|
+
* 1. REPLAY - for each BenchRunRecord, take the recorded FINAL output and either
|
|
9
9
|
* (a) recompute the structural verdict from the stored per-attempt verdicts
|
|
10
10
|
* (default, zero model tokens) - proves the corpus is structurally
|
|
11
11
|
* replayable: the stored `resolved` matches the stored attempt verdicts; or
|
|
@@ -32,7 +32,7 @@ import { argv } from 'node:process'
|
|
|
32
32
|
import { fileURLToPath } from 'node:url'
|
|
33
33
|
import type { BenchmarkAdapter, BenchScore, BenchTask } from './benchmarks/types'
|
|
34
34
|
import { ADAPTERS } from './adapters'
|
|
35
|
-
import type {
|
|
35
|
+
import type { BenchRunRecord } from './corpus'
|
|
36
36
|
import { selfConsistencySelect, summarizeSelector, summarizeVerifierSelector } from './selector'
|
|
37
37
|
|
|
38
38
|
/** The benchmark's own judge - the EXTERNAL, write-only anchor (learning-flywheel.md). */
|
|
@@ -43,7 +43,7 @@ export type Judge = (task: BenchTask, artifact: string) => Promise<BenchScore>
|
|
|
43
43
|
* produced an output. Returns undefined when no attempt produced one (every round
|
|
44
44
|
* errored / blank) - the caller treats that as an unreplayable record, not a pass.
|
|
45
45
|
*/
|
|
46
|
-
export function finalOutput(record:
|
|
46
|
+
export function finalOutput(record: BenchRunRecord): string | undefined {
|
|
47
47
|
for (let i = record.attempts.length - 1; i >= 0; i -= 1) {
|
|
48
48
|
const out = record.attempts[i]?.output
|
|
49
49
|
if (typeof out === 'string' && out.length > 0) return out
|
|
@@ -52,7 +52,7 @@ export function finalOutput(record: RunRecord): string | undefined {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/** The stored structural verdict for the final attempt (its `valid` flag). */
|
|
55
|
-
function storedFinalValid(record:
|
|
55
|
+
function storedFinalValid(record: BenchRunRecord): boolean {
|
|
56
56
|
for (let i = record.attempts.length - 1; i >= 0; i -= 1) {
|
|
57
57
|
const a = record.attempts[i]
|
|
58
58
|
if (a?.output !== undefined && a.output.length > 0) return a.valid === true
|
|
@@ -77,7 +77,7 @@ function storedFinalValid(record: RunRecord): boolean {
|
|
|
77
77
|
* was used to score the corpus so offline and online scores are comparable.
|
|
78
78
|
*/
|
|
79
79
|
export async function scoreCandidateOffline(
|
|
80
|
-
record:
|
|
80
|
+
record: BenchRunRecord,
|
|
81
81
|
candidateOutput: string,
|
|
82
82
|
judge: Judge,
|
|
83
83
|
task: BenchTask,
|
|
@@ -92,7 +92,7 @@ export async function scoreCandidateOffline(
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/** Parse the corpus JSONL; fail loud on empty/unreadable. */
|
|
95
|
-
async function readCorpus(corpusPath: string): Promise<
|
|
95
|
+
async function readCorpus(corpusPath: string): Promise<BenchRunRecord[]> {
|
|
96
96
|
let raw: string
|
|
97
97
|
try {
|
|
98
98
|
raw = await readFile(corpusPath, 'utf8')
|
|
@@ -106,7 +106,7 @@ async function readCorpus(corpusPath: string): Promise<RunRecord[]> {
|
|
|
106
106
|
if (lines.length === 0) throw new Error(`corpus-replay: corpus ${corpusPath} is empty - nothing to replay`)
|
|
107
107
|
return lines.map((l, i) => {
|
|
108
108
|
try {
|
|
109
|
-
return JSON.parse(l) as
|
|
109
|
+
return JSON.parse(l) as BenchRunRecord
|
|
110
110
|
} catch (err) {
|
|
111
111
|
throw new Error(`corpus-replay: corpus ${corpusPath} line ${i + 1} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`)
|
|
112
112
|
}
|
|
@@ -136,7 +136,7 @@ async function main(): Promise<void> {
|
|
|
136
136
|
const records = await readCorpus(corpusPath)
|
|
137
137
|
|
|
138
138
|
// Group by benchmark so each adapter judges only its own records.
|
|
139
|
-
const byBench = new Map<string,
|
|
139
|
+
const byBench = new Map<string, BenchRunRecord[]>()
|
|
140
140
|
for (const r of records) {
|
|
141
141
|
const bench = benchOverride ?? r.benchmark
|
|
142
142
|
const list = byBench.get(bench)
|