@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.
Files changed (218) hide show
  1. package/CHANGELOG.md +48 -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/scripts/verify-packed-consumer.mjs +0 -1
  118. package/src/atom-mcp-e2e.mts +16 -4
  119. package/src/benchmarks/frames.ts +10 -44
  120. package/src/benchmarks/hotpotqa.ts +9 -29
  121. package/src/benchmarks/rag-shared.ts +12 -0
  122. package/src/benchmarks/simpleqa.ts +2 -36
  123. package/src/commit0-prereqs.sh +0 -0
  124. package/src/corpus-replay.mts +8 -8
  125. package/src/corpus-report.mts +21 -21
  126. package/src/corpus.test.mts +5 -5
  127. package/src/corpus.ts +16 -16
  128. package/src/directives.ts +0 -38
  129. package/src/examples/lean-verify.ts +1 -1
  130. package/src/gate.ts +8 -8
  131. package/src/generate-eval/certify.ts +2 -2
  132. package/src/index.ts +1 -0
  133. package/src/refine-loop.ts +5 -5
  134. package/src/resolve-client.ts +1 -1
  135. package/src/router-turn.ts +3 -11
  136. package/src/run-benchmarks.test.mts +0 -4
  137. package/src/run-pool.ts +1 -1
  138. package/src/runtime-hook-recorder.ts +2 -2
  139. package/src/search-bench/tasks.ts +1 -1
  140. package/src/selector.test.mts +13 -13
  141. package/src/selector.ts +19 -19
  142. package/src/swe-bench-env.ts +4 -12
  143. package/src/swe-jail.ts +5 -156
  144. package/src/swe-structural-judge-policy.ts +3 -3
  145. package/src/swe-structural-policy.ts +3 -3
  146. package/src/swe-structural-provenance.ts +4 -4
  147. package/src/terminal-compare.ts +10 -10
  148. package/src/worker-blender.ts +2 -106
  149. package/src/worker-build123d.ts +2 -81
  150. package/tb_agents/opencode_router_agent.py +1 -1
  151. package/dist/cadbench-BRF-59Mt.js.map +0 -1
  152. package/dist/cadgenbench-DXtGkuW3.js.map +0 -1
  153. package/dist/router-turn-uTYO6KQ1.js.map +0 -1
  154. package/scripts/cadbench_prepare.py +0 -22
  155. package/scripts/cadgenbench_hard_parts.py +0 -48
  156. package/scripts/clbench_codebase_judge.py +0 -73
  157. package/scripts/render-gate-chart.mjs +0 -176
  158. package/scripts/trata-hedge/README.md +0 -57
  159. package/scripts/trata-hedge/run.sh +0 -64
  160. package/src/browser/adapters/bad-design-audit.ts +0 -153
  161. package/src/browser/adapters/bad-design-audit.verify.ts +0 -85
  162. package/src/browser/adapters/bad.ts +0 -165
  163. package/src/browser/agent-adapter.ts +0 -145
  164. package/src/browser/process-adapter.ts +0 -146
  165. package/src/browser/run-to-spans.ts +0 -105
  166. package/src/browser/run-to-spans.verify.ts +0 -89
  167. package/src/browser/ui-reviewer.ts +0 -200
  168. package/src/browser/ui-reviewer.verify.ts +0 -94
  169. package/src/browser/verify.ts +0 -96
  170. package/src/clbench-codebase-gate.mts +0 -314
  171. package/src/clbench-context-gate.mts +0 -341
  172. package/src/cloud-loop.mts +0 -156
  173. package/src/commit0-env-run.mts +0 -62
  174. package/src/commit0-env.ts +0 -172
  175. package/src/commit0-gate.mts +0 -558
  176. package/src/coordination-mcp-container-reach.mts +0 -182
  177. package/src/egress-probe.mts +0 -26
  178. package/src/fleet.mts +0 -143
  179. package/src/hev-structural.mts +0 -697
  180. package/src/humaneval-gate.mts +0 -220
  181. package/src/humaneval-repair-gate.mts +0 -182
  182. package/src/mbpp-structural.mts +0 -676
  183. package/src/mcp-mount-probe.mts +0 -139
  184. package/src/profile-coordinates.ts +0 -134
  185. package/src/profiles.ts +0 -128
  186. package/src/research-gate.mts +0 -132
  187. package/src/research-shot.ts +0 -144
  188. package/src/router-executor.ts +0 -51
  189. package/src/run-benchmarks-report.ts +0 -66
  190. package/src/sandbox-run.ts +0 -108
  191. package/src/search-bench/bridge.ts +0 -182
  192. package/src/search-bench/export.mts +0 -0
  193. package/src/search-bench/parametric-check.mts +0 -78
  194. package/src/search-bench/profiles.ts +0 -113
  195. package/src/search-bench/run.mts +0 -286
  196. package/src/search-bench/tasks-fresh.ts +0 -688
  197. package/src/skill-sandbox-smoke.mts +0 -101
  198. package/src/smoke-structural-rollout.mts +0 -415
  199. package/src/stats.mts +0 -90
  200. package/src/supervisor-arena.mts +0 -825
  201. package/src/swe-code-improve.mts +0 -306
  202. package/src/swe-emit-patch.mts +0 -125
  203. package/src/swe-improve.mts +0 -284
  204. package/src/swe-local-proof.mts +0 -265
  205. package/src/swe-repro-calibrate.mts +0 -451
  206. package/src/swe-stream.mts +0 -1561
  207. package/src/swe-structural.mts +0 -707
  208. package/src/tb-container-executor.mts +0 -266
  209. package/src/tb-container-executor.test.mts +0 -134
  210. package/src/tb-supervisor-sidecar.mts +0 -208
  211. package/src/trajectory-assemble.mjs +0 -130
  212. package/src/trata-gepa.mts +0 -381
  213. package/src/trata-hedge-solve.mts +0 -81
  214. package/src/worker-browser.ts +0 -115
  215. package/src/worker-cad.ts +0 -470
  216. package/src/workspace-loop.mts +0 -133
  217. package/tb_agents/opencode_refine_agent.py +0 -117
  218. package/tb_agents/opencode_supervisor_agent.py +0 -239
