@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.
- package/CHANGELOG.md +46 -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/src/atom-mcp-e2e.mts +2 -2
- 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 +7 -7
- 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-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/cloud-loop.mts +0 -156
- package/src/coordination-mcp-container-reach.mts +0 -182
- package/src/fleet.mts +0 -143
- package/src/hev-structural.mts +0 -697
- package/src/humaneval-gate.mts +0 -220
- package/src/mbpp-structural.mts +0 -676
- package/src/mcp-mount-probe.mts +0 -141
- 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/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/smoke-structural-rollout.mts +0 -415
- package/src/stats.mts +0 -90
- package/src/swe-code-improve.mts +0 -306
- package/src/swe-improve.mts +0 -284
- 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/trata-gepa.mts +0 -381
- package/src/trata-hedge-solve.mts +0 -81
- package/tb_agents/opencode_refine_agent.py +0 -117
- package/tb_agents/opencode_supervisor_agent.py +0 -239
package/src/selector.test.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import assert from 'node:assert/strict'
|
|
2
|
-
import type { AttemptRecord,
|
|
2
|
+
import type { AttemptRecord, BenchRunRecord } from './corpus'
|
|
3
3
|
import {
|
|
4
4
|
bootstrapDeltaCI,
|
|
5
5
|
flipRate,
|
|
6
|
-
|
|
6
|
+
normalizeVoteKey,
|
|
7
7
|
scoreSelectorOnRun,
|
|
8
8
|
scoreVerifierSelectorOnRun,
|
|
9
9
|
selfConsistencySelect,
|
|
@@ -22,11 +22,11 @@ assert.throws(() => verifierGroundedSelect([]), /no candidate pass-counts/)
|
|
|
22
22
|
assert.throws(() => verifierGroundedSelect([0, -1]), /invalid pass-count/)
|
|
23
23
|
assert.throws(() => verifierGroundedSelect([0, Number.NaN]), /invalid pass-count/)
|
|
24
24
|
|
|
25
|
-
// ---
|
|
26
|
-
assert.equal(
|
|
27
|
-
assert.equal(
|
|
28
|
-
assert.equal(
|
|
29
|
-
assert.equal(
|
|
25
|
+
// --- normalizeVoteKey ---
|
|
26
|
+
assert.equal(normalizeVoteKey(' The Paris. '), 'paris')
|
|
27
|
+
assert.equal(normalizeVoteKey('"London"'), 'london')
|
|
28
|
+
assert.equal(normalizeVoteKey('a Cat'), 'cat')
|
|
29
|
+
assert.equal(normalizeVoteKey('New York'), 'new york')
|
|
30
30
|
|
|
31
31
|
// --- selfConsistencySelect: majority, ties, single ---
|
|
32
32
|
assert.equal(selfConsistencySelect(['Paris', 'Paris', 'London']), 0, 'largest cluster')
|
|
@@ -35,7 +35,7 @@ assert.equal(selfConsistencySelect(['a', 'b']), 0, 'tie → earliest cluster')
|
|
|
35
35
|
assert.equal(selfConsistencySelect(['only']), 0)
|
|
36
36
|
assert.throws(() => selfConsistencySelect([]), /no candidate outputs/)
|
|
37
37
|
|
|
38
|
-
// helper: build a
|
|
38
|
+
// helper: build a BenchRunRecord whose attempts carry (output, valid)
|
|
39
39
|
const att = (output: string, valid: boolean): AttemptRecord => ({
|
|
40
40
|
round: 0,
|
|
41
41
|
prompt: '',
|
|
@@ -48,7 +48,7 @@ const att = (output: string, valid: boolean): AttemptRecord => ({
|
|
|
48
48
|
eventCount: 0,
|
|
49
49
|
eventTypes: {},
|
|
50
50
|
})
|
|
51
|
-
const rec = (atts: AttemptRecord[], blind = atts[0]?.valid === true):
|
|
51
|
+
const rec = (atts: AttemptRecord[], blind = atts[0]?.valid === true): BenchRunRecord => ({
|
|
52
52
|
ts: '',
|
|
53
53
|
benchmark: 'test',
|
|
54
54
|
instanceId: 'i',
|
|
@@ -77,7 +77,7 @@ const rec = (atts: AttemptRecord[], blind = atts[0]?.valid === true): RunRecord
|
|
|
77
77
|
// --- selector beats random when the majority correlates with correctness ---
|
|
78
78
|
// Across instances where the right answer is usually the majority, selector@k > random@k.
|
|
79
79
|
{
|
|
80
|
-
const records:
|
|
80
|
+
const records: BenchRunRecord[] = [
|
|
81
81
|
rec([att('A', true), att('A', true), att('B', false)]), // majority right
|
|
82
82
|
rec([att('X', true), att('Y', false), att('X', true)]), // majority right
|
|
83
83
|
rec([att('Q', false), att('Q', false), att('R', true)]), // majority wrong (selector loses this one)
|
|
@@ -94,7 +94,7 @@ const rec = (atts: AttemptRecord[], blind = atts[0]?.valid === true): RunRecord
|
|
|
94
94
|
|
|
95
95
|
// --- unscoreable record (no outputs) is skipped, not counted as a pass ---
|
|
96
96
|
{
|
|
97
|
-
const blank:
|
|
97
|
+
const blank: BenchRunRecord = {
|
|
98
98
|
ts: '', benchmark: 'test', instanceId: 'i', condition: 'random@3', model: 'm',
|
|
99
99
|
blindResolved: false, resolved: false, infraError: true,
|
|
100
100
|
attempts: [{ round: 0, prompt: '', costUsd: 0, tokensIn: 0, tokensOut: 0, eventCount: 0, eventTypes: {} }],
|
|
@@ -126,7 +126,7 @@ const attS = (score: number, output = `out-${score}`): AttemptRecord => ({
|
|
|
126
126
|
eventCount: 0,
|
|
127
127
|
eventTypes: {},
|
|
128
128
|
})
|
|
129
|
-
const recS = (scores: number[]):
|
|
129
|
+
const recS = (scores: number[]): BenchRunRecord => ({
|
|
130
130
|
ts: '', benchmark: 'aec', instanceId: 'i', condition: 'random@4', model: 'm',
|
|
131
131
|
blindResolved: (scores[0] ?? 0) >= 1,
|
|
132
132
|
resolved: scores.some((s) => s >= 1),
|
|
@@ -175,7 +175,7 @@ const recS = (scores: number[]): RunRecord => ({
|
|
|
175
175
|
|
|
176
176
|
// unscoreable (no checker score on any attempt) is skipped, not counted
|
|
177
177
|
{
|
|
178
|
-
const noScore:
|
|
178
|
+
const noScore: BenchRunRecord = {
|
|
179
179
|
ts: '', benchmark: 'aec', instanceId: 'i', condition: 'random@4', model: 'm',
|
|
180
180
|
blindResolved: false, resolved: false, infraError: false,
|
|
181
181
|
attempts: [{ round: 0, prompt: '', output: 'x', costUsd: 0, tokensIn: 0, tokensOut: 0, eventCount: 0, eventTypes: {} }],
|
package/src/selector.ts
CHANGED
|
@@ -8,23 +8,23 @@
|
|
|
8
8
|
* firewall: a Selector is `(outputs: string[]) => index`; it is structurally
|
|
9
9
|
* incapable of reading `valid`/`score`, so it cannot become an oracle by accident.
|
|
10
10
|
*
|
|
11
|
-
* Scoring is OFFLINE over the corpus: each random@k
|
|
11
|
+
* Scoring is OFFLINE over the corpus: each random@k BenchRunRecord already holds k
|
|
12
12
|
* attempts each with a stored `valid`, so picking index i and reading
|
|
13
13
|
* attempts[i].valid is the judge's verdict of the pick — zero new rollouts, zero
|
|
14
14
|
* new judge calls. selector@k vs random@k (does picking beat a blind random draw?)
|
|
15
15
|
* and selector@k vs oracle@k (how much ceiling is recoverable?) fall straight out.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type { AttemptRecord,
|
|
18
|
+
import type { AttemptRecord, BenchRunRecord } from './corpus'
|
|
19
19
|
|
|
20
20
|
/** Picks one of `outputs` by index, using the candidate text only. Never the verdict. */
|
|
21
|
-
|
|
21
|
+
type Selector = (outputs: string[]) => number
|
|
22
22
|
|
|
23
23
|
/** Normalize a short free-text answer so equivalent answers cluster: lowercase,
|
|
24
24
|
* trim, collapse whitespace, strip surrounding quotes/punctuation, drop a leading
|
|
25
25
|
* article. Deliberately conservative — it clusters trivial restatements, not
|
|
26
26
|
* paraphrases (that is the selector's known ceiling, not a bug). */
|
|
27
|
-
export function
|
|
27
|
+
export function normalizeVoteKey(s: string): string {
|
|
28
28
|
return s
|
|
29
29
|
.toLowerCase()
|
|
30
30
|
.trim()
|
|
@@ -45,13 +45,13 @@ export const selfConsistencySelect: Selector = (outputs) => {
|
|
|
45
45
|
if (outputs.length === 0) throw new Error('selfConsistencySelect: no candidate outputs')
|
|
46
46
|
const counts = new Map<string, number>()
|
|
47
47
|
for (const o of outputs) {
|
|
48
|
-
const k =
|
|
48
|
+
const k = normalizeVoteKey(o)
|
|
49
49
|
counts.set(k, (counts.get(k) ?? 0) + 1)
|
|
50
50
|
}
|
|
51
51
|
let bestIdx = 0
|
|
52
52
|
let bestCount = -1
|
|
53
53
|
for (let i = 0; i < outputs.length; i += 1) {
|
|
54
|
-
const c = counts.get(
|
|
54
|
+
const c = counts.get(normalizeVoteKey(outputs[i] as string)) ?? 0
|
|
55
55
|
if (c > bestCount) {
|
|
56
56
|
bestCount = c
|
|
57
57
|
bestIdx = i // first member of the largest cluster encountered
|
|
@@ -86,7 +86,7 @@ export function verifierGroundedSelect(passCounts: ReadonlyArray<number>): numbe
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/** One instance's offline selector outcome, all derived from stored verdicts. */
|
|
89
|
-
|
|
89
|
+
interface SelectorOutcome {
|
|
90
90
|
/** usable candidates (attempts with a non-empty output) */
|
|
91
91
|
k: number
|
|
92
92
|
/** the picked attempt's stored verdict — selector@k for this instance */
|
|
@@ -99,15 +99,15 @@ export interface SelectorOutcome {
|
|
|
99
99
|
blind: boolean
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
const usableCandidates = (record:
|
|
102
|
+
const usableCandidates = (record: BenchRunRecord): AttemptRecord[] =>
|
|
103
103
|
record.attempts.filter((a) => typeof a.output === 'string' && a.output.length > 0)
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
* Score a selector on one
|
|
106
|
+
* Score a selector on one BenchRunRecord offline. Returns null when no attempt produced
|
|
107
107
|
* an output (unscoreable — not a pass). The selector sees OUTPUTS ONLY; the stored
|
|
108
108
|
* `valid` flags are read after the pick, never passed to the selector.
|
|
109
109
|
*/
|
|
110
|
-
export function scoreSelectorOnRun(record:
|
|
110
|
+
export function scoreSelectorOnRun(record: BenchRunRecord, select: Selector): SelectorOutcome | null {
|
|
111
111
|
const usable = usableCandidates(record)
|
|
112
112
|
if (usable.length === 0) return null
|
|
113
113
|
const picked = select(usable.map((a) => a.output as string))
|
|
@@ -124,7 +124,7 @@ export function scoreSelectorOnRun(record: RunRecord, select: Selector): Selecto
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
interface SelectorReport {
|
|
128
128
|
/** scoreable instances */
|
|
129
129
|
n: number
|
|
130
130
|
selectorRate: number
|
|
@@ -142,7 +142,7 @@ export interface SelectorReport {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/** Aggregate the offline selector outcome across a corpus slice (one condition). */
|
|
145
|
-
export function summarizeSelector(records:
|
|
145
|
+
export function summarizeSelector(records: BenchRunRecord[], select: Selector): SelectorReport {
|
|
146
146
|
let n = 0
|
|
147
147
|
let selector = 0
|
|
148
148
|
let randomExp = 0
|
|
@@ -196,11 +196,11 @@ export function summarizeSelector(records: RunRecord[], select: Selector): Selec
|
|
|
196
196
|
// outcome; selection itself ranks by the checker score, never by the gold.
|
|
197
197
|
// ---------------------------------------------------------------------------
|
|
198
198
|
|
|
199
|
-
const scoredAttempts = (record:
|
|
199
|
+
const scoredAttempts = (record: BenchRunRecord): AttemptRecord[] =>
|
|
200
200
|
record.attempts.filter((a) => typeof a.score === 'number' && Number.isFinite(a.score))
|
|
201
201
|
|
|
202
202
|
/** One instance's verifier-grounded outcome on the continuous graded reward. */
|
|
203
|
-
|
|
203
|
+
interface VerifierSelectorOutcome {
|
|
204
204
|
k: number
|
|
205
205
|
/** reward of the argmax-score pick (== max score) — what a deployable best-of-k ships */
|
|
206
206
|
selectorReward: number
|
|
@@ -217,11 +217,11 @@ export interface VerifierSelectorOutcome {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
/**
|
|
220
|
-
* Score verifier-grounded selection on one
|
|
220
|
+
* Score verifier-grounded selection on one BenchRunRecord offline. Returns null when no
|
|
221
221
|
* attempt carries a numeric checker score (unscoreable). The selector ranks by the
|
|
222
222
|
* stored `score` only; `valid` is read post-pick to report the binary outcome.
|
|
223
223
|
*/
|
|
224
|
-
export function scoreVerifierSelectorOnRun(record:
|
|
224
|
+
export function scoreVerifierSelectorOnRun(record: BenchRunRecord): VerifierSelectorOutcome | null {
|
|
225
225
|
const usable = scoredAttempts(record)
|
|
226
226
|
if (usable.length === 0) return null
|
|
227
227
|
const scores = usable.map((a) => a.score as number)
|
|
@@ -281,7 +281,7 @@ export function bootstrapDeltaCI(
|
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
|
|
284
|
+
interface VerifierSelectorReport {
|
|
285
285
|
/** scoreable instances */
|
|
286
286
|
n: number
|
|
287
287
|
selectorReward: number
|
|
@@ -302,7 +302,7 @@ export interface VerifierSelectorReport {
|
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
/** Aggregate verifier-grounded selection across a corpus slice (one condition). */
|
|
305
|
-
export function summarizeVerifierSelector(records:
|
|
305
|
+
export function summarizeVerifierSelector(records: BenchRunRecord[]): VerifierSelectorReport {
|
|
306
306
|
let n = 0
|
|
307
307
|
let selR = 0
|
|
308
308
|
let randR = 0
|
|
@@ -352,7 +352,7 @@ export function summarizeVerifierSelector(records: RunRecord[]): VerifierSelecto
|
|
|
352
352
|
* (or two seeds) reveals how much its decision is noise. A selector whose flips
|
|
353
353
|
* move the resolve rate is not a selector.
|
|
354
354
|
*/
|
|
355
|
-
export function flipRate(records:
|
|
355
|
+
export function flipRate(records: BenchRunRecord[], a: Selector, b: Selector): number {
|
|
356
356
|
let n = 0
|
|
357
357
|
let flips = 0
|
|
358
358
|
for (const r of records) {
|
package/src/swe-bench-env.ts
CHANGED
|
@@ -131,14 +131,6 @@ import importlib.metadata
|
|
|
131
131
|
print(importlib.metadata.version("swebench"))
|
|
132
132
|
`
|
|
133
133
|
|
|
134
|
-
/** Installed official scorer package stamped into experiment execution receipts. */
|
|
135
|
-
export async function resolveSweBenchScorerVersion(): Promise<string> {
|
|
136
|
-
const output = await runVenvPython(SWEBENCH_VERSION_SCRIPT, [], 60_000)
|
|
137
|
-
const version = output.trim().split('\n').filter(Boolean).pop() ?? ''
|
|
138
|
-
if (!version) throw new Error('could not resolve installed swebench scorer version')
|
|
139
|
-
return version
|
|
140
|
-
}
|
|
141
|
-
|
|
142
134
|
/**
|
|
143
135
|
* Cheap string pre-filter for an agent-supplied repo-relative path, applied before the path is
|
|
144
136
|
* joined to a workspace root: rejects absolute paths and any `..` segment, strips a leading `./`.
|
|
@@ -158,17 +150,17 @@ export const jailPath = (_root: string, p: string): string | null => {
|
|
|
158
150
|
*/
|
|
159
151
|
export const isInsideJail = (jailRoot: string, real: string): boolean => real === jailRoot || real.startsWith(jailRoot + sep)
|
|
160
152
|
|
|
161
|
-
|
|
153
|
+
interface SweImageIdentity {
|
|
162
154
|
id: string
|
|
163
155
|
repoDigests: string[]
|
|
164
156
|
}
|
|
165
157
|
|
|
166
|
-
|
|
158
|
+
interface SweImageCandidate {
|
|
167
159
|
tag: string
|
|
168
160
|
namespace: 'swebench' | 'none'
|
|
169
161
|
}
|
|
170
162
|
|
|
171
|
-
|
|
163
|
+
type SweImageResolution =
|
|
172
164
|
| { ok: true; tag: string; namespace: SweImageCandidate['namespace']; identity: SweImageIdentity }
|
|
173
165
|
| { ok: false; reason: string }
|
|
174
166
|
|
|
@@ -220,7 +212,7 @@ interface Ws {
|
|
|
220
212
|
* Fail-closed: docker down / no cached image / resolver error → `{ ok:false }`. Exported so script-side
|
|
221
213
|
* calibrators (swe-repro-calibrate) hard-assert image presence through the SAME resolution the `run`
|
|
222
214
|
* tool uses instead of hand-building tags. */
|
|
223
|
-
|
|
215
|
+
async function resolveImageForMetadata(
|
|
224
216
|
metadata: Record<string, unknown>,
|
|
225
217
|
): Promise<SweImageResolution> {
|
|
226
218
|
let candidates: SweImageCandidate[]
|
package/src/swe-jail.ts
CHANGED
|
@@ -18,11 +18,9 @@ import { runBenchRouterTurn, withBenchProfile } from './router-turn'
|
|
|
18
18
|
|
|
19
19
|
const exec = promisify(execFile)
|
|
20
20
|
|
|
21
|
-
export const tail = (s: string, n: number): string => (s.length > n ? `…${s.slice(s.length - n)}` : s)
|
|
22
|
-
|
|
23
21
|
// ---------- zai chat client (Runtime transport; patient 429 ladder) ----------
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
interface ZaiCfg {
|
|
26
24
|
base: string
|
|
27
25
|
key: string
|
|
28
26
|
timeoutMs: number
|
|
@@ -34,7 +32,7 @@ export interface ZaiCfg {
|
|
|
34
32
|
maxAttempts?: number
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
interface ZaiRaw {
|
|
38
36
|
/** The OpenAI-compatible message and usage fields expected by existing SWE callers. */
|
|
39
37
|
json: Record<string, unknown>
|
|
40
38
|
/** Runtime completion attempts spent (retries included). */
|
|
@@ -202,7 +200,7 @@ export function assertNoHiddenLeak(marks: readonly string[], msgs: ReadonlyArray
|
|
|
202
200
|
|
|
203
201
|
// ---------- jailed python execution ----------
|
|
204
202
|
|
|
205
|
-
|
|
203
|
+
interface JailRun {
|
|
206
204
|
code: number
|
|
207
205
|
out: string
|
|
208
206
|
timedOut: boolean
|
|
@@ -212,166 +210,17 @@ export interface JailRun {
|
|
|
212
210
|
/** Echoed by the in-container shell after a successful `git apply` of the ride-along patch —
|
|
213
211
|
* unambiguously separates "patch failed to apply" (no sentinel, git's error in the output) from
|
|
214
212
|
* "patched code still fails" (sentinel present, the script's own nonzero exit). */
|
|
215
|
-
|
|
213
|
+
const APPLY_SENTINEL = '__PATCH_APPLIED__'
|
|
216
214
|
|
|
217
215
|
let runSeq = 0
|
|
218
216
|
|
|
219
|
-
/** `treeDir === null` ⇒ run against the image's OWN built /testbed (the `image` substrate); a string
|
|
220
|
-
* ⇒ mount that host tree :ro over /testbed (the `mount` substrate — the run tool's exact pattern).
|
|
221
|
-
* `applyPatch` (image-substrate patch runs) applies a patch to the container's writable layer before
|
|
222
|
-
* running; --rm discards it, so every run still starts from the pristine image. */
|
|
223
|
-
export async function runPyInJail(
|
|
224
|
-
imageTag: string,
|
|
225
|
-
treeDir: string | null,
|
|
226
|
-
pyScript: string,
|
|
227
|
-
applyPatch?: string,
|
|
228
|
-
opts: { timeoutS?: number } = {},
|
|
229
|
-
): Promise<JailRun> {
|
|
230
|
-
const scriptDir = mkdtempSync(join(tmpdir(), 'swe-repro-'))
|
|
231
|
-
writeFileSync(join(scriptDir, 'repro.py'), pyScript)
|
|
232
|
-
if (applyPatch) writeFileSync(join(scriptDir, 'ride.patch'), applyPatch.endsWith('\n') ? applyPatch : `${applyPatch}\n`)
|
|
233
|
-
const T = opts.timeoutS ?? 120
|
|
234
|
-
const containerName = `swe-repro-${process.pid}-${Date.now()}-${runSeq++}`
|
|
235
|
-
// Identical shape to swe-bench-env's run tool; the command is the fixed `python /repro/repro.py`,
|
|
236
|
-
// so no SWE_CMD env ride-along is needed. The script rides in on a SECOND :ro mount.
|
|
237
|
-
// PYTHONPATH=/testbed is LOAD-BEARING: `python /repro/repro.py` puts /repro (the script's dir), not
|
|
238
|
-
// the cwd, at sys.path[0], so without it `import <pkg>` resolves to the image's baked-in install —
|
|
239
|
-
// the UNPATCHED code — and the patched tree is never exercised (verified on psf__requests-1142:
|
|
240
|
-
// post-gold run kept failing until PYTHONPATH pinned the mounted tree). The run tool never hits this
|
|
241
|
-
// because `python -c`/`python -m` put the cwd on sys.path.
|
|
242
|
-
const shell =
|
|
243
|
-
'{ source /opt/miniconda3/etc/profile.d/conda.sh && conda activate testbed && cd /testbed && ' +
|
|
244
|
-
(applyPatch ? `git apply --whitespace=nowarn /repro/ride.patch && echo ${APPLY_SENTINEL} && ` : '') +
|
|
245
|
-
'timeout -s KILL "$SWE_T"s env PYTHONPATH=/testbed python /repro/repro.py; } 2>&1'
|
|
246
|
-
const dockerArgs = [
|
|
247
|
-
'run', '--rm', '--name', containerName, '--network', 'none',
|
|
248
|
-
...(treeDir ? ['-v', `${treeDir}:/testbed:ro`] : []),
|
|
249
|
-
'-v', `${scriptDir}:/repro:ro`, '-w', '/testbed',
|
|
250
|
-
'-e', 'PYTHONDONTWRITEBYTECODE=1', '-e', `SWE_T=${T}`,
|
|
251
|
-
imageTag, 'bash', '-lc', shell,
|
|
252
|
-
]
|
|
253
|
-
let code = 0
|
|
254
|
-
let out = ''
|
|
255
|
-
// docker exit 125 (the daemon refused to start the container — transient resource pressure,
|
|
256
|
-
// a momentary daemon hiccup) is NOT a test result. Retry a few times with backoff before
|
|
257
|
-
// surfacing it as an infra error, so one bad daemon window can't nuke an instance (or, when it
|
|
258
|
-
// hits the canary of every instance in a fast error-loop, the whole stream).
|
|
259
|
-
for (let attempt = 0; ; attempt += 1) {
|
|
260
|
-
code = 0
|
|
261
|
-
out = ''
|
|
262
|
-
try {
|
|
263
|
-
const r = await exec('docker', dockerArgs, { timeout: (T + 20) * 1000, killSignal: 'SIGKILL', maxBuffer: 20_000_000 })
|
|
264
|
-
out = r.stdout
|
|
265
|
-
} catch (e) {
|
|
266
|
-
const err = e as { code?: number; killed?: boolean; stdout?: string; stderr?: string; message?: string }
|
|
267
|
-
if (typeof err.code === 'number') {
|
|
268
|
-
code = err.code
|
|
269
|
-
out = `${err.stdout ?? ''}${err.stderr ?? ''}`
|
|
270
|
-
} else if (err.killed) {
|
|
271
|
-
code = 124
|
|
272
|
-
out = `${err.stdout ?? ''}\n[host timeout: docker run exceeded ${T + 20}s and was killed]`
|
|
273
|
-
} else {
|
|
274
|
-
rmSync(scriptDir, { recursive: true, force: true })
|
|
275
|
-
return { code: -1, out: '', timedOut: false, infraError: `run failed to execute (${String(err.message ?? e).slice(0, 200)})` }
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
const transient = code === 125 || /Cannot connect to the Docker daemon|error creating overlay mount|no space left/i.test(out)
|
|
279
|
-
if (!transient || attempt >= 4) break
|
|
280
|
-
await exec('docker', ['rm', '-f', containerName], { timeout: 20_000 }).catch(() => {})
|
|
281
|
-
await new Promise((r) => setTimeout(r, 2000 * 2 ** attempt))
|
|
282
|
-
}
|
|
283
|
-
rmSync(scriptDir, { recursive: true, force: true })
|
|
284
|
-
if (code === 125 || /Cannot connect to the Docker daemon/i.test(out)) {
|
|
285
|
-
return { code, out, timedOut: false, infraError: `docker: ${out.slice(0, 300)} (persisted through 5 attempts)` }
|
|
286
|
-
}
|
|
287
|
-
return { code, out, timedOut: code === 124 || code === 137 }
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// ---------- execution canary ----------
|
|
291
|
-
|
|
292
|
-
/** Import name of the repo's primary package, used by the per-instance EXECUTION CANARY. The canary
|
|
293
|
-
* decides whether this substrate can grade this instance AT ALL: with the gold patch applied to the
|
|
294
|
-
* tree under test, `import <pkg>` must succeed AND resolve INTO that tree (/testbed — not the image's
|
|
295
|
-
* site-packages install, which never receives the patch). A canary failure means any grade produced
|
|
296
|
-
* here measures the harness, not the model, so the instance is marked env-unresolvable before a
|
|
297
|
-
* single model call is spent. Never shown to the model. */
|
|
298
|
-
export const IMPORT_NAME: Record<string, string> = {
|
|
299
|
-
'astropy/astropy': 'astropy',
|
|
300
|
-
'django/django': 'django',
|
|
301
|
-
'matplotlib/matplotlib': 'matplotlib',
|
|
302
|
-
'mwaskom/seaborn': 'seaborn',
|
|
303
|
-
'pallets/flask': 'flask',
|
|
304
|
-
'pydata/xarray': 'xarray',
|
|
305
|
-
'psf/requests': 'requests',
|
|
306
|
-
'pylint-dev/pylint': 'pylint',
|
|
307
|
-
'pytest-dev/pytest': 'pytest',
|
|
308
|
-
'scikit-learn/scikit-learn': 'sklearn',
|
|
309
|
-
'sphinx-doc/sphinx': 'sphinx',
|
|
310
|
-
'sympy/sympy': 'sympy',
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/** The canary script: exit 0 iff `import <pkg>` succeeds AND resolves into /testbed. */
|
|
314
|
-
export const importCanaryScript = (pkg: string): string =>
|
|
315
|
-
`import sys\nimport ${pkg}\nf = getattr(${pkg}, '__file__', '') or ''\nprint(f)\n` +
|
|
316
|
-
"sys.exit(0 if f.startswith('/testbed') else 3)\n"
|
|
317
|
-
|
|
318
|
-
// ---------- repro-authoring protocol (extracted from swe-repro-calibrate.mts, byte-identical
|
|
319
|
-
// behavior, so the stream driver authors fresh repros with the SAME calibrated protocol instead
|
|
320
|
-
// of forking one) ----------
|
|
321
|
-
|
|
322
|
-
/** The authoring system prompt, parameterized only on the jail's script timeout. */
|
|
323
|
-
export const reproAuthorSystem = (reproTimeoutS: number): string =>
|
|
324
|
-
'You are an expert Python engineer writing a REPRODUCTION script for a reported bug in an open-source repository.\n\n' +
|
|
325
|
-
'Contract for the script you produce:\n' +
|
|
326
|
-
'- A single self-contained Python file, executed as: python /repro/repro.py with cwd=/testbed, where /testbed is the ' +
|
|
327
|
-
"repository checkout. The project's own environment is active, so the repository package and its dependencies are importable.\n" +
|
|
328
|
-
'- Exit code 0 means the bug is FIXED. A nonzero exit (sys.exit(1), a failing assert, or an uncaught exception) means the ' +
|
|
329
|
-
'bug is PRESENT. The script must exercise the EXACT behavior described in the issue.\n' +
|
|
330
|
-
'- The repository tree is READ-ONLY: never modify, create, or delete files inside it. If you genuinely need a scratch ' +
|
|
331
|
-
'file, use the tempfile module (system tmp is writable).\n' +
|
|
332
|
-
`- No network access. Deterministic. Must finish well under ${reproTimeoutS} seconds.\n` +
|
|
333
|
-
"- Prefer plain Python with assert statements. Do not invoke the repository's test-suite runner and do not depend on " +
|
|
334
|
-
'pytest fixtures; importing the repository package directly is the way.\n' +
|
|
335
|
-
'- Print one short line describing what was checked before exiting.\n\n' +
|
|
336
|
-
'Be precise: the script must FAIL on the current buggy code and PASS once the underlying bug is properly fixed. Test the ' +
|
|
337
|
-
'observable behavior the issue describes, not incidental implementation details that a legitimate fix might change.'
|
|
338
|
-
|
|
339
217
|
/** All-READ-lines detector: models sometimes wrap their read requests in a python fence, which must
|
|
340
218
|
* NOT be mistaken for a script (observed live: a "script" of `READ: astropy/timeseries/core.py`
|
|
341
219
|
* reached the jail and crashed with NameError — measuring the parser, not the model). */
|
|
342
|
-
|
|
220
|
+
function asReadRequests(block: string): string[] | null {
|
|
343
221
|
const lines = block.split('\n').map((l) => l.trim()).filter(Boolean)
|
|
344
222
|
if (lines.length > 0 && lines.length <= 3 && lines.every((l) => /^READ:\s*\S+$/.test(l))) {
|
|
345
223
|
return lines.map((l) => l.replace(/^READ:\s*/, ''))
|
|
346
224
|
}
|
|
347
225
|
return null
|
|
348
226
|
}
|
|
349
|
-
|
|
350
|
-
export function extractReproScript(text: string): string | null {
|
|
351
|
-
// Collapse a doubled fence OPENER (observed live: "```python\n```python\nimport os…" — the
|
|
352
|
-
// non-greedy fence match otherwise captures the empty span between the two openers and a
|
|
353
|
-
// complete script is thrown away as authoring-failed).
|
|
354
|
-
const cleaned = text.replace(/```(?:python|py)?[ \t]*\n(?=```(?:python|py)?[ \t]*\n)/g, '')
|
|
355
|
-
const fences = [...cleaned.matchAll(/```(?:python|py)?\s*\n([\s\S]*?)```/g)]
|
|
356
|
-
const last = fences.at(-1)?.[1]?.trim()
|
|
357
|
-
if (!last || asReadRequests(last)) return null
|
|
358
|
-
return last
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
export function extractReadRequests(text: string): string[] {
|
|
362
|
-
return [...text.matchAll(/^READ:\s*(\S+)\s*$/gm)].map((m) => m[1]).slice(0, 3)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// ---------- backbone enumeration ----------
|
|
366
|
-
|
|
367
|
-
/** The cached-instance backbone: every instance whose swebench eval image is cached locally.
|
|
368
|
-
* Tag → id mapping inverts make_test_spec's `__` → `_1776_` name mangling. */
|
|
369
|
-
export async function cachedInstanceIds(): Promise<string[]> {
|
|
370
|
-
const { stdout } = await exec('docker', ['images', '--format', '{{.Repository}}'], { timeout: 30_000 })
|
|
371
|
-
const ids = new Set<string>()
|
|
372
|
-
for (const line of stdout.split('\n')) {
|
|
373
|
-
const m = /(?:^|\/)sweb\.eval\.x86_64\.(.+)$/.exec(line.trim())
|
|
374
|
-
if (m) ids.add(m[1].replace('_1776_', '__'))
|
|
375
|
-
}
|
|
376
|
-
return [...ids].sort()
|
|
377
|
-
}
|
|
@@ -2,7 +2,7 @@ import { realpathSync, statSync } from 'node:fs'
|
|
|
2
2
|
import { basename, dirname, join, resolve } from 'node:path'
|
|
3
3
|
import type { Fingerprints } from './swe-structural-provenance'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const PAIRED_FINGERPRINT_KEYS = [
|
|
6
6
|
'source',
|
|
7
7
|
'commonConfig',
|
|
8
8
|
'repro',
|
|
@@ -76,7 +76,7 @@ export function assertDistinctArtifactPaths(paths: Record<string, string>): void
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
interface CompletedJudgeScore {
|
|
80
80
|
hiddenResolved: boolean
|
|
81
81
|
judgeDetail: string | null
|
|
82
82
|
judgeSkipped: 'empty-patch' | null
|
|
@@ -114,7 +114,7 @@ export function assertJudgeCompletionMatchesInput(
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
interface JudgeResumeFingerprintReceipt {
|
|
118
118
|
pairFingerprint: string
|
|
119
119
|
phaseFileFingerprint: string
|
|
120
120
|
inputFingerprint: string
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isAbsolute } from 'node:path'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type ExperimentArm = 'independent-2' | 'persistent-refine-2'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
interface ExperimentArmPreset {
|
|
6
6
|
arm: ExperimentArm
|
|
7
7
|
k: 1 | 2
|
|
8
8
|
repairs: 0 | 1
|
|
@@ -11,7 +11,7 @@ export interface ExperimentArmPreset {
|
|
|
11
11
|
workerSessions: 2
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
interface WorkerSessionReceipt {
|
|
15
15
|
calls: number
|
|
16
16
|
completions: number
|
|
17
17
|
attemptError: string | null
|
|
@@ -14,7 +14,7 @@ export interface Fingerprints {
|
|
|
14
14
|
composite: string
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
interface FingerprintInputs {
|
|
18
18
|
source: unknown
|
|
19
19
|
config: unknown
|
|
20
20
|
commonConfig: unknown
|
|
@@ -24,7 +24,7 @@ export interface FingerprintInputs {
|
|
|
24
24
|
task: unknown
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
interface SharedExecutionReceipt {
|
|
28
28
|
runTool: {
|
|
29
29
|
timeoutS: number
|
|
30
30
|
outputLimit: number
|
|
@@ -39,7 +39,7 @@ export interface SharedExecutionReceipt {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
interface ExecutionReceipt extends SharedExecutionReceipt {
|
|
43
43
|
image: {
|
|
44
44
|
tag: string
|
|
45
45
|
namespace: 'swebench' | 'none'
|
|
@@ -60,7 +60,7 @@ function canonicalize(value: unknown): unknown {
|
|
|
60
60
|
return value
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
function canonicalJson(value: unknown): string {
|
|
64
64
|
return JSON.stringify(canonicalize(value))
|
|
65
65
|
}
|
|
66
66
|
|
package/src/terminal-compare.ts
CHANGED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
* summary of round 1's commands + terminal state + the
|
|
14
14
|
* failing tests from tb's own run dir, then
|
|
15
15
|
* `tb run --agent-import-path
|
|
16
|
-
* tb_agents.
|
|
17
|
-
* --agent-kwarg
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* tb_agents.opencode_router_agent:OpenCodeRouterAgent
|
|
17
|
+
* --agent-kwarg prior_attempt_hex=h<hex>`. The router agent
|
|
18
|
+
* adds refine instructions only when prior evidence exists.
|
|
19
|
+
* Round 1 uses the same exact profile without prior evidence;
|
|
20
|
+
* router configuration and metering stay active in every round.
|
|
21
21
|
* Stop early once resolved.
|
|
22
22
|
*
|
|
23
23
|
* Reports blind (resolved_1) vs refine (resolved_final) + rescued/broke counts,
|
|
@@ -33,7 +33,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
33
33
|
import { homedir } from 'node:os'
|
|
34
34
|
import { agentProfileSchema } from '@tangle-network/agent-interface'
|
|
35
35
|
|
|
36
|
-
import { appendRunRecord, type AttemptRecord, type
|
|
36
|
+
import { appendRunRecord, type AttemptRecord, type BenchRunRecord } from './corpus'
|
|
37
37
|
import { runPool } from './run-pool'
|
|
38
38
|
|
|
39
39
|
const BENCH_ROOT = fileURLToPath(new URL('..', import.meta.url))
|
|
@@ -43,7 +43,7 @@ const PROFILE_AGENT_IMPORT = 'tb_agents.opencode_router_agent:OpenCodeRouterAgen
|
|
|
43
43
|
// The durable learning-flywheel corpus (docs/learning-flywheel.md). terminal-bench
|
|
44
44
|
// is bench-orchestrated (tb owns the containers) so it cannot use buildRunRecord,
|
|
45
45
|
// which consumes runAgentRounds Iterations; instead each task's per-round tb artifacts are
|
|
46
|
-
// folded into one
|
|
46
|
+
// folded into one BenchRunRecord here so the corpus is genuinely cross-benchmark
|
|
47
47
|
// (finsearch-loop.ts writes the same store from the runAgentRounds path).
|
|
48
48
|
const CORPUS = process.env.CORPUS ?? join(BENCH_ROOT, 'corpus', 'terminal.jsonl')
|
|
49
49
|
|
|
@@ -327,7 +327,7 @@ function informativeFailureMode(mode: string | undefined): string | undefined {
|
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
/**
|
|
330
|
-
* Build and persist one flywheel
|
|
330
|
+
* Build and persist one flywheel BenchRunRecord per task from terminal-compare's own
|
|
331
331
|
* round data — no buildRunRecord (that consumes runAgentRounds Iterations; tb is not
|
|
332
332
|
* runAgentRounds-shaped). condition = 'refine@k' when a refine budget was available,
|
|
333
333
|
* 'blind' when only the single blind round can run (ROUNDS===1). Appended once
|
|
@@ -346,7 +346,7 @@ async function captureRunRecord(
|
|
|
346
346
|
}
|
|
347
347
|
const blindResolved = rounds[0]?.resolved === true
|
|
348
348
|
const last = rounds[rounds.length - 1]
|
|
349
|
-
const record:
|
|
349
|
+
const record: BenchRunRecord = {
|
|
350
350
|
ts: new Date().toISOString(),
|
|
351
351
|
benchmark: 'terminal-bench',
|
|
352
352
|
instanceId: taskId,
|
|
@@ -465,7 +465,7 @@ async function solveTask(taskId: string): Promise<{
|
|
|
465
465
|
await captureRunRecord(taskId, history, priorSteers)
|
|
466
466
|
} catch (err) {
|
|
467
467
|
const msg = err instanceof Error ? (err.stack ?? err.message) : String(err)
|
|
468
|
-
console.error(` [corpus] WARN: failed to persist
|
|
468
|
+
console.error(` [corpus] WARN: failed to persist BenchRunRecord for ${taskId}: ${msg}`)
|
|
469
469
|
}
|
|
470
470
|
return { taskId, blind, refine, rounds: history }
|
|
471
471
|
}
|