@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,176 +0,0 @@
1
- /**
2
- * Render the gate results as clean, dependency-free SVG bar charts.
3
- *
4
- * One honest chart per benchmark: bars for each arm (baseline greys + the
5
- * verifier-grounded method in the accent), an optional dashed oracle-ceiling line,
6
- * and a single annotated delta. No chartjunk — value labels, one accent, lots of
7
- * whitespace. Data is passed in (no hidden numbers) so the charts regenerate from
8
- * the real run outputs.
9
- *
10
- * node bench/scripts/render-gate-chart.mjs # writes docs/assets/*.svg
11
- * (then: cairosvg docs/assets/<f>.svg -o /tmp/<f>.png to preview)
12
- */
13
-
14
- import { mkdirSync, writeFileSync } from 'node:fs'
15
- import { dirname, join } from 'node:path'
16
- import { fileURLToPath } from 'node:url'
17
-
18
- const here = dirname(fileURLToPath(import.meta.url))
19
- const assetsDir = join(here, '..', '..', 'docs', 'assets')
20
-
21
- const palette = {
22
- bg: '#ffffff',
23
- ink: '#0f172a', // slate-900 — titles, values
24
- muted: '#64748b', // slate-500 — subtitles, labels
25
- faint: '#e2e8f0', // slate-200 — baseline / axis
26
- baseline: '#cbd5e1', // slate-300 — "blind" / weaker baselines
27
- baseline2: '#94a3b8', // slate-400 — the competing selector
28
- method: '#4f46e5', // indigo-600 — the verifier-grounded method (the hero)
29
- methodSoft: '#eef2ff', // indigo-50 — method bar wash
30
- ceiling: '#475569', // slate-600 — oracle ceiling line
31
- good: '#059669', // emerald-600 — positive delta
32
- }
33
-
34
- const esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
35
- const f = 'system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif'
36
-
37
- /**
38
- * @param {{
39
- * title: string, subtitle: string, footnote?: string,
40
- * bars: {label: string, value: number, kind: 'blind'|'rival'|'method'}[],
41
- * ceiling?: {value: number, label: string},
42
- * delta?: {fromIdx: number, toIdx: number, label: string},
43
- * yMax?: number, unit?: string,
44
- * }} cfg
45
- */
46
- function chart(cfg) {
47
- const W = 820
48
- const H = 524
49
- const m = { top: 152, right: 136, bottom: 120, left: 66 }
50
- const plotW = W - m.left - m.right
51
- const plotH = H - m.top - m.bottom
52
- const yMax = cfg.yMax ?? 100
53
- const unit = cfg.unit ?? '%'
54
- const y = (v) => m.top + plotH * (1 - v / yMax)
55
-
56
- const n = cfg.bars.length
57
- const bandW = plotW / n
58
- const barW = Math.min(112, bandW * 0.56)
59
- const cx = (i) => m.left + bandW * (i + 0.5)
60
- const fill = { blind: palette.baseline, rival: palette.baseline2, method: palette.method }
61
-
62
- const parts = []
63
- parts.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}" font-family='${f}'>`)
64
- parts.push(`<rect width="${W}" height="${H}" fill="${palette.bg}"/>`)
65
-
66
- // title + subtitle
67
- parts.push(`<text x="${m.left}" y="46" font-size="22" font-weight="700" fill="${palette.ink}">${esc(cfg.title)}</text>`)
68
- parts.push(`<text x="${m.left}" y="72" font-size="13.5" fill="${palette.muted}">${esc(cfg.subtitle)}</text>`)
69
-
70
- // baseline axis
71
- parts.push(`<line x1="${m.left}" y1="${y(0)}" x2="${m.left + plotW}" y2="${y(0)}" stroke="${palette.faint}" stroke-width="1.5"/>`)
72
- // light gridlines at 25/50/75/100
73
- for (const g of [25, 50, 75, 100]) {
74
- if (g > yMax) continue
75
- parts.push(`<line x1="${m.left}" y1="${y(g)}" x2="${m.left + plotW}" y2="${y(g)}" stroke="${palette.faint}" stroke-width="1" stroke-dasharray="2 5"/>`)
76
- parts.push(`<text x="${m.left - 12}" y="${y(g) + 4}" font-size="11" text-anchor="end" fill="${palette.muted}">${g}${unit}</text>`)
77
- }
78
-
79
- // oracle ceiling line
80
- if (cfg.ceiling) {
81
- const yc = y(cfg.ceiling.value)
82
- parts.push(`<line x1="${m.left}" y1="${yc}" x2="${m.left + plotW}" y2="${yc}" stroke="${palette.ceiling}" stroke-width="1.5" stroke-dasharray="6 4"/>`)
83
- parts.push(`<text x="${m.left + plotW + 8}" y="${yc - 5}" font-size="12" font-weight="600" fill="${palette.ceiling}">${esc(cfg.ceiling.label)}</text>`)
84
- parts.push(`<text x="${m.left + plotW + 8}" y="${yc + 12}" font-size="12" fill="${palette.ceiling}">${cfg.ceiling.value}${unit}</text>`)
85
- }
86
-
87
- // bars
88
- cfg.bars.forEach((b, i) => {
89
- const x = cx(i) - barW / 2
90
- const top = y(b.value)
91
- const h = y(0) - top
92
- const isMethod = b.kind === 'method'
93
- if (isMethod) parts.push(`<rect x="${x - 3}" y="${top - 3}" width="${barW + 6}" height="${h + 3}" rx="7" fill="${palette.methodSoft}"/>`)
94
- parts.push(`<rect x="${x}" y="${top}" width="${barW}" height="${h}" rx="5" fill="${fill[b.kind]}"/>`)
95
- // value label
96
- parts.push(`<text x="${cx(i)}" y="${top - 12}" font-size="16" font-weight="700" text-anchor="middle" fill="${isMethod ? palette.method : palette.ink}">${b.value}${unit}</text>`)
97
- // x label (two lines if it contains a newline)
98
- const lines = b.label.split('\n')
99
- lines.forEach((ln, li) => {
100
- parts.push(`<text x="${cx(i)}" y="${y(0) + 24 + li * 16}" font-size="12.5" font-weight="${isMethod ? 600 : 400}" text-anchor="middle" fill="${isMethod ? palette.method : palette.muted}">${esc(ln)}</text>`)
101
- })
102
- })
103
-
104
- // delta annotation: a bracket from one bar's top to another's, labelled
105
- if (cfg.delta) {
106
- const a = cfg.delta.fromIdx
107
- const b = cfg.delta.toIdx
108
- const xa = cx(a)
109
- const xb = cx(b)
110
- const ya = y(cfg.bars[a].value)
111
- const yb = y(cfg.bars[b].value)
112
- const yBar = Math.min(ya, yb) - 34
113
- const midx = (xa + xb) / 2
114
- parts.push(`<line x1="${xa}" y1="${ya - 26}" x2="${xa}" y2="${yBar}" stroke="${palette.good}" stroke-width="1.25"/>`)
115
- parts.push(`<line x1="${xb}" y1="${yb - 26}" x2="${xb}" y2="${yBar}" stroke="${palette.good}" stroke-width="1.25"/>`)
116
- parts.push(`<line x1="${xa}" y1="${yBar}" x2="${xb}" y2="${yBar}" stroke="${palette.good}" stroke-width="1.25"/>`)
117
- const lw = cfg.delta.label.length * 7.2 + 16
118
- parts.push(`<rect x="${midx - lw / 2}" y="${yBar - 22}" width="${lw}" height="20" rx="10" fill="${palette.good}"/>`)
119
- parts.push(`<text x="${midx}" y="${yBar - 8}" font-size="12.5" font-weight="700" text-anchor="middle" fill="#ffffff">${esc(cfg.delta.label)}</text>`)
120
- }
121
-
122
- if (cfg.footnote) {
123
- // wrap to the plot width (~92 chars at 11.5px over the full canvas)
124
- const words = cfg.footnote.split(' ')
125
- const lines = []
126
- let cur = ''
127
- for (const w of words) {
128
- if ((cur + ' ' + w).trim().length > 104) {
129
- lines.push(cur.trim())
130
- cur = w
131
- } else cur = `${cur} ${w}`
132
- }
133
- if (cur.trim()) lines.push(cur.trim())
134
- const startY = H - 20 - (lines.length - 1) * 15
135
- lines.forEach((ln, i) => {
136
- parts.push(`<text x="${m.left}" y="${startY + i * 15}" font-size="11.5" fill="${palette.muted}">${esc(ln)}</text>`)
137
- })
138
- }
139
- parts.push('</svg>')
140
- return parts.join('\n')
141
- }
142
-
143
- // ---- the charts (numbers are the real, verified run outputs) -------------------
144
-
145
- const humaneval = chart({
146
- title: 'Verifier-grounded selection recovers the oracle ceiling',
147
- subtitle: 'HumanEval · gpt-3.5-turbo · k=4 · n=50 · paired bootstrap (B=10000) + Benjamini–Hochberg',
148
- bars: [
149
- { label: 'Blind\n(1 shot)', value: 80, kind: 'blind' },
150
- { label: 'Self-consistency\n(pick the consensus)', value: 82, kind: 'rival' },
151
- { label: 'Verifier-grounded\n(re-run the tests)', value: 92, kind: 'method' },
152
- ],
153
- ceiling: { value: 92, label: 'oracle ceiling', },
154
- delta: { fromIdx: 1, toIdx: 2, label: '+10.0pp CI[+2, +18]' },
155
- footnote: 'Deployable, non-oracle selector: ranks k attempts by re-running the task’s own unit tests (gold never shown). It captures the FULL ceiling (gap 0); self-consistency leaves 10pp on the table. Reproduced across two independent n=50 runs (+10pp / +12pp, both BH-positive).',
156
- })
157
-
158
- // commit0 — single-task Layer-1 VALIDATION (wcwidth, k=3). Regenerate with the powered
159
- // n=10 cross-task gate when it lands. Honestly labelled as a per-task validation.
160
- const commit0Validation = chart({
161
- title: 'The selector signal survives real stateful coding rollouts',
162
- subtitle: 'commit0 · gpt-4.1 · k=3 · single-task validation (wcwidth) — official pytest harness, graded pass-rate',
163
- bars: [
164
- { label: 'Random pick\n(blind, mean-of-k)', value: 67.5, kind: 'blind' },
165
- { label: 'Verifier-grounded\n(highest test-pass)', value: 78.9, kind: 'method' },
166
- ],
167
- ceiling: { value: 78.9, label: 'best-of-k', },
168
- delta: { fromIdx: 0, toIdx: 1, label: '+11.4pp' },
169
- footnote: 'Layer-1: agent clones the repo, implements, runs pytest, iterates, emits a diff. Attempts score 60.5 / 78.9 / 63.2% — within-task variance the selector exploits. Powered n=10 cross-task gate in progress.',
170
- })
171
-
172
- mkdirSync(assetsDir, { recursive: true })
173
- writeFileSync(join(assetsDir, 'gate-humaneval.svg'), humaneval)
174
- writeFileSync(join(assetsDir, 'gate-commit0-validation.svg'), commit0Validation)
175
- console.log(`wrote ${join(assetsDir, 'gate-humaneval.svg')}`)
176
- console.log(`wrote ${join(assetsDir, 'gate-commit0-validation.svg')}`)
@@ -1,57 +0,0 @@
1
- # trata-hedge-bench — evaluating our system against an LLM-judge benchmark
2
-
3
- [trata-hedge-bench](https://github.com/Trata-Inc/trata-hedge-bench) is a 102-task
4
- financial-analyst benchmark (Harbor format): the agent reads a company's data corpus
5
- (earnings calls, 10-K/10-Q, financials, press releases) and writes an analysis; the
6
- verifier is a **Gemini-3.1-pro 3-task cascade** (hallucination-check → per-move-hit →
7
- synthesis) that grades *concept match* against the expert analyst's documented moves
8
- (`ground_truth.txt`). Graded `score` is 0–4 (themes fully covered); `reward.txt` is
9
- sparse (1 iff all themes). No deployable ground-truth checker — it's an **oracle judge**.
10
-
11
- ## What's admissible here (and what isn't)
12
-
13
- - **NOT** the verifier-grounded selector gate (our HumanEval/commit0 headline). The only
14
- checker is the judge itself, so selecting by it = selecting by the eval metric (an
15
- oracle, a Goodhart trap). See `docs/results.md`.
16
- - **IS** admissible: (1) more-compute headroom (pass@k), (2) prompt optimization
17
- (`improve` with agent-eval's official GEPA method, using disjoint train, selection,
18
- and final-test partitions), with the honest caveat that an
19
- LLM-judge can be *gamed*, so a held-out lift means "higher judge score," which without
20
- ground truth we can't independently certify as "better analysis."
21
-
22
- ## Status (2026-06-06): pipeline PROVEN end-to-end
23
-
24
- Our Runtime-backed solver → their **real** Gemini-3.1-pro judge → a genuine graded result. Every link
25
- works. The naive **single-shot** baseline (DeepSeek V4 Flash, ~3 of N corpus files in one context
26
- window) scores **0/4** — a floor: it hit only 1/3 moves on a few themes with
27
- hallucinations flagged, because it could not explore the full corpus. The bench is built
28
- for **agentic** exploration; a fair baseline needs our sandbox runtime as the solver
29
- (browse + cite selectively), like the commit0 gate — pending sandbox-gateway health.
30
-
31
- ## Run it
32
-
33
- ```bash
34
- # clone the bench once (102 envs, ~580MB; or sparse-checkout one env)
35
- git clone https://github.com/Trata-Inc/trata-hedge-bench /tmp/thb
36
-
37
- dotenvx run -f ~/company/devops/secrets/.env.keys -f ~/company/devops/secrets/agent-state.env -- \
38
- bash bench/scripts/trata-hedge/run.sh /tmp/thb/environments/<env-name> deepseek-v4-flash
39
- ```
40
-
41
- ## Gotchas (each cost a debugging cycle)
42
-
43
- - **Use `GOOGLE_AI_KEY`, not `GEMINI_API_KEY`** — the latter in the secrets is
44
- `API_KEY_INVALID`; `GOOGLE_AI_KEY` is the working Gemini key (`gemini-3.1-pro-preview`
45
- returns 200). `run.sh` maps `GOOGLE_API_KEY=$GOOGLE_AI_KEY` for `grade.py`.
46
- - The router is behind Cloudflare bot-fight: a default urllib User-Agent → 403 (CF 1010)
47
- on large bodies; the solver sends a browser UA.
48
- - `grade.py` hardcodes `/app/answer.txt` (only that path); `/app` is sudo-writable.
49
- `DATA_DIR` / `GROUND_TRUTH_PATH` / `REWARD_PATH` / `DETAILS_PATH` are env-overridable, so
50
- the grader runs **unmodified** (faithful).
51
-
52
- ## Next steps
53
-
54
- 1. Agentic solver: our sandbox runtime browses the corpus + cites (fair baseline).
55
- 2. Prompt optimization: run `bench/src/trata-gepa.mts` across all 102 tasks with
56
- explicit train, selection, and final-test partitions, and state the judge-gaming
57
- caveat with every result.
@@ -1,64 +0,0 @@
1
- #!/bin/bash
2
- # Evaluate our system against trata-hedge-bench's OWN Gemini-3.1-pro judge.
3
- #
4
- # Pipeline: our solver writes a cited analysis -> their grade.py (unmodified, a
5
- # 3-task Gemini cascade: hallucination-check -> per-move-hit -> synthesis) scores it
6
- # against the expert analyst's documented moves (ground_truth.txt).
7
- #
8
- # Prereqs (all present in this environment):
9
- # - GOOGLE_AI_KEY — a VALID Gemini key (NOTE: GEMINI_API_KEY in the secrets is
10
- # API_KEY_INVALID; GOOGLE_AI_KEY is the working one).
11
- # - TANGLE_API_KEY — our router (the solver).
12
- # - uv + Docker. /app is sudo-writable (grade.py hardcodes /app/answer.txt).
13
- #
14
- # Usage (wrap in dotenvx so the keys resolve):
15
- # dotenvx run -f ~/company/devops/secrets/.env.keys -f ~/company/devops/secrets/agent-state.env -- \
16
- # bash bench/scripts/trata-hedge/run.sh <path-to-trata-env-dir> [WORKER_MODEL]
17
- set -euo pipefail
18
-
19
- ENV="${1:?usage: run.sh <trata-env-dir> [model]}"
20
- MODEL="${2:-${WORKER_MODEL:-}}"
21
- if [[ -z "$MODEL" ]]; then
22
- echo "WORKER_MODEL is required (or pass it as argument 2)" >&2
23
- exit 2
24
- fi
25
- HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
26
- ANS=/tmp/thb-answer.txt
27
- REWARD=/tmp/thb-reward.txt
28
- DETAILS=/tmp/thb-details.json
29
-
30
- echo "[trata] solve: $ENV (model=$MODEL)"
31
- WORKER_MODEL="$MODEL" pnpm --dir "$HERE/../../.." exec tsx "$HERE/../../src/trata-hedge-solve.mts" "$ENV" "$ANS"
32
-
33
- sudo -n mkdir -p /app && sudo -n cp "$ANS" /app/answer.txt && sudo -n chmod 644 /app/answer.txt
34
-
35
- echo "[trata] grade: their grade.py (gemini-3.1-pro)"
36
- GRADE_LOG=/tmp/thb-grade.log
37
- # Fail loud: capture the grader's output; if it errors (bad key, import, network) or
38
- # writes no details, surface ITS error rather than crashing the reporter cryptically.
39
- set +e
40
- ( cd "$ENV/tests" && \
41
- GOOGLE_API_KEY="$GOOGLE_AI_KEY" \
42
- DATA_DIR="$ENV/environment/data" \
43
- GROUND_TRUTH_PATH="$ENV/tests/ground_truth.txt" \
44
- REWARD_PATH="$REWARD" DETAILS_PATH="$DETAILS" \
45
- uvx --with google-genai python3 grade.py ) >"$GRADE_LOG" 2>&1
46
- grade_status=$?
47
- set -e
48
- if [ "$grade_status" -ne 0 ] || [ ! -f "$DETAILS" ]; then
49
- echo "[trata] grade.py FAILED (exit $grade_status) — last output:" >&2
50
- tail -n 15 "$GRADE_LOG" >&2
51
- exit 1
52
- fi
53
-
54
- python3 - "$DETAILS" "$REWARD" <<'PY'
55
- import json, sys
56
- d = json.load(open(sys.argv[1]))
57
- reward = open(sys.argv[2]).read().strip() if __import__("os").path.exists(sys.argv[2]) else "?"
58
- print(f" sparse reward (1 iff all themes): {reward}")
59
- print(f" graded score (0-4): {d.get('score')} | themes_covered: {d.get('themes_covered')}/{d.get('num_themes')} | hallucinations: {d.get('hallucinations_detected')}")
60
- for t in d.get("themes_hit", []):
61
- print(f" HIT : {t.get('label')}")
62
- for t in d.get("themes_missed", []):
63
- print(f" MISS: {t.get('label')} ({len(t.get('moves_hit',[]))}/{t.get('n_moves')} moves)")
64
- PY
@@ -1,156 +0,0 @@
1
- /**
2
- * The LIVE observe→steer loop — the hard join, on real endpoints (no mocks).
3
- *
4
- * The facade-postmortem's standing rule (docs/research/loop-facade-postmortem.md):
5
- * prove the smallest real loop on LIVE paths, not mocks. This closes the join
6
- * with BOTH ends real — a real cloud worker and a real router-backed observer:
7
- *
8
- * round → REAL cloud worker (openSandboxRun, opencode in a box) over the task +
9
- * accumulated steers → its real event trace
10
- * → observe() with a REAL router LLM reads that trace → an AnalystFinding
11
- * → the finding's recommended_action is injected as a STEER into the next
12
- * round's worker prompt
13
- * → stop when the deterministic verifier passes, or budget.
14
- *
15
- * It reports, per round: the tools the worker actually used, the observer's
16
- * finding (LLM-derived from the real trace), and whether the steer changed
17
- * behavior — honestly, never as a claimed win.
18
- *
19
- * STATUS (2026-06-08): the join ran live end-to-end for 3 rounds earlier (real
20
- * worker → real trace → real router-LLM finding → real steer injection). Re-runs
21
- * are currently BLOCKED at provisioning: the sandbox egress proxy returns
22
- * CONNECT 403 for router.tangle.tools (only that host; id/pangolin/sandbox +
23
- * api.openai.com all pass), so the in-box agent cannot reach the model router and
24
- * produces zero output/zero tools. This is a platform egress regression — it
25
- * worked 2026-06-06 — tracked as ops-board #984, NOT a flaw in this loop. The
26
- * efficacy measurement (does the steer improve behavior at equal budget) is gated
27
- * on that unblock; until then this proves the live JOIN, not efficacy.
28
- *
29
- * dotenvx run -f …/.env.keys -f …/agent-state.env -- \
30
- * env MODEL=gpt-4.1 ROUNDS=3 pnpm exec tsx src/cloud-loop.mts
31
- */
32
- import {
33
- defaultAnalystInstruction,
34
- observe,
35
- openSandboxRun,
36
- } from '@tangle-network/agent-runtime/kernel'
37
- import { Sandbox } from '@tangle-network/sandbox'
38
- import { answerOutput, sandboxAgentRun } from './sandbox-run'
39
-
40
- function env(name: string, fallback?: string): string {
41
- const v = process.env[name] ?? fallback
42
- if (v === undefined) throw new Error(`missing env ${name}`)
43
- return v
44
- }
45
-
46
- /** A task with a flaw the observer can catch from the trace: models tend to
47
- * CLAIM the tests pass without running them. The verifier requires the exact
48
- * proof-of-execution token, so a real run is the only way to pass. */
49
- const task = [
50
- 'Write a Python function `is_prime(n)` in a file `prime.py`, then write a test',
51
- 'that exercises it on 2, 11, 15, and 97. ACTUALLY RUN the test with python3 and',
52
- 'paste the real interpreter output. End your reply with the line ALLPASS only if',
53
- 'every assertion really passed when you ran it. Do not claim ALLPASS without',
54
- 'having executed the test and seen it pass.',
55
- ].join(' ')
56
-
57
- /** Deterministic verifier: the worker must show real execution + the proof token. */
58
- function verify(output: string): boolean {
59
- return /ALLPASS/.test(output) && /(passed|ok|\b4 (tests|asserts)|assert)/i.test(output)
60
- }
61
-
62
- /** Distinct tool names from an opencode trace (the proof the worker acted). */
63
- function tools(events: ReadonlyArray<unknown>): string[] {
64
- const names = new Set<string>()
65
- for (const ev of events) {
66
- const part = (ev as { data?: { part?: { type?: string; tool?: string } } }).data?.part
67
- if (part?.type === 'tool' && part.tool) names.add(part.tool)
68
- }
69
- return [...names]
70
- }
71
-
72
- async function main(): Promise<void> {
73
- const routerKey = env('TANGLE_API_KEY')
74
- const model = env('MODEL', 'deepseek-v4-flash')
75
- const workerProvider = env('WORKER_PROVIDER', 'openai-compat')
76
- const routerBaseUrl = env('ROUTER_BASE_URL', 'https://router.tangle.tools/v1')
77
- const rounds = Number(env('ROUNDS', '3'))
78
- const client = new Sandbox({ baseUrl: env('SANDBOX_BASE_URL', 'https://sandbox.tangle.tools'), apiKey: routerKey })
79
- const observerProfile = {
80
- name: 'trace-observer',
81
- harness: 'cli-base' as const,
82
- model: { provider: 'tangle-router', default: model },
83
- prompt: { systemPrompt: defaultAnalystInstruction },
84
- }
85
-
86
- console.error(`\n=== LIVE observe→steer loop · ${model} · real cloud worker + real observer ===\n`)
87
- const steers: string[] = []
88
- let solved = false
89
-
90
- for (let round = 1; round <= rounds && !solved; round++) {
91
- const prompt = steers.length
92
- ? `${task}\n\n=== CORRECTIONS FROM YOUR PRIOR ATTEMPT (apply them) ===\n${steers.map((s) => `- ${s}`).join('\n')}`
93
- : task
94
- console.error(`── round ${round}${steers.length ? ` (carrying ${steers.length} steer)` : ''}`)
95
-
96
- const controller = new AbortController()
97
- const timer = setTimeout(() => controller.abort(), 240_000)
98
- let output = ''
99
- let events: unknown[] = []
100
- try {
101
- const agentRun = sandboxAgentRun({
102
- profile: {
103
- name: `worker-r${round}`,
104
- harness: 'opencode',
105
- model: { provider: workerProvider, default: model },
106
- },
107
- })
108
- const run = await openSandboxRun<string>(
109
- client,
110
- { agentRun, signal: controller.signal },
111
- { kind: 'events', fromEvents: (e) => answerOutput.parse(e as never) },
112
- )
113
- try {
114
- const turn = await run.start(prompt)
115
- output = (turn.out ?? '').trim()
116
- events = turn.events
117
- } finally {
118
- await run.close().catch(() => {})
119
- }
120
- } catch (err) {
121
- console.error(` worker errored: ${err instanceof Error ? err.message : String(err)}`)
122
- continue
123
- } finally {
124
- clearTimeout(timer)
125
- }
126
-
127
- solved = verify(output)
128
- console.error(` tools used: [${tools(events).join(', ') || 'none'}] verifier: ${solved ? 'PASS ✓' : 'fail'}`)
129
- if (solved) break
130
-
131
- // THE JOIN: a REAL observer reads the REAL trace → a finding → next round's steer.
132
- const ob = await observe(
133
- { task, output, trace: events, outcome: 'failed', runId: `r${round}` },
134
- {
135
- profile: observerProfile,
136
- executor: { backend: 'router', routerBaseUrl, routerKey },
137
- },
138
- )
139
- const next = ob.findings.flatMap((f) => (f.recommended_action ? [f.recommended_action] : [])).slice(0, 3)
140
- if (next.length === 0) {
141
- console.error(' observer found nothing actionable — stopping.')
142
- break
143
- }
144
- for (const s of next) console.error(` observer → steer: ${s}`)
145
- steers.length = 0
146
- steers.push(...next)
147
- }
148
-
149
- console.error(`\n=== ${solved ? '✅ SOLVED' : '✗ unsolved'} after ${steers.length ? 'steered ' : ''}rounds · observe→steer ran on LIVE endpoints ===`)
150
- process.exit(solved ? 0 : 1)
151
- }
152
-
153
- main().catch((e) => {
154
- console.error(e)
155
- process.exit(1)
156
- })
@@ -1,182 +0,0 @@
1
- /**
2
- * Manual reachability probe for the coordination MCP from inside a Docker container.
3
- *
4
- * Run: `npx tsx bench/src/coordination-mcp-container-reach.mts`.
5
- */
6
-
7
- import { execFile } from 'node:child_process'
8
- import { promisify } from 'node:util'
9
-
10
- const execFileAsync = promisify(execFile)
11
- import {
12
- type Agent,
13
- type AgentProfile,
14
- type AgentSpec,
15
- createExecutorRegistry,
16
- createSupervisor,
17
- type Executor,
18
- type ExecutorResult,
19
- InMemoryResultBlobStore,
20
- InMemorySpawnJournal,
21
- type Scope,
22
- type UsageEvent,
23
- } from '../../src/runtime/index'
24
- import { serveCoordinationMcp } from '../../src/runtime/supervise/coordination-mcp'
25
-
26
- const HOST_BIND = '0.0.0.0'
27
- const DOCKER_BRIDGE_GATEWAY = process.env.DOCKER_BRIDGE_GATEWAY ?? '172.17.0.1'
28
-
29
- function trivialWorker(name: string): Agent<unknown, unknown> {
30
- const ex: Executor<unknown> = {
31
- runtime: 'router',
32
- execute() {
33
- return (async function* () {
34
- yield { kind: 'iteration' } as UsageEvent
35
- })()
36
- },
37
- teardown: () => Promise.resolve({ destroyed: true }),
38
- resultArtifact: (): ExecutorResult<unknown> => ({
39
- outRef: `w:${name}`,
40
- out: { ok: true },
41
- verdict: { valid: true, score: 1 },
42
- spent: { iterations: 1, tokens: { input: 0, output: 0 }, usd: 0, ms: 0 },
43
- }),
44
- }
45
- const spec: AgentSpec = { profile: { name } as AgentProfile, harness: null, executor: ex }
46
- return { name, act: async () => ({ ok: true }), executorSpec: spec } as Agent<unknown, unknown> & {
47
- executorSpec: AgentSpec
48
- }
49
- }
50
-
51
- interface ToolsListResponse {
52
- result?: { tools?: Array<{ name: string; description?: string; inputSchema?: unknown }> }
53
- error?: { code: number; message: string }
54
- }
55
-
56
- async function dockerCurlToolsList(
57
- containerUrl: string,
58
- ): Promise<{ raw: string; parsed: ToolsListResponse; cmd: string }> {
59
- const rpc = JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/list' })
60
- const args = [
61
- 'run',
62
- '--rm',
63
- '--add-host',
64
- 'host.docker.internal:host-gateway',
65
- 'curlimages/curl',
66
- '-s',
67
- '-X',
68
- 'POST',
69
- containerUrl,
70
- '-H',
71
- 'content-type: application/json',
72
- '-d',
73
- rpc,
74
- ]
75
- const cmd = `docker ${args.join(' ')}`
76
- const { stdout } = await execFileAsync('docker', args, { encoding: 'utf8', timeout: 120_000 })
77
- return { raw: stdout, parsed: JSON.parse(stdout) as ToolsListResponse, cmd }
78
- }
79
-
80
- function opencodeConfigSnippet(containerUrl: string): string {
81
- return JSON.stringify(
82
- {
83
- $schema: 'https://opencode.ai/config.json',
84
- permission: {
85
- external_directory: 'allow',
86
- bash: 'allow',
87
- edit: 'allow',
88
- read: 'allow',
89
- write: 'allow',
90
- webfetch: 'allow',
91
- task: 'allow',
92
- plan_enter: 'allow',
93
- plan_exit: 'allow',
94
- question: 'allow',
95
- },
96
- mcp: {
97
- coordination: {
98
- type: 'remote',
99
- url: containerUrl,
100
- enabled: true,
101
- },
102
- },
103
- },
104
- null,
105
- 2,
106
- )
107
- }
108
-
109
- async function main(): Promise<void> {
110
- const blobs = new InMemoryResultBlobStore()
111
- let ok = false
112
-
113
- const root: Agent<unknown, unknown> = {
114
- name: 'coordination-mcp-container-reach',
115
- async act(_t, scope: Scope<unknown>) {
116
- const mcp = await serveCoordinationMcp({
117
- scope,
118
- blobs,
119
- makeWorkerAgent: () => trivialWorker('w'),
120
- perWorker: { maxIterations: 4, maxTokens: 2000 },
121
- toolNames: ['spawn_worker', 'observe_agent'],
122
- host: HOST_BIND,
123
- })
124
- // Docker containers reach the host through the bridge gateway, not the 0.0.0.0 bind URL.
125
- const containerUrl = `http://${DOCKER_BRIDGE_GATEWAY}:${mcp.port}/mcp`
126
- const hostDockerInternalUrl = `http://host.docker.internal:${mcp.port}/mcp`
127
-
128
- console.error(`[probe] host-binding used : ${HOST_BIND}`)
129
- console.error(`[probe] server url (mcp.url) : ${mcp.url}`)
130
- console.error(`[probe] container-reachable url : ${containerUrl}`)
131
- console.error(`[probe] alt (host.docker.internal) : ${hostDockerInternalUrl}`)
132
- console.error('')
133
-
134
- try {
135
- console.error('[probe] POSTing tools/list from inside a docker container ...')
136
- const { raw, parsed, cmd } = await dockerCurlToolsList(containerUrl)
137
- console.error(`[probe] container ran: ${cmd}`)
138
- console.error(`[probe] container got back (${raw.length} bytes):`)
139
- console.error(raw)
140
- console.error('')
141
-
142
- const toolNames = (parsed.result?.tools ?? []).map((t) => t.name)
143
- const hasSpawn = toolNames.includes('spawn_worker')
144
- const hasObserve = toolNames.includes('observe_agent')
145
- console.error(`[probe] tools advertised: ${toolNames.join(', ')}`)
146
- console.error(`[probe] spawn_worker present = ${hasSpawn}; observe_agent present = ${hasObserve}`)
147
- ok = hasSpawn && hasObserve
148
-
149
- if (ok) {
150
- console.error('')
151
- console.error('[probe] opencode.json snippet (arm B writes this via OPENCODE_CONFIG):')
152
- console.error(opencodeConfigSnippet(containerUrl))
153
- }
154
- return ok ? { reachable: true } : undefined
155
- } finally {
156
- await mcp.close()
157
- }
158
- },
159
- }
160
-
161
- await createSupervisor<unknown, unknown>().run(root, 'reach', {
162
- budget: { maxIterations: 100, maxTokens: 400_000 },
163
- runId: 'coordination-mcp-container-reach',
164
- journal: new InMemorySpawnJournal(),
165
- blobs,
166
- executors: createExecutorRegistry(),
167
- maxDepth: 4,
168
- now: () => Date.now(),
169
- })
170
-
171
- console.error(
172
- ok
173
- ? 'CONTAINER-REACHABLE: docker tools/list returned spawn_worker and observe_agent.'
174
- : 'NOT reachable from container; see output above.',
175
- )
176
- process.exit(ok ? 0 : 1)
177
- }
178
-
179
- main().catch((e) => {
180
- console.error(e instanceof Error ? (e.stack ?? e.message) : String(e))
181
- process.exit(1)
182
- })