@@ -1,144 +0,0 @@
1
- /**
2
- * One research rollout as a reusable primitive: 2-step RAG — (1) provider-pinned web
3
- * search via the router's proven `/v1/search?provider=<id>` + `web_fetch` of the top-K
4
- * result pages, (2) answer with that evidence through Runtime's profile-bound turn (no tools on the
5
- * answer call → `content` always present, so a search arm differs from the parametric
6
- * control ONLY by the evidence). Pure router HTTP (bearer `TANGLE_API_KEY`).
7
- *
8
- * Shared by the off-sandbox RAG leaderboard (`research-gate.mts`) and the router-backed
9
- * loop executor (`router-executor.ts`), so both score the identical retrieve→answer body
10
- * — the only difference is who drives the rounds (a flat best-of-k pool vs the real
11
- * `runAgentRounds` kernel with analyst steering).
12
- */
13
- import { runBenchRouterTurn } from './router-turn'
14
-
15
- export interface ShotCfg {
16
- model: string
17
- /** search provider id: 'default'/'off'/'none' = no search (parametric control); else a router provider. */
18
- search: string
19
- maxResults: number
20
- /** how many top search URLs to web_fetch full page content for (0 = snippets only). */
21
- fetchTopK: number
22
- temperature: number
23
- routerBaseUrl: string
24
- routerKey: string
25
- timeoutMs: number
26
- }
27
-
28
- export interface Shot {
29
- taskId: string
30
- attempt: number
31
- answer: string
32
- ok: boolean
33
- detail?: string
34
- wallMs: number
35
- /** count of search hits retrieved (0 ⇒ no search happened / it failed). */
36
- searches: number
37
- }
38
-
39
- /** Fetch a URL's extracted page text via the router web_fetch MCP tool. Returns '' on any failure. */
40
- export async function fetchPage(url: string, cfg: ShotCfg): Promise<string> {
41
- try {
42
- const res = await fetch(`${cfg.routerBaseUrl}/search/mcp?provider=${encodeURIComponent(cfg.search)}`, {
43
- method: 'POST',
44
- headers: { 'content-type': 'application/json', authorization: `Bearer ${cfg.routerKey}` },
45
- body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'web_fetch', arguments: { url } } }),
46
- ...(cfg.timeoutMs ? { signal: AbortSignal.timeout(Math.min(cfg.timeoutMs, 60_000)) } : {}),
47
- })
48
- if (!res.ok) return ''
49
- const body = (await res.json()) as { result?: { content?: Array<{ text?: string }> } }
50
- const text = body.result?.content?.[0]?.text ?? ''
51
- // The tool returns a JSON string {url,title,content}; pull `content` if parseable, else the raw text.
52
- try {
53
- const parsed = JSON.parse(text) as { content?: string }
54
- return (parsed.content ?? text).slice(0, 2500)
55
- } catch {
56
- return text.slice(0, 2500)
57
- }
58
- } catch {
59
- return ''
60
- }
61
- }
62
-
63
- /**
64
- * One research rollout, 2-step RAG against `prompt` (the task question, possibly with a
65
- * steer appended): (1) provider-pinned web search + web_fetch of the top-K pages, (2)
66
- * answer with that evidence. The search query is the clean question (first non-empty
67
- * line) — appended worker-contract / steer boilerplate pollutes the query and returns 0
68
- * hits — while the ANSWER sees the full `prompt` so a steer round can act on it. The
69
- * COMMIT prompt stops the model deferring ("may I search?"), which otherwise scores 0.
70
- * Fault-isolated: a flaky call → a NO-ANSWER `Shot`, never a throw.
71
- */
72
- export async function runResearchShot(prompt: string, taskId: string, attempt: number, cfg: ShotCfg): Promise<Shot> {
73
- const startedAt = Date.now()
74
- const useSearch = cfg.search !== 'default' && cfg.search !== 'off' && cfg.search !== 'none'
75
- let searches = 0
76
- try {
77
- // 1) Provider-pinned web search (proven /v1/search). The control arm skips this.
78
- let context = ''
79
- if (useSearch) {
80
- const query = (prompt.split('\n').find((l) => l.trim().length > 0) ?? prompt).slice(0, 300)
81
- const sres = await fetch(`${cfg.routerBaseUrl}/search?provider=${encodeURIComponent(cfg.search)}`, {
82
- method: 'POST',
83
- headers: { 'content-type': 'application/json', authorization: `Bearer ${cfg.routerKey}` },
84
- body: JSON.stringify({ query, count: cfg.maxResults }),
85
- ...(cfg.timeoutMs ? { signal: AbortSignal.timeout(cfg.timeoutMs) } : {}),
86
- })
87
- if (!sres.ok) {
88
- // Surface, never silently degrade to parametric — a failed search must be visible.
89
- console.warn(` [search FAIL ${taskId}#${attempt}] HTTP ${sres.status}: ${(await sres.text()).slice(0, 140)}`)
90
- } else {
91
- const sb = (await sres.json()) as { data?: Array<{ title?: string; url?: string; snippet?: string }> }
92
- const hits = sb.data ?? []
93
- searches = hits.length
94
- // Fetch the full page text of the top-K results (snippets rarely carry exact figures).
95
- const fetched = await Promise.all(hits.slice(0, cfg.fetchTopK).map((h) => (h.url ? fetchPage(h.url, cfg) : Promise.resolve(''))))
96
- context = hits
97
- .map((h, i) => `[${i + 1}] ${h.title ?? ''}\n${h.snippet ?? ''}\n${h.url ?? ''}${fetched[i] ? `\nPAGE CONTENT:\n${fetched[i]}` : ''}`)
98
- .join('\n\n')
99
- }
100
- }
101
-
102
- // 2) Answer — no tools (content always present), COMMIT (no deferral), via the shared router primitive.
103
- const commit =
104
- 'You have no further tools and cannot ask questions or request more research. ' +
105
- 'Output a SINGLE, FINAL answer to the question, leading with the value in the exact units and precision requested ' +
106
- '(e.g. "Answer: -47.9 billion USD"). ' +
107
- (useSearch
108
- ? 'Use the WEB SEARCH RESULTS below (snippets + fetched page content) as your primary evidence; cite the source. '
109
- : 'Answer from your own knowledge. ') +
110
- 'If you are not fully certain, still COMMIT to your single best estimate — never refuse, defer, or reply with a question.'
111
- const userContent = useSearch && context ? `${prompt}\n\n=== WEB SEARCH RESULTS (provider: ${cfg.search}) ===\n${context}` : prompt
112
- const turn = await runBenchRouterTurn(
113
- {
114
- routerBaseUrl: cfg.routerBaseUrl,
115
- routerKey: cfg.routerKey,
116
- profile: {
117
- name: 'research-shot-answerer',
118
- harness: 'cli-base',
119
- model: {
120
- provider: 'tangle-router',
121
- default: cfg.model,
122
- metadata: { temperature: cfg.temperature },
123
- },
124
- prompt: { systemPrompt: commit },
125
- },
126
- ...(cfg.timeoutMs ? { timeoutMs: cfg.timeoutMs } : {}),
127
- },
128
- userContent,
129
- )
130
- const answer = turn.finalText.trim()
131
- const ok = answer.length > 0
132
- return { taskId, attempt, answer, ok, searches, wallMs: Date.now() - startedAt, ...(ok ? {} : { detail: `empty answer (searches=${searches})` }) }
133
- } catch (err) {
134
- return {
135
- taskId,
136
- attempt,
137
- answer: '',
138
- ok: false,
139
- searches,
140
- wallMs: Date.now() - startedAt,
141
- detail: `rollout error: ${(err instanceof Error ? err.message : String(err)).slice(0, 200)}`,
142
- }
143
- }
144
- }
@@ -1,51 +0,0 @@
1
- /**
2
- * Router-backed research executor — the "router" cost-dial backend (experiment.ts:
3
- * "backend = the injected SandboxClient (router / bridge / sandbox)"). Each run is
4
- * ONE research shot (router web-search + answer, off-sandbox); its answer is the
5
- * terminal `finalText` the kernel's `answerOutput` parses.
6
- *
7
- * Why off-sandbox: research is retrieval, not in-box code execution — it never
8
- * needed a box, and a real sandbox box reaches only the router (egress allowlist,
9
- * ops-board #976), so it cannot web-search natively anyway. Driving the loop with
10
- * this executor instead of a box gives the REAL `runAgentRounds` kernel full `rounds` +
11
- * analyst steering (the depth regime), search working, no sandbox dependency.
12
- *
13
- * This is a BYO `Executor` over `runResearchShot`; `inlineSandboxClient` supplies
14
- * the one shared box-shell so this file owns only the research-shot specifics
15
- * (no hand-rolled create/streamPrompt/delete). A fresh executor per round ⇒ no
16
- * fork/live session; statefulness is the across-round steer, not a box.
17
- */
18
- import {
19
- type ExecutorFactory,
20
- type ExecutorResult,
21
- inlineSandboxClient,
22
- type SandboxClient,
23
- } from '@tangle-network/agent-runtime/kernel'
24
- import { runResearchShot, type ShotCfg } from './research-shot'
25
-
26
- export function routerSandboxClient(cfg: ShotCfg): SandboxClient {
27
- let seq = 0
28
- const factory: ExecutorFactory<unknown> = () => {
29
- const id = `router-research-${seq++}`
30
- let artifact: ExecutorResult<unknown> | undefined
31
- return {
32
- runtime: 'router',
33
- async execute(task): Promise<ExecutorResult<unknown>> {
34
- const started = Date.now()
35
- const shot = await runResearchShot(String(task), id, 0, cfg)
36
- artifact = {
37
- outRef: `router-research:${id}`,
38
- out: { content: shot.answer },
39
- spent: { iterations: 1, tokens: { input: 0, output: 0 }, usd: 0, ms: Date.now() - started },
40
- }
41
- return artifact
42
- },
43
- teardown: () => Promise.resolve({ destroyed: true }),
44
- resultArtifact() {
45
- if (!artifact) throw new Error('routerSandboxClient: resultArtifact() read before execute()')
46
- return artifact
47
- },
48
- }
49
- }
50
- return inlineSandboxClient(factory)
51
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * run-benchmarks-report — render a `runBenchmarks` result as a rich, multi-axis leaderboard (markdown +
3
- * SVG + HTML), with the BENCHMARKS as the axes. `runBenchmarks` (the registry matrix runner) already
4
- * returns a fixed-width CLI table; this bridges its per-task results into the domain-agnostic `leaderboard`
5
- * engine so the same run also yields a publishable board — every harness×model×persona cell scored on every
6
- * benchmark, the vals.ai-style surface.
7
- *
8
- * No new aggregation logic: it maps each `BenchCellTaskResult` into the universal `RunRecord` shape the
9
- * engine reads (cell → profile, benchmark → axis, score → score), then calls the shared renderers.
10
- * Errored shots (`ok:false`) are dropped, exactly as the runner excludes them from its own denominator.
11
- */
12
- import type { RunRecord } from '@tangle-network/agent-eval'
13
- import {
14
- type Leaderboard,
15
- leaderboard,
16
- renderLeaderboardHtml,
17
- renderLeaderboardMarkdown,
18
- renderLeaderboardSvg,
19
- } from '@tangle-network/agent-runtime/kernel'
20
- import type { BenchCellTaskResult, RunBenchmarksReport } from './run-benchmarks'
21
-
22
- /** Project the runner's per-task results into `RunRecord`s the leaderboard engine reads. Cost/tokens are
23
- * left at 0 — `runBenchmarks` does not meter them per task, so the board shows them as not-captured rather
24
- * than inventing a number. */
25
- function toRecords(perTask: readonly BenchCellTaskResult[]): RunRecord[] {
26
- return perTask
27
- .filter((t) => t.ok)
28
- .map(
29
- (t) =>
30
- ({
31
- runId: `${t.benchmark}:${t.cell}:${t.taskId}:${t.rep}`,
32
- experimentId: t.benchmark,
33
- candidateId: t.cell,
34
- seed: t.rep,
35
- // The cell label is `harness/model` (or a persona id); carry it as the model + harness so the
36
- // leaderboard's default profile key resolves to the cell.
37
- model: t.cell,
38
- promptHash: '',
39
- configHash: '',
40
- commitSha: '',
41
- wallMs: t.wallMs,
42
- costUsd: 0,
43
- tokenUsage: { input: 0, output: 0 },
44
- outcome: { holdoutScore: t.score, raw: { resolved: t.resolved ? 1 : 0 } },
45
- splitTag: 'holdout',
46
- scenarioId: t.benchmark,
47
- agentProfile: { harness: t.cell.split('/')[0] ?? t.cell, model: t.cell },
48
- }) as unknown as RunRecord,
49
- )
50
- }
51
-
52
- /** Build the rich leaderboard from a `runBenchmarks` result — benchmarks are the axes, cells are the rows. */
53
- export function benchmarksLeaderboard(
54
- report: RunBenchmarksReport,
55
- opts: { title?: string; meta?: Record<string, string> } = {},
56
- ): Leaderboard {
57
- return leaderboard(toRecords(report.perTask), {
58
- title: opts.title ?? 'Benchmark matrix — cell × benchmark',
59
- // The cell (harness/model/persona) is the row label; one column per benchmark.
60
- profileKeyOf: (r) => r.candidateId,
61
- groupOf: (r) => r.scenarioId ?? r.experimentId,
62
- ...(opts.meta ? { meta: opts.meta } : {}),
63
- })
64
- }
65
-
66
- export { renderLeaderboardHtml, renderLeaderboardMarkdown, renderLeaderboardSvg }
@@ -1,108 +0,0 @@
1
- /**
2
- * Shared sandbox-rollout helpers for the bench harnesses.
3
- *
4
- * The worker plumbing every sandbox-backed bench needs, independent of how the
5
- * loop is driven: build the standard `AgentRunSpec` (`sandboxAgentRun`), parse
6
- * the agent's final answer from the event stream (`answerOutput`), name the
7
- * cost-dial backend (`WorkerBackendType`), and run a single-model "review the
8
- * prior attempt" analyst (`llmAnalyst`/`AnalystFn`). These are pure profile /
9
- * backend / parsing plumbing — no experiment shell, no topology arms.
10
- */
11
-
12
- import {
13
- type AgentProfile,
14
- type AgentRunSpec,
15
- type OutputAdapter,
16
- } from '@tangle-network/agent-runtime/kernel'
17
- import { parseExactAgentProfile } from '@tangle-network/agent-runtime/candidate-execution'
18
-
19
- // `BackendType` is the sandbox SDK's harness union and its canonical home. Runtime consumes it
20
- // from there too; benchmark profiles use the same values as their exact harness identity.
21
- import type { BackendType } from '@tangle-network/sandbox'
22
- import { assertExecutableAgentProfile } from '../../src/runtime/supervise/model-policy'
23
- import { benchRouterProfile, runBenchRouterTurn } from './router-turn'
24
-
25
- /** Parse the agent's final answer from the event stream (harness-agnostic).
26
- * The default deliverable; a benchmark whose artifact is a file overrides via
27
- * its own `OutputAdapter` that reads from the run. */
28
- export const answerOutput: OutputAdapter<string> = {
29
- parse(events) {
30
- let answer = ''
31
- for (const ev of events) {
32
- const d = (ev as { data?: Record<string, unknown> })?.data
33
- const t = d?.finalText ?? d?.text ?? d?.result
34
- if (typeof t === 'string' && t.length > 0) answer = t
35
- }
36
- return answer
37
- },
38
- }
39
-
40
- /** What an analyst sees of each prior attempt: its output, its verdict, and its
41
- * raw trace events. The events are the trace an analyst reads. */
42
- export type SteerHistory = ReadonlyArray<{
43
- output?: string
44
- verdict?: { valid?: boolean; score?: number; notes?: string }
45
- events?: readonly unknown[]
46
- }>
47
-
48
- /**
49
- * The investigation: read the prior attempt's trace, return targeted feedback for
50
- * the next one. It observes BEHAVIOR (output, trace), never the judge's verdict —
51
- * the selector != judge firewall.
52
- */
53
- export type AnalystFn = (history: SteerHistory, task?: string) => Promise<string>
54
-
55
- /** Simple analyst: ONE model call reads the public task plus a bounded view of the
56
- * last attempt (its output + a tail of its trace events) and returns a concrete
57
- * correction. Selector != judge firewall: it NEVER reads the held-out judge's
58
- * verdict or failure detail — that would be a non-deployable oracle gradient
59
- * toward the reference answer. A deployable steerer must locate the fault from the
60
- * task and the agent's own behavior alone. */
61
- export const llmAnalyst = (cfg: { routerBaseUrl: string; routerKey: string; model: string }): AnalystFn =>
62
- async (history, task) => {
63
- const last = history.at(-1)
64
- const traceTail = (last?.events ?? [])
65
- .slice(-12)
66
- .map((e) => (typeof e === 'string' ? e : JSON.stringify(e)))
67
- .join('\n')
68
- .slice(-2000)
69
- const systemPrompt =
70
- "You review an AI agent's previous attempt at a task. From the task, the attempt's output, and its execution trace ALONE, judge whether it correctly and completely solved the task. If you find a specific fault — a wrong value, a guessed API signature, a missing step, a misread requirement — name it and give the concrete correction in 1-3 sentences. Reply exactly 'no change needed' if the attempt looks correct and complete."
71
- const turn = await runBenchRouterTurn(
72
- {
73
- routerBaseUrl: cfg.routerBaseUrl,
74
- routerKey: cfg.routerKey,
75
- profile: benchRouterProfile('sandbox-run-analyst', cfg.model, { systemPrompt }),
76
- },
77
- `Task:\n${task ?? '(task unavailable)'}\n\nPrevious answer:\n${last?.output ?? '(none)'}\n\nTrace tail:\n${traceTail}`,
78
- )
79
- return turn.finalText
80
- }
81
-
82
- /** Cost-dial backend = the SDK's canonical `BackendType` (single source of truth; no local
83
- * literal copy that drifts from the harness set). `hermes` = the inference-router agent (the
84
- * cheap "router llm-call" dial); the rest are agent CLIs. The ONLY knob that changes which
85
- * agent runs — no per-backend worker. */
86
- export type WorkerBackendType = BackendType
87
-
88
- /** Build the standard sandbox `AgentRunSpec` for a benchmark. The complete profile is the only
89
- * behavioral input: its harness selects the box backend and its provider/model select inference.
90
- * Extra sandbox env remains infrastructure, not a second model-selection path. */
91
- export function sandboxAgentRun(opts: {
92
- profile: AgentProfile
93
- taskToPrompt?: (task: string) => string
94
- /** Extra box-level env (e.g. `TANGLE_SEARCH_DEFAULT_PROVIDER` to pin the in-box
95
- * agent's web-search provider, provider keys like EXA_API_KEY). Allowlisted
96
- * keys only reach the spawned CLI. Must NOT carry router/model credentials. */
97
- env?: Record<string, string>
98
- }): AgentRunSpec<string> {
99
- const profile = parseExactAgentProfile(opts.profile, 'sandboxAgentRun profile')
100
- assertExecutableAgentProfile(profile, 'sandboxAgentRun profile')
101
- const name = profile.name ?? 'sandbox-worker'
102
- return {
103
- profile,
104
- name,
105
- taskToPrompt: opts.taskToPrompt ?? ((t) => t),
106
- ...(opts.env ? { sandboxOverrides: { env: opts.env } } : {}),
107
- }
108
- }
@@ -1,182 +0,0 @@
1
- /**
2
- * cli-bridge cell executor — the unblocked path to the head-to-head numbers
3
- * while the sandbox sidecar image is pending #1810.
4
- *
5
- * Same arms, same deterministic oracle, same export. The only difference from
6
- * the sandbox path is HOW the harness runs: a single OpenAI-compatible chat call
7
- * to the local cli-bridge (`/v1/chat/completions`) with an `agent_profile` that
8
- * (a) disables native web tools via `metadata.disallowedTools` and (b) adds the
9
- * provider search MCP via `mcp` — both PROVEN to work on the bridge. Native arm
10
- * leaves the harness untouched.
11
- *
12
- * The bridge model id IS the harness selector (e.g. `claude-code/sonnet`,
13
- * `opencode/zai-coding-plan/glm-5.1`), so `harness` here is just the label.
14
- */
15
- import { createExecutor } from '@tangle-network/agent-runtime/kernel'
16
- import {
17
- defineAgentProfileSecretRef,
18
- harnessProviders,
19
- type AgentProfile,
20
- type HarnessType,
21
- } from '@tangle-network/agent-interface'
22
- import type { SearchArm } from './profiles'
23
- import { armLabel } from './profiles'
24
- import type { SearchCellResult } from './run.mts'
25
- import { type SearchTask, scoreTask, taskToPrompt } from './tasks'
26
-
27
- const nativeWebDisallowed = ['WebSearch', 'WebFetch', 'web_search', 'web_fetch', 'websearch', 'webfetch', 'fetch']
28
-
29
- /** Build the cli-bridge `agent_profile` for one arm (bridge dialect: disable via
30
- * `metadata.disallowedTools`, search MCP via `mcp.<name>.transport:'http'`). */
31
- function bridgeProfile(
32
- arm: SearchArm,
33
- routerSearchMcp: string,
34
- tangleApiKey: string,
35
- label: string,
36
- harness: HarnessType,
37
- wireModel: string,
38
- ): AgentProfile {
39
- const prefix = `${harness}/`
40
- if (!wireModel.startsWith(prefix)) {
41
- throw new Error(
42
- `bridgeProfile: wire model '${wireModel}' must start with harness '${prefix}'`,
43
- )
44
- }
45
- const modelPath = wireModel.slice(prefix.length)
46
- const segments = modelPath.split('/').filter(Boolean)
47
- if (segments.length === 0) {
48
- throw new Error(`bridgeProfile: wire model '${wireModel}' has no model id`)
49
- }
50
- let provider: string
51
- let model: string
52
- if (segments.length === 1) {
53
- const providers = harnessProviders(harness)
54
- if (providers?.length !== 1) {
55
- throw new Error(
56
- `bridgeProfile: wire model '${wireModel}' must include a provider for harness '${harness}'`,
57
- )
58
- }
59
- provider = providers[0]!
60
- model = segments[0]!
61
- } else {
62
- provider = segments[0]!
63
- model = segments.slice(1).join('/')
64
- }
65
- const identity: AgentProfile = {
66
- name: `search-bench-${label}`,
67
- harness,
68
- model: { provider, default: model },
69
- }
70
- if (arm === 'native') return identity
71
- const base: AgentProfile = {
72
- ...identity,
73
- metadata: { disallowedTools: nativeWebDisallowed },
74
- }
75
- if (arm === 'off') return base
76
- if (!tangleApiKey) {
77
- throw new Error(`bridgeProfile: provider arm requires TANGLE_API_KEY`)
78
- }
79
- return {
80
- ...base,
81
- mcp: {
82
- tangle_search: {
83
- transport: 'http',
84
- url: `${routerSearchMcp}?provider=${encodeURIComponent(arm.provider)}`,
85
- headers: {
86
- Authorization: defineAgentProfileSecretRef('TANGLE_API_KEY', 'bearer'),
87
- },
88
- enabled: true,
89
- },
90
- },
91
- }
92
- }
93
-
94
- const urlRe = /https?:\/\/[^\s)\]}"'<>]+/gi
95
- function citationsOf(answer: string): string[] {
96
- return [...new Set((answer.match(urlRe) ?? []).map((u) => u.replace(/[.,;]+$/, '')))]
97
- }
98
-
99
- export interface BridgeCfg {
100
- bridgeUrl: string
101
- bridgeBearer: string
102
- tangleApiKey: string
103
- /** Router search-MCP endpoint, e.g. https://router.tangle.tools/v1/search/mcp */
104
- routerSearchMcp: string
105
- /** harness label → cli-bridge model id (the harness selector). */
106
- bridgeModels: Record<string, string>
107
- timeoutMs?: number
108
- }
109
-
110
- export async function runBridgeCell(
111
- cfg: BridgeCfg,
112
- task: SearchTask,
113
- harness: HarnessType,
114
- arm: SearchArm,
115
- ): Promise<SearchCellResult> {
116
- const startedAt = Date.now()
117
- const armId = armLabel(arm)
118
- const base = {
119
- taskId: task.id,
120
- domain: task.domain,
121
- harness,
122
- arm: armId,
123
- model: cfg.bridgeModels[harness] ?? harness,
124
- ts: new Date(startedAt).toISOString(),
125
- }
126
- const controller = new AbortController()
127
- const timer = setTimeout(() => controller.abort(), cfg.timeoutMs ?? 300_000)
128
- try {
129
- // One harness turn through the unified bridge executor — same backend the
130
- // loop path uses; this cell scorer just adds oracle scoring + citations.
131
- const profile = bridgeProfile(
132
- arm,
133
- cfg.routerSearchMcp,
134
- cfg.tangleApiKey,
135
- `${harness}-${armId}`,
136
- harness,
137
- cfg.bridgeModels[harness] ?? harness,
138
- )
139
- const exec = createExecutor({
140
- backend: 'bridge',
141
- bridgeUrl: cfg.bridgeUrl,
142
- bridgeBearer: cfg.bridgeBearer,
143
- timeoutMs: cfg.timeoutMs ?? 300_000,
144
- })({ profile, harness: null }, { signal: controller.signal, seams: {} })
145
- // bridgeExecutor is one-shot (async execute resolves an ExecutorResult).
146
- const artifact = (await exec.execute(taskToPrompt(task), controller.signal)) as {
147
- out: unknown
148
- spent: { tokens: { input: number; output: number }; usd: number }
149
- }
150
- const out = artifact.out as { content?: string; toolCalls?: string[] }
151
- const answer = out.content ?? ''
152
- const names = out.toolCalls ?? []
153
- const { score, reasons } = scoreTask(task, answer)
154
- return {
155
- ...base,
156
- score,
157
- reasons,
158
- ...(artifact.spent.usd ? { costUsd: artifact.spent.usd } : {}),
159
- ...(artifact.spent.tokens.input ? { tokensIn: artifact.spent.tokens.input } : {}),
160
- ...(artifact.spent.tokens.output ? { tokensOut: artifact.spent.tokens.output } : {}),
161
- wallMs: Date.now() - startedAt,
162
- toolCalls: names.length,
163
- toolNames: [...new Set(names)],
164
- citations: citationsOf(answer),
165
- answer,
166
- }
167
- } catch (err) {
168
- return {
169
- ...base,
170
- score: null,
171
- reasons: [],
172
- wallMs: Date.now() - startedAt,
173
- toolCalls: 0,
174
- toolNames: [],
175
- citations: [],
176
- answer: '',
177
- infraError: err instanceof Error ? err.message : String(err),
178
- }
179
- } finally {
180
- clearTimeout(timer)
181
- }
182
- }
Binary file
@@ -1,78 +0,0 @@
1
- /**
2
- * Discrimination check: how many fresh-docs tasks does a model get WRONG from
3
- * memory (no tools, no search)? A high parametric fail-rate is the prerequisite
4
- * for the whole comparison — if the model already knows the answer, no search
5
- * backend can help. This is a pure router chat-completion per task, scored by
6
- * the same deterministic oracle the sandbox run uses. No sandbox, no deploy dep.
7
- *
8
- * Run:
9
- * dotenvx run -f ~/company/devops/secrets/.env.keys -f ~/company/devops/secrets/agent-state.env -- \
10
- * env MODEL=gpt-4.1 CONCURRENCY=4 pnpm exec tsx src/search-bench/parametric-check.mts
11
- */
12
- import { writeFileSync } from 'node:fs'
13
- import { runPool } from '../run-pool'
14
- import { runBenchRouterTurn } from '../router-turn'
15
- import { freshTasks } from './tasks-fresh'
16
- import { scoreTask, taskToPrompt } from './tasks'
17
-
18
- async function main(): Promise<void> {
19
- const model = process.env.MODEL ?? 'deepseek-v4-flash'
20
- const routerKey = process.env.TANGLE_API_KEY
21
- if (!routerKey) throw new Error('missing TANGLE_API_KEY')
22
- const cfg = {
23
- routerBaseUrl: process.env.ROUTER_BASE_URL ?? 'https://router.tangle.tools/v1',
24
- routerKey,
25
- model,
26
- }
27
- const conc = Number(process.env.CONCURRENCY ?? 4)
28
-
29
- const outcomes = await runPool(freshTasks, conc, async (task) => {
30
- try {
31
- const res = await runBenchRouterTurn(
32
- {
33
- routerBaseUrl: cfg.routerBaseUrl,
34
- routerKey: cfg.routerKey,
35
- profile: {
36
- name: 'search-parametric-check',
37
- model: { provider: 'tangle-router', default: model },
38
- },
39
- },
40
- taskToPrompt(task),
41
- )
42
- const { score } = scoreTask(task, res.finalText)
43
- return {
44
- id: task.id,
45
- score: score as 0 | 1 | null,
46
- cost: res.usage.usdKnown === false ? undefined : res.usage.costUsd,
47
- err: undefined as string | undefined,
48
- }
49
- } catch (err) {
50
- return { id: task.id, score: null as 0 | 1 | null, cost: undefined, err: err instanceof Error ? err.message : String(err) }
51
- }
52
- })
53
- const rows = outcomes.map((o) => o.value!).filter(Boolean)
54
-
55
- const scored = rows.filter((r) => r.score !== null)
56
- const passed = scored.filter((r) => r.score === 1).length
57
- const failed = scored.length - passed
58
- console.log(`\n=== Parametric (no-search) discrimination · ${model} · n=${scored.length} ===`)
59
- for (const r of rows.sort((a, b) => (a.score ?? -1) - (b.score ?? -1))) {
60
- console.log(` ${r.score === null ? 'ERR ' : r.score === 1 ? 'KNEW' : 'MISS'} ${r.id}${r.err ? ` (${r.err})` : ''}`)
61
- }
62
- console.log(
63
- `\nparametric FAIL (search-correctable headroom): ${failed}/${scored.length} = ${((failed / scored.length) * 100).toFixed(0)}%` +
64
- ` · model already knew: ${passed}/${scored.length}`,
65
- )
66
- if (process.env.PARAM_OUT) {
67
- writeFileSync(
68
- process.env.PARAM_OUT,
69
- rows.map((r) => JSON.stringify({ id: r.id, model, knewParametrically: r.score === 1, score: r.score })).join('\n') + '\n',
70
- )
71
- console.log(`wrote per-task baseline → ${process.env.PARAM_OUT}`)
72
- }
73
- }
74
-
75
- main().catch((e) => {
76
- console.error(e)
77
- process.exit(1)
78
- })