@tangle-network/agent-bench 0.14.4 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +2 -3
  3. package/dist/adapters.d.ts +2 -5
  4. package/dist/adapters.js +3 -4
  5. package/dist/benchmarks/_harness.d.ts +17 -20
  6. package/dist/benchmarks/_harness.js +4 -4
  7. package/dist/benchmarks/_harness.js.map +1 -1
  8. package/dist/benchmarks/aec-bench.d.ts +1 -4
  9. package/dist/benchmarks/aec-bench.js +1 -2
  10. package/dist/benchmarks/agentbench.d.ts +2 -5
  11. package/dist/benchmarks/agentbench.js +1 -2
  12. package/dist/benchmarks/appworld.d.ts +8 -10
  13. package/dist/benchmarks/appworld.js +23 -23
  14. package/dist/benchmarks/appworld.js.map +1 -1
  15. package/dist/benchmarks/bfcl.d.ts +2 -5
  16. package/dist/benchmarks/bfcl.js +1 -2
  17. package/dist/benchmarks/cad-design.d.ts +2 -5
  18. package/dist/benchmarks/cad-design.js +2 -3
  19. package/dist/benchmarks/cad-design.js.map +1 -1
  20. package/dist/benchmarks/cadbench.d.ts +1 -4
  21. package/dist/benchmarks/cadbench.js +1 -2
  22. package/dist/benchmarks/cadgenbench.d.ts +1 -4
  23. package/dist/benchmarks/cadgenbench.js +1 -2
  24. package/dist/benchmarks/commit0.d.ts +2 -5
  25. package/dist/benchmarks/commit0.js +1 -2
  26. package/dist/benchmarks/crag.d.ts +1 -4
  27. package/dist/benchmarks/crag.js +3 -3
  28. package/dist/benchmarks/crag.js.map +1 -1
  29. package/dist/benchmarks/dabstep.d.ts +2 -5
  30. package/dist/benchmarks/dabstep.js +2 -3
  31. package/dist/benchmarks/dabstep.js.map +1 -1
  32. package/dist/benchmarks/enterpriseops-gym.d.ts +2 -5
  33. package/dist/benchmarks/enterpriseops-gym.js +1 -2
  34. package/dist/benchmarks/finresearchbench.d.ts +2 -5
  35. package/dist/benchmarks/finresearchbench.js +2 -3
  36. package/dist/benchmarks/finsearchcomp.d.ts +2 -5
  37. package/dist/benchmarks/finsearchcomp.js +4 -4
  38. package/dist/benchmarks/finsearchcomp.js.map +1 -1
  39. package/dist/benchmarks/frames.d.ts +3 -19
  40. package/dist/benchmarks/frames.js +13 -39
  41. package/dist/benchmarks/frames.js.map +1 -1
  42. package/dist/benchmarks/hotpotqa.d.ts +4 -14
  43. package/dist/benchmarks/hotpotqa.js +12 -32
  44. package/dist/benchmarks/hotpotqa.js.map +1 -1
  45. package/dist/benchmarks/humaneval.d.ts +9 -12
  46. package/dist/benchmarks/humaneval.js +2 -3
  47. package/dist/benchmarks/humaneval.js.map +1 -1
  48. package/dist/benchmarks/mcad-bench.d.ts +13 -16
  49. package/dist/benchmarks/mcad-bench.js +2 -3
  50. package/dist/benchmarks/mcad-bench.js.map +1 -1
  51. package/dist/benchmarks/mcad-cq-bench.d.ts +17 -20
  52. package/dist/benchmarks/mcad-cq-bench.js +2 -3
  53. package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
  54. package/dist/benchmarks/mcad-cq-golds.d.ts +2 -5
  55. package/dist/benchmarks/mcad-cq-golds.js +1 -2
  56. package/dist/benchmarks/mcad-golds.d.ts +1 -4
  57. package/dist/benchmarks/mcad-golds.js +0 -1
  58. package/dist/benchmarks/mcad-tasks.d.ts +5 -8
  59. package/dist/benchmarks/mcad-tasks.js +7 -8
  60. package/dist/benchmarks/mcad-tasks.js.map +1 -1
  61. package/dist/benchmarks/mind2web.d.ts +3 -5
  62. package/dist/benchmarks/mind2web.js +2 -3
  63. package/dist/benchmarks/mind2web.js.map +1 -1
  64. package/dist/benchmarks/nomiracl.d.ts +1 -4
  65. package/dist/benchmarks/nomiracl.js +1 -2
  66. package/dist/benchmarks/open-rag-bench.d.ts +1 -4
  67. package/dist/benchmarks/open-rag-bench.js +3 -3
  68. package/dist/benchmarks/open-rag-bench.js.map +1 -1
  69. package/dist/benchmarks/programbench.d.ts +2 -5
  70. package/dist/benchmarks/programbench.js +1 -2
  71. package/dist/benchmarks/rag-shared.d.ts +30 -22
  72. package/dist/benchmarks/rag-shared.js +8 -2
  73. package/dist/benchmarks/rag-shared.js.map +1 -1
  74. package/dist/benchmarks/ragbench.d.ts +1 -4
  75. package/dist/benchmarks/ragbench.js +3 -3
  76. package/dist/benchmarks/ragbench.js.map +1 -1
  77. package/dist/benchmarks/simpleqa.d.ts +2 -18
  78. package/dist/benchmarks/simpleqa.js +5 -31
  79. package/dist/benchmarks/simpleqa.js.map +1 -1
  80. package/dist/benchmarks/swe-bench.d.ts +7 -10
  81. package/dist/benchmarks/swe-bench.js +4 -4
  82. package/dist/benchmarks/swe-bench.js.map +1 -1
  83. package/dist/benchmarks/t2-ragbench.d.ts +1 -4
  84. package/dist/benchmarks/t2-ragbench.js +3 -3
  85. package/dist/benchmarks/t2-ragbench.js.map +1 -1
  86. package/dist/benchmarks/tau-bench-shared.d.ts +5 -8
  87. package/dist/benchmarks/tau-bench-shared.js +4 -4
  88. package/dist/benchmarks/tau-bench-shared.js.map +1 -1
  89. package/dist/benchmarks/tau2-bench.d.ts +2 -5
  90. package/dist/benchmarks/tau2-bench.js +1 -2
  91. package/dist/benchmarks/tau3-banking.d.ts +1 -4
  92. package/dist/benchmarks/tau3-banking.js +1 -2
  93. package/dist/benchmarks/terminal-bench.d.ts +1 -4
  94. package/dist/benchmarks/terminal-bench.js +4 -4
  95. package/dist/benchmarks/terminal-bench.js.map +1 -1
  96. package/dist/benchmarks/toollm.d.ts +2 -5
  97. package/dist/benchmarks/toollm.js +1 -2
  98. package/dist/benchmarks/trata-hedge.d.ts +1 -4
  99. package/dist/benchmarks/trata-hedge.js +2 -3
  100. package/dist/benchmarks/types.d.ts +6 -9
  101. package/dist/benchmarks/webarena-verified.d.ts +2 -5
  102. package/dist/benchmarks/webarena-verified.js +1 -2
  103. package/dist/{cadbench-BRF-59Mt.js → cadbench-DhAndllg.js} +4 -6
  104. package/dist/cadbench-DhAndllg.js.map +1 -0
  105. package/dist/{cadgenbench-DXtGkuW3.js → cadgenbench-Tvk16YKT.js} +15 -5
  106. package/dist/cadgenbench-Tvk16YKT.js.map +1 -0
  107. package/dist/index.d.ts +8 -18
  108. package/dist/index.js +16 -24
  109. package/dist/index.js.map +1 -1
  110. package/dist/{router-turn-uTYO6KQ1.js → router-turn-DNbQ_GjQ.js} +2 -3
  111. package/dist/router-turn-DNbQ_GjQ.js.map +1 -0
  112. package/fixtures/pier-agent/no-model-task/pre_artifacts.sh +0 -0
  113. package/fixtures/pier-agent/no-model-task/tests/test.sh +0 -0
  114. package/package.json +10 -10
  115. package/pier_agents/tangle_candidate.py +15 -23
  116. package/scripts/run-package-tests.mjs +8 -15
  117. package/src/atom-mcp-e2e.mts +2 -2
  118. package/src/benchmarks/frames.ts +10 -44
  119. package/src/benchmarks/hotpotqa.ts +9 -29
  120. package/src/benchmarks/rag-shared.ts +12 -0
  121. package/src/benchmarks/simpleqa.ts +2 -36
  122. package/src/commit0-prereqs.sh +0 -0
  123. package/src/corpus-replay.mts +8 -8
  124. package/src/corpus-report.mts +21 -21
  125. package/src/corpus.test.mts +5 -5
  126. package/src/corpus.ts +16 -16
  127. package/src/directives.ts +0 -38
  128. package/src/examples/lean-verify.ts +1 -1
  129. package/src/gate.ts +7 -7
  130. package/src/generate-eval/certify.ts +2 -2
  131. package/src/index.ts +1 -0
  132. package/src/refine-loop.ts +5 -5
  133. package/src/resolve-client.ts +1 -1
  134. package/src/router-turn.ts +3 -11
  135. package/src/run-pool.ts +1 -1
  136. package/src/runtime-hook-recorder.ts +2 -2
  137. package/src/search-bench/tasks.ts +1 -1
  138. package/src/selector.test.mts +13 -13
  139. package/src/selector.ts +19 -19
  140. package/src/swe-bench-env.ts +4 -12
  141. package/src/swe-jail.ts +5 -156
  142. package/src/swe-structural-judge-policy.ts +3 -3
  143. package/src/swe-structural-policy.ts +3 -3
  144. package/src/swe-structural-provenance.ts +4 -4
  145. package/src/terminal-compare.ts +10 -10
  146. package/src/worker-blender.ts +2 -106
  147. package/src/worker-build123d.ts +2 -81
  148. package/tb_agents/opencode_router_agent.py +1 -1
  149. package/dist/cadbench-BRF-59Mt.js.map +0 -1
  150. package/dist/cadgenbench-DXtGkuW3.js.map +0 -1
  151. package/dist/router-turn-uTYO6KQ1.js.map +0 -1
  152. package/scripts/cadbench_prepare.py +0 -22
  153. package/scripts/cadgenbench_hard_parts.py +0 -48
  154. package/scripts/clbench_codebase_judge.py +0 -73
  155. package/scripts/render-gate-chart.mjs +0 -176
  156. package/scripts/trata-hedge/README.md +0 -57
  157. package/scripts/trata-hedge/run.sh +0 -64
  158. package/src/cloud-loop.mts +0 -156
  159. package/src/coordination-mcp-container-reach.mts +0 -182
  160. package/src/fleet.mts +0 -143
  161. package/src/hev-structural.mts +0 -697
  162. package/src/humaneval-gate.mts +0 -220
  163. package/src/mbpp-structural.mts +0 -676
  164. package/src/mcp-mount-probe.mts +0 -141
  165. package/src/profiles.ts +0 -128
  166. package/src/research-gate.mts +0 -132
  167. package/src/research-shot.ts +0 -144
  168. package/src/router-executor.ts +0 -51
  169. package/src/sandbox-run.ts +0 -108
  170. package/src/search-bench/bridge.ts +0 -182
  171. package/src/search-bench/export.mts +0 -0
  172. package/src/search-bench/parametric-check.mts +0 -78
  173. package/src/search-bench/profiles.ts +0 -113
  174. package/src/search-bench/run.mts +0 -286
  175. package/src/search-bench/tasks-fresh.ts +0 -688
  176. package/src/smoke-structural-rollout.mts +0 -415
  177. package/src/stats.mts +0 -90
  178. package/src/swe-code-improve.mts +0 -306
  179. package/src/swe-improve.mts +0 -284
  180. package/src/swe-structural.mts +0 -707
  181. package/src/tb-container-executor.mts +0 -266
  182. package/src/tb-container-executor.test.mts +0 -134
  183. package/src/tb-supervisor-sidecar.mts +0 -208
  184. package/src/trata-gepa.mts +0 -381
  185. package/src/trata-hedge-solve.mts +0 -81
  186. package/tb_agents/opencode_refine_agent.py +0 -117
  187. 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
