@tangle-network/agent-bench 0.14.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +2 -3
- package/dist/adapters.d.ts +2 -5
- package/dist/adapters.js +3 -4
- package/dist/benchmarks/_harness.d.ts +17 -20
- package/dist/benchmarks/_harness.js +4 -4
- package/dist/benchmarks/_harness.js.map +1 -1
- package/dist/benchmarks/aec-bench.d.ts +1 -4
- package/dist/benchmarks/aec-bench.js +1 -2
- package/dist/benchmarks/agentbench.d.ts +2 -5
- package/dist/benchmarks/agentbench.js +1 -2
- package/dist/benchmarks/appworld.d.ts +8 -10
- package/dist/benchmarks/appworld.js +23 -23
- package/dist/benchmarks/appworld.js.map +1 -1
- package/dist/benchmarks/bfcl.d.ts +2 -5
- package/dist/benchmarks/bfcl.js +1 -2
- package/dist/benchmarks/cad-design.d.ts +2 -5
- package/dist/benchmarks/cad-design.js +2 -3
- package/dist/benchmarks/cad-design.js.map +1 -1
- package/dist/benchmarks/cadbench.d.ts +1 -4
- package/dist/benchmarks/cadbench.js +1 -2
- package/dist/benchmarks/cadgenbench.d.ts +1 -4
- package/dist/benchmarks/cadgenbench.js +1 -2
- package/dist/benchmarks/commit0.d.ts +2 -5
- package/dist/benchmarks/commit0.js +1 -2
- package/dist/benchmarks/crag.d.ts +1 -4
- package/dist/benchmarks/crag.js +3 -3
- package/dist/benchmarks/crag.js.map +1 -1
- package/dist/benchmarks/dabstep.d.ts +2 -5
- package/dist/benchmarks/dabstep.js +2 -3
- package/dist/benchmarks/dabstep.js.map +1 -1
- package/dist/benchmarks/enterpriseops-gym.d.ts +2 -5
- package/dist/benchmarks/enterpriseops-gym.js +1 -2
- package/dist/benchmarks/finresearchbench.d.ts +2 -5
- package/dist/benchmarks/finresearchbench.js +2 -3
- package/dist/benchmarks/finsearchcomp.d.ts +2 -5
- package/dist/benchmarks/finsearchcomp.js +4 -4
- package/dist/benchmarks/finsearchcomp.js.map +1 -1
- package/dist/benchmarks/frames.d.ts +3 -19
- package/dist/benchmarks/frames.js +13 -39
- package/dist/benchmarks/frames.js.map +1 -1
- package/dist/benchmarks/hotpotqa.d.ts +4 -14
- package/dist/benchmarks/hotpotqa.js +12 -32
- package/dist/benchmarks/hotpotqa.js.map +1 -1
- package/dist/benchmarks/humaneval.d.ts +9 -12
- package/dist/benchmarks/humaneval.js +2 -3
- package/dist/benchmarks/humaneval.js.map +1 -1
- package/dist/benchmarks/mcad-bench.d.ts +13 -16
- package/dist/benchmarks/mcad-bench.js +2 -3
- package/dist/benchmarks/mcad-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-bench.d.ts +17 -20
- package/dist/benchmarks/mcad-cq-bench.js +2 -3
- package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-golds.d.ts +2 -5
- package/dist/benchmarks/mcad-cq-golds.js +1 -2
- package/dist/benchmarks/mcad-golds.d.ts +1 -4
- package/dist/benchmarks/mcad-golds.js +0 -1
- package/dist/benchmarks/mcad-tasks.d.ts +5 -8
- package/dist/benchmarks/mcad-tasks.js +7 -8
- package/dist/benchmarks/mcad-tasks.js.map +1 -1
- package/dist/benchmarks/mind2web.d.ts +3 -5
- package/dist/benchmarks/mind2web.js +2 -3
- package/dist/benchmarks/mind2web.js.map +1 -1
- package/dist/benchmarks/nomiracl.d.ts +1 -4
- package/dist/benchmarks/nomiracl.js +1 -2
- package/dist/benchmarks/open-rag-bench.d.ts +1 -4
- package/dist/benchmarks/open-rag-bench.js +3 -3
- package/dist/benchmarks/open-rag-bench.js.map +1 -1
- package/dist/benchmarks/programbench.d.ts +2 -5
- package/dist/benchmarks/programbench.js +1 -2
- package/dist/benchmarks/rag-shared.d.ts +30 -22
- package/dist/benchmarks/rag-shared.js +8 -2
- package/dist/benchmarks/rag-shared.js.map +1 -1
- package/dist/benchmarks/ragbench.d.ts +1 -4
- package/dist/benchmarks/ragbench.js +3 -3
- package/dist/benchmarks/ragbench.js.map +1 -1
- package/dist/benchmarks/simpleqa.d.ts +2 -18
- package/dist/benchmarks/simpleqa.js +5 -31
- package/dist/benchmarks/simpleqa.js.map +1 -1
- package/dist/benchmarks/swe-bench.d.ts +7 -10
- package/dist/benchmarks/swe-bench.js +4 -4
- package/dist/benchmarks/swe-bench.js.map +1 -1
- package/dist/benchmarks/t2-ragbench.d.ts +1 -4
- package/dist/benchmarks/t2-ragbench.js +3 -3
- package/dist/benchmarks/t2-ragbench.js.map +1 -1
- package/dist/benchmarks/tau-bench-shared.d.ts +5 -8
- package/dist/benchmarks/tau-bench-shared.js +4 -4
- package/dist/benchmarks/tau-bench-shared.js.map +1 -1
- package/dist/benchmarks/tau2-bench.d.ts +2 -5
- package/dist/benchmarks/tau2-bench.js +1 -2
- package/dist/benchmarks/tau3-banking.d.ts +1 -4
- package/dist/benchmarks/tau3-banking.js +1 -2
- package/dist/benchmarks/terminal-bench.d.ts +1 -4
- package/dist/benchmarks/terminal-bench.js +4 -4
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/benchmarks/toollm.d.ts +2 -5
- package/dist/benchmarks/toollm.js +1 -2
- package/dist/benchmarks/trata-hedge.d.ts +1 -4
- package/dist/benchmarks/trata-hedge.js +2 -3
- package/dist/benchmarks/types.d.ts +6 -9
- package/dist/benchmarks/webarena-verified.d.ts +2 -5
- package/dist/benchmarks/webarena-verified.js +1 -2
- package/dist/{cadbench-BRF-59Mt.js → cadbench-DhAndllg.js} +4 -6
- package/dist/cadbench-DhAndllg.js.map +1 -0
- package/dist/{cadgenbench-DXtGkuW3.js → cadgenbench-Tvk16YKT.js} +15 -5
- package/dist/cadgenbench-Tvk16YKT.js.map +1 -0
- package/dist/index.d.ts +8 -18
- package/dist/index.js +16 -24
- package/dist/index.js.map +1 -1
- package/dist/{router-turn-uTYO6KQ1.js → router-turn-DNbQ_GjQ.js} +2 -3
- package/dist/router-turn-DNbQ_GjQ.js.map +1 -0
- package/fixtures/pier-agent/no-model-task/pre_artifacts.sh +0 -0
- package/fixtures/pier-agent/no-model-task/tests/test.sh +0 -0
- package/package.json +10 -10
- package/pier_agents/tangle_candidate.py +15 -23
- package/scripts/run-package-tests.mjs +8 -15
- package/scripts/verify-packed-consumer.mjs +0 -1
- package/src/atom-mcp-e2e.mts +16 -4
- package/src/benchmarks/frames.ts +10 -44
- package/src/benchmarks/hotpotqa.ts +9 -29
- package/src/benchmarks/rag-shared.ts +12 -0
- package/src/benchmarks/simpleqa.ts +2 -36
- package/src/commit0-prereqs.sh +0 -0
- package/src/corpus-replay.mts +8 -8
- package/src/corpus-report.mts +21 -21
- package/src/corpus.test.mts +5 -5
- package/src/corpus.ts +16 -16
- package/src/directives.ts +0 -38
- package/src/examples/lean-verify.ts +1 -1
- package/src/gate.ts +8 -8
- package/src/generate-eval/certify.ts +2 -2
- package/src/index.ts +1 -0
- package/src/refine-loop.ts +5 -5
- package/src/resolve-client.ts +1 -1
- package/src/router-turn.ts +3 -11
- package/src/run-benchmarks.test.mts +0 -4
- package/src/run-pool.ts +1 -1
- package/src/runtime-hook-recorder.ts +2 -2
- package/src/search-bench/tasks.ts +1 -1
- package/src/selector.test.mts +13 -13
- package/src/selector.ts +19 -19
- package/src/swe-bench-env.ts +4 -12
- package/src/swe-jail.ts +5 -156
- package/src/swe-structural-judge-policy.ts +3 -3
- package/src/swe-structural-policy.ts +3 -3
- package/src/swe-structural-provenance.ts +4 -4
- package/src/terminal-compare.ts +10 -10
- package/src/worker-blender.ts +2 -106
- package/src/worker-build123d.ts +2 -81
- package/tb_agents/opencode_router_agent.py +1 -1
- package/dist/cadbench-BRF-59Mt.js.map +0 -1
- package/dist/cadgenbench-DXtGkuW3.js.map +0 -1
- package/dist/router-turn-uTYO6KQ1.js.map +0 -1
- package/scripts/cadbench_prepare.py +0 -22
- package/scripts/cadgenbench_hard_parts.py +0 -48
- package/scripts/clbench_codebase_judge.py +0 -73
- package/scripts/render-gate-chart.mjs +0 -176
- package/scripts/trata-hedge/README.md +0 -57
- package/scripts/trata-hedge/run.sh +0 -64
- package/src/browser/adapters/bad-design-audit.ts +0 -153
- package/src/browser/adapters/bad-design-audit.verify.ts +0 -85
- package/src/browser/adapters/bad.ts +0 -165
- package/src/browser/agent-adapter.ts +0 -145
- package/src/browser/process-adapter.ts +0 -146
- package/src/browser/run-to-spans.ts +0 -105
- package/src/browser/run-to-spans.verify.ts +0 -89
- package/src/browser/ui-reviewer.ts +0 -200
- package/src/browser/ui-reviewer.verify.ts +0 -94
- package/src/browser/verify.ts +0 -96
- package/src/clbench-codebase-gate.mts +0 -314
- package/src/clbench-context-gate.mts +0 -341
- package/src/cloud-loop.mts +0 -156
- package/src/commit0-env-run.mts +0 -62
- package/src/commit0-env.ts +0 -172
- package/src/commit0-gate.mts +0 -558
- package/src/coordination-mcp-container-reach.mts +0 -182
- package/src/egress-probe.mts +0 -26
- package/src/fleet.mts +0 -143
- package/src/hev-structural.mts +0 -697
- package/src/humaneval-gate.mts +0 -220
- package/src/humaneval-repair-gate.mts +0 -182
- package/src/mbpp-structural.mts +0 -676
- package/src/mcp-mount-probe.mts +0 -139
- package/src/profile-coordinates.ts +0 -134
- package/src/profiles.ts +0 -128
- package/src/research-gate.mts +0 -132
- package/src/research-shot.ts +0 -144
- package/src/router-executor.ts +0 -51
- package/src/run-benchmarks-report.ts +0 -66
- package/src/sandbox-run.ts +0 -108
- package/src/search-bench/bridge.ts +0 -182
- package/src/search-bench/export.mts +0 -0
- package/src/search-bench/parametric-check.mts +0 -78
- package/src/search-bench/profiles.ts +0 -113
- package/src/search-bench/run.mts +0 -286
- package/src/search-bench/tasks-fresh.ts +0 -688
- package/src/skill-sandbox-smoke.mts +0 -101
- package/src/smoke-structural-rollout.mts +0 -415
- package/src/stats.mts +0 -90
- package/src/supervisor-arena.mts +0 -825
- package/src/swe-code-improve.mts +0 -306
- package/src/swe-emit-patch.mts +0 -125
- package/src/swe-improve.mts +0 -284
- package/src/swe-local-proof.mts +0 -265
- package/src/swe-repro-calibrate.mts +0 -451
- package/src/swe-stream.mts +0 -1561
- package/src/swe-structural.mts +0 -707
- package/src/tb-container-executor.mts +0 -266
- package/src/tb-container-executor.test.mts +0 -134
- package/src/tb-supervisor-sidecar.mts +0 -208
- package/src/trajectory-assemble.mjs +0 -130
- package/src/trata-gepa.mts +0 -381
- package/src/trata-hedge-solve.mts +0 -81
- package/src/worker-browser.ts +0 -115
- package/src/worker-cad.ts +0 -470
- package/src/workspace-loop.mts +0 -133
- package/tb_agents/opencode_refine_agent.py +0 -117
- package/tb_agents/opencode_supervisor_agent.py +0 -239
package/src/cloud-loop.mts
DELETED
|
@@ -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
|
-
})
|
package/src/commit0-env-run.mts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The HARD test: sample-vs-refine on Commit0 (implement entire stubbed Python libraries
|
|
3
|
-
* against their own test suites), through the PUBLISHED suite — runBenchmark over a
|
|
4
|
-
* Commit0 Environment (local Docker workspace, file tools, pytest as the check).
|
|
5
|
-
*
|
|
6
|
-
* COMMIT0_FIXTURES=1 N=3 BUDGET=3 INNER_TURNS=10 WORKER_MODEL=deepseek-v4-pro \
|
|
7
|
-
* tsx src/commit0-env-run.mts
|
|
8
|
-
*
|
|
9
|
-
* IDS=commit-0/wcwidth to pick repos; STRATEGIES=sample,refine,adaptiveRefine to choose arms.
|
|
10
|
-
*/
|
|
11
|
-
import { readFileSync } from 'node:fs'
|
|
12
|
-
import { join } from 'node:path'
|
|
13
|
-
import { adaptiveRefine, printBenchmarkReport, refine, runBenchmark, sample, type Strategy } from '@tangle-network/agent-runtime/kernel'
|
|
14
|
-
import { type Commit0Row, createCommit0Environment, rowToTask } from './commit0-env'
|
|
15
|
-
import { benchRouterProfile } from './router-turn'
|
|
16
|
-
|
|
17
|
-
function must(name: string): string {
|
|
18
|
-
const v = process.env[name]
|
|
19
|
-
if (!v) throw new Error(`env ${name} is required`)
|
|
20
|
-
return v
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function main(): Promise<void> {
|
|
24
|
-
const n = Number(process.env.N ?? 2)
|
|
25
|
-
const budget = Number(process.env.BUDGET ?? 3)
|
|
26
|
-
const model = process.env.WORKER_MODEL ?? 'deepseek-v4-pro'
|
|
27
|
-
const rows = (JSON.parse(readFileSync(join(import.meta.dirname, '..', 'fixtures', 'commit0.json'), 'utf8')) as Commit0Row[]).filter(
|
|
28
|
-
(r) => !process.env.IDS || process.env.IDS.split(',').includes(r.instance_id),
|
|
29
|
-
)
|
|
30
|
-
const picked = rows.slice(0, n)
|
|
31
|
-
const byName: Record<string, Strategy> = { sample, refine, adaptiveRefine }
|
|
32
|
-
const strategies = (process.env.STRATEGIES ?? 'sample,refine').split(',').map((s) => {
|
|
33
|
-
const st = byName[s.trim()]
|
|
34
|
-
if (!st) throw new Error(`unknown strategy ${s}`)
|
|
35
|
-
return st
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
console.error(`=== commit0 (HARD) · ${picked.map((r) => r.instance_id).join(', ')} · ${model} · budget=${budget} · [${strategies.map((s) => s.name).join(' vs ')}] ===\n`)
|
|
39
|
-
const environment = createCommit0Environment(picked)
|
|
40
|
-
const report = await runBenchmark({
|
|
41
|
-
environment,
|
|
42
|
-
tasks: picked.map(rowToTask),
|
|
43
|
-
worker: {
|
|
44
|
-
routerBaseUrl: process.env.ROUTER_BASE ?? 'https://router.tangle.tools/v1',
|
|
45
|
-
routerKey: must('TANGLE_API_KEY'),
|
|
46
|
-
workerProfile: benchRouterProfile('commit0-worker', model, {
|
|
47
|
-
systemPrompt: 'You are a senior Python engineer. Work through the available tools until the task is verified complete.',
|
|
48
|
-
maxTurns: Number(process.env.INNER_TURNS ?? 10),
|
|
49
|
-
temperature: 0.4,
|
|
50
|
-
}),
|
|
51
|
-
},
|
|
52
|
-
strategies,
|
|
53
|
-
budget,
|
|
54
|
-
concurrency: Number(process.env.CONCURRENCY ?? 1),
|
|
55
|
-
})
|
|
56
|
-
printBenchmarkReport(report)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
main().catch((e) => {
|
|
60
|
-
console.error(`commit0-env-run: ${e instanceof Error ? (e.stack ?? e.message) : String(e)}`)
|
|
61
|
-
process.exit(1)
|
|
62
|
-
})
|
package/src/commit0-env.ts
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Commit0 as an `Environment` — the HARD test (docs/research/long-horizon-benchmark-survey.md:
|
|
3
|
-
* the survey's top pick, graded + natively multi-stage). The agent implements an entire
|
|
4
|
-
* stubbed Python library so its existing test suite passes.
|
|
5
|
-
*
|
|
6
|
-
* Off-box construction (routes around the sandbox platform exactly like the EOPS gym):
|
|
7
|
-
* open() — clone the stub repo at base_commit into a tmpdir, start a PERSISTENT
|
|
8
|
-
* python:<ver>-slim container with the workspace mounted, `pip install -e .`
|
|
9
|
-
* + pytest once. The container is the artifact; it carries across shots.
|
|
10
|
-
* tools() — list_files / read_file / write_file / run_tests. The worker EDITS SOURCE
|
|
11
|
-
* VIA TOOLS (no diff emission). write_file is path-jailed and refuses the
|
|
12
|
-
* test dir — the agent cannot edit the check.
|
|
13
|
-
* score() — the repo's OWN pytest suite (passed/total), parsed from a quiet run inside
|
|
14
|
-
* the container. Deterministic, deployable. (The official commit0 harness can
|
|
15
|
-
* re-validate a winner from `git diff` later; it is not in the loop.)
|
|
16
|
-
* close() — kill the container, remove the tmpdir.
|
|
17
|
-
*/
|
|
18
|
-
import { execFile } from 'node:child_process'
|
|
19
|
-
import { mkdtempSync, rmSync } from 'node:fs'
|
|
20
|
-
import { tmpdir } from 'node:os'
|
|
21
|
-
import { join } from 'node:path'
|
|
22
|
-
import { promisify } from 'node:util'
|
|
23
|
-
import type { AgenticSurface, AgenticTask, AgenticTool, ArtifactHandle, SurfaceScore } from '@tangle-network/agent-runtime/kernel'
|
|
24
|
-
|
|
25
|
-
const exec = promisify(execFile)
|
|
26
|
-
|
|
27
|
-
export interface Commit0Row {
|
|
28
|
-
instance_id: string
|
|
29
|
-
repo: string
|
|
30
|
-
base_commit: string
|
|
31
|
-
setup: { install: string; pre_install?: string[] | null; python: string; specification?: string }
|
|
32
|
-
src_dir: string
|
|
33
|
-
test: { test_cmd: string; test_dir: string }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface Ws {
|
|
37
|
-
dir: string
|
|
38
|
-
container: string
|
|
39
|
-
row: Commit0Row
|
|
40
|
-
}
|
|
41
|
-
const workspaces = new Map<string, Ws>()
|
|
42
|
-
|
|
43
|
-
async function dockerExec(container: string, cmd: string, timeoutMs = 180_000): Promise<{ out: string; code: number }> {
|
|
44
|
-
try {
|
|
45
|
-
const r = await exec('docker', ['exec', container, 'bash', '-lc', cmd], { timeout: timeoutMs, maxBuffer: 8 * 1024 * 1024 })
|
|
46
|
-
return { out: `${r.stdout}\n${r.stderr}`.trim(), code: 0 }
|
|
47
|
-
} catch (e) {
|
|
48
|
-
const err = e as { stdout?: string; stderr?: string; code?: number }
|
|
49
|
-
return { out: `${err.stdout ?? ''}\n${err.stderr ?? ''}`.trim(), code: typeof err.code === 'number' ? err.code : 1 }
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** Parse pytest's summary tail ("X passed", "Y failed", "Z errors") into counts. */
|
|
54
|
-
function parsePytest(out: string): { passed: number; failed: number } {
|
|
55
|
-
const grab = (re: RegExp) => {
|
|
56
|
-
const m = out.match(re)
|
|
57
|
-
return m ? Number(m[1]) : 0
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
passed: grab(/(\d+) passed/),
|
|
61
|
-
failed: grab(/(\d+) failed/) + grab(/(\d+) error/),
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function rowToTask(row: Commit0Row): AgenticTask {
|
|
66
|
-
return {
|
|
67
|
-
id: row.instance_id,
|
|
68
|
-
userPrompt:
|
|
69
|
-
'You are a senior Python engineer implementing a stubbed library so its existing test suite passes. ' +
|
|
70
|
-
'Workflow: list_files and read the tests + stubs to learn the required behavior, write COMPLETE implementations ' +
|
|
71
|
-
`with write_file (source under ${row.src_dir} only — the test dir is read-only), then run_tests and fix failures. ` +
|
|
72
|
-
'Iterate until the suite passes. Reply DONE only when run_tests shows no failures.\n\n' +
|
|
73
|
-
`Implement the stubbed library "${row.repo}". The public functions/classes under \`${row.src_dir}\` have empty bodies. ` +
|
|
74
|
-
`Make the existing tests under \`${row.test.test_dir}\` pass.${row.setup.specification ? ` Spec: ${row.setup.specification}` : ''}`,
|
|
75
|
-
meta: { instanceId: row.instance_id },
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function createCommit0Environment(rows: Commit0Row[]): AgenticSurface {
|
|
80
|
-
const byId = new Map(rows.map((r) => [r.instance_id, r]))
|
|
81
|
-
return {
|
|
82
|
-
name: 'commit0',
|
|
83
|
-
async open(task) {
|
|
84
|
-
const row = byId.get(task.id)
|
|
85
|
-
if (!row) throw new Error(`commit0-env: unknown task ${task.id}`)
|
|
86
|
-
const dir = mkdtempSync(join(tmpdir(), 'c0-'))
|
|
87
|
-
await exec('git', ['clone', '--quiet', `https://github.com/${row.repo}.git`, dir], { timeout: 120_000 })
|
|
88
|
-
await exec('git', ['-C', dir, 'checkout', '--quiet', row.base_commit], { timeout: 60_000 })
|
|
89
|
-
const container = `c0-${task.id.replace(/[^a-z0-9]/gi, '-')}-${Math.random().toString(36).slice(2, 8)}`
|
|
90
|
-
await exec('docker', ['run', '-d', '--name', container, '--cpus=2', '--memory=2g', '-v', `${dir}:/w`, '-w', '/w', `python:${row.setup.python}-slim`, 'sleep', 'infinity'], { timeout: 120_000 })
|
|
91
|
-
for (const pre of row.setup.pre_install ?? []) await dockerExec(container, pre, 300_000)
|
|
92
|
-
const setup = await dockerExec(container, `${row.setup.install} && pip install -q pytest`, 600_000)
|
|
93
|
-
if (setup.code !== 0) {
|
|
94
|
-
await dockerExec(container, 'find /w -mindepth 1 -delete', 60_000).catch(() => {})
|
|
95
|
-
await exec('docker', ['rm', '-f', container]).catch(() => {})
|
|
96
|
-
rmSync(dir, { recursive: true, force: true })
|
|
97
|
-
throw new Error(`commit0-env setup failed for ${task.id}: ${setup.out.slice(-300)}`)
|
|
98
|
-
}
|
|
99
|
-
const handle: ArtifactHandle = { id: container, surface: 'commit0' }
|
|
100
|
-
workspaces.set(container, { dir, container, row })
|
|
101
|
-
return handle
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
async tools(task) {
|
|
105
|
-
const row = byId.get(task.id)
|
|
106
|
-
const src = row?.src_dir ?? 'src/'
|
|
107
|
-
const tests = row?.test.test_dir ?? 'tests/'
|
|
108
|
-
return [
|
|
109
|
-
{ type: 'function', function: { name: 'list_files', description: `List the repo's source (${src}) and test (${tests}) files.`, parameters: { type: 'object', properties: {} } } },
|
|
110
|
-
{ type: 'function', function: { name: 'read_file', description: 'Read a file from the repo (bounded).', parameters: { type: 'object', properties: { path: { type: 'string' } }, required: ['path'] } } },
|
|
111
|
-
{ type: 'function', function: { name: 'write_file', description: `Write COMPLETE file contents (source under ${src} only; the test dir is read-only).`, parameters: { type: 'object', properties: { path: { type: 'string' }, content: { type: 'string' } }, required: ['path', 'content'] } } },
|
|
112
|
-
{ type: 'function', function: { name: 'run_tests', description: 'Run the existing test suite; returns the pytest summary + failure tails.', parameters: { type: 'object', properties: {} } } },
|
|
113
|
-
] satisfies AgenticTool[]
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
async call(handle, name, args) {
|
|
117
|
-
const ws = workspaces.get(handle.id)
|
|
118
|
-
if (!ws) return 'ERROR: workspace closed'
|
|
119
|
-
const jail = (p: string): string | null => {
|
|
120
|
-
const norm = p.replace(/^\.?\//, '')
|
|
121
|
-
if (norm.includes('..') || norm.startsWith('/')) return null
|
|
122
|
-
return norm
|
|
123
|
-
}
|
|
124
|
-
if (name === 'list_files') {
|
|
125
|
-
const r = await dockerExec(ws.container, `find ${ws.row.src_dir} ${ws.row.test.test_dir} -name '*.py' | head -80`, 30_000)
|
|
126
|
-
return r.out.slice(0, 2000)
|
|
127
|
-
}
|
|
128
|
-
if (name === 'read_file') {
|
|
129
|
-
const p = jail(String(args.path ?? ''))
|
|
130
|
-
if (!p) return 'ERROR: invalid path'
|
|
131
|
-
const r = await dockerExec(ws.container, `cat ${JSON.stringify(p)}`, 30_000)
|
|
132
|
-
return r.code === 0 ? r.out.slice(0, 8000) : `ERROR: ${r.out.slice(0, 200)}`
|
|
133
|
-
}
|
|
134
|
-
if (name === 'write_file') {
|
|
135
|
-
const p = jail(String(args.path ?? ''))
|
|
136
|
-
if (!p) return 'ERROR: invalid path'
|
|
137
|
-
if (p.startsWith(ws.row.test.test_dir.replace(/^\.?\//, ''))) return 'ERROR: the test dir is read-only — implement the source, not the tests'
|
|
138
|
-
const content = String(args.content ?? '')
|
|
139
|
-
const b64 = Buffer.from(content, 'utf8').toString('base64')
|
|
140
|
-
const r = await dockerExec(ws.container, `mkdir -p $(dirname ${JSON.stringify(p)}) && echo '${b64}' | base64 -d > ${JSON.stringify(p)}`, 30_000)
|
|
141
|
-
return r.code === 0 ? `wrote ${p} (${content.length} chars)` : `ERROR: ${r.out.slice(0, 200)}`
|
|
142
|
-
}
|
|
143
|
-
if (name === 'run_tests') {
|
|
144
|
-
// `-o addopts=` neutralizes repo-configured pytest plugins (e.g. wcwidth's tox.ini
|
|
145
|
-
// demands pytest-cov) that aren't installed and would usage-error before any test runs.
|
|
146
|
-
const r = await dockerExec(ws.container, `${ws.row.test.test_cmd} ${ws.row.test.test_dir} -q --tb=line -p no:cacheprovider -o addopts= 2>&1 | tail -30`, 240_000)
|
|
147
|
-
return r.out.slice(0, 2500)
|
|
148
|
-
}
|
|
149
|
-
return `ERROR: unknown tool ${name}`
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
async score(_task, handle) {
|
|
153
|
-
const ws = workspaces.get(handle.id)
|
|
154
|
-
if (!ws) return { passes: 0, total: 0, errored: 1 }
|
|
155
|
-
const r = await dockerExec(ws.container, `${ws.row.test.test_cmd} ${ws.row.test.test_dir} -q --tb=no -p no:cacheprovider -o addopts= 2>&1 | tail -5`, 240_000)
|
|
156
|
-
const { passed, failed } = parsePytest(r.out)
|
|
157
|
-
const total = passed + failed
|
|
158
|
-
return total > 0 ? { passes: passed, total, errored: 0 } : { passes: 0, total: 0, errored: 1 }
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
async close(handle) {
|
|
162
|
-
const ws = workspaces.get(handle.id)
|
|
163
|
-
if (!ws) return
|
|
164
|
-
workspaces.delete(handle.id)
|
|
165
|
-
// The container ran as root, so its writes on the bind mount are root-owned and the
|
|
166
|
-
// host rmSync would EACCES — wipe the mount from INSIDE the container first.
|
|
167
|
-
await dockerExec(ws.container, 'find /w -mindepth 1 -delete', 60_000).catch(() => {})
|
|
168
|
-
await exec('docker', ['rm', '-f', ws.container]).catch(() => {})
|
|
169
|
-
rmSync(ws.dir, { recursive: true, force: true })
|
|
170
|
-
},
|
|
171
|
-
}
|
|
172
|
-
}
|