- //#region src/router-turn.ts
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-uTYO6KQ1.js.map
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-bench",
3
- "version": "0.14.4",
3
+ "version": "1.0.2",
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": ">=0.214.0 <0.215.0",
29
- "@tangle-network/agent-interface": "^5.2.1",
30
- "@tangle-network/agent-knowledge": "^22.0.2",
31
- "@tangle-network/sandbox": ">=0.60.49 <0.61.0",
32
- "@tangle-network/agent-runtime": "^0.321.0"
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.1",
32
+ "@tangle-network/sandbox": "^1.0.233"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@arethetypeswrong/cli": "0.18.5",
36
- "@types/node": "26.4.0",
37
- "publint": "0.3.24",
38
- "tsdown": "0.22.14",
39
- "tsx": "4.23.12",
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
- current = parsed_anchor
408
- relative_parts = parsed.relative_to(parsed_anchor).parts
409
- for part in relative_parts:
410
- current /= part
411
- value = str(current)
412
- quoted = shlex.quote(value)
413
- await self._exec(
414
- environment,
415
- "\n".join(
416
- [
417
- "set -eu",
418
- f"if test -e {quoted} || test -L {quoted}; then",
419
- f" test -d {quoted}",
420
- f" test ! -L {quoted}",
421
- "else",
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 { access, readdir, readFile, realpath } from 'node:fs/promises'
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(`${invocation} failed: ${message}`, { cause: 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 = path.join(benchDir, '.venv', 'bin', 'python')
79
- try {
80
- await access(python)
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
- ...process.env,
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`,
@@ -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?.prompt.systemPrompt ?? TASK
126
+ const sys = p ? assessAuthoredProfile(p).systemPrompt : TASK
127
127
  const run = await runInWorkspace(
128
128
  ws,
129
129
  async (cwd) => {
@@ -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 ResearchTask {
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 normalizeAnswer(input: string): string {
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 = normalizeAnswer(candidate)
237
- const ng = normalizeAnswer(gold)
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: normalizeAnswer(meta.gold),
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: normalizeAnswer(finalAnswer),
500
- normalizedGold: normalizeAnswer(meta.gold),
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: normalizeAnswer(finalAnswer),
514
- normalizedGold: normalizeAnswer(meta.gold),
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 normalizeAnswer(input: string): string {
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 = normalizeAnswer(input)
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 normalizeAnswer(prediction) === normalizeAnswer(gold)
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 tokenF1(prediction: string, gold: string): number {
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: normalizeAnswer(meta.gold),
275
+ normalizedGold: normalizeHotpotAnswer(meta.gold),
296
276
  }),
297
277
  }
298
278
  }
299
279
 
300
280
  const em = exactMatch(finalAnswer, meta.gold)
301
- const f1 = tokenF1(finalAnswer, meta.gold)
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: normalizeAnswer(finalAnswer),
312
- normalizedGold: normalizeAnswer(meta.gold),
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 ResearchTask {
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
File without changes
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Two jobs, both READ-ONLY against the corpus:
7
7
  *
8
- * 1. REPLAY - for each RunRecord, take the recorded FINAL output and either
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 { RunRecord } from './corpus'
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: RunRecord): string | undefined {
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: RunRecord): boolean {
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: RunRecord,
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<RunRecord[]> {
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 RunRecord
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, RunRecord[]>()
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)