@tangle-network/agent-bench 4.0.0 → 4.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 +14 -0
- package/dist/cli.js +44 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/pier-trial-supervisor.mjs +352 -0
- package/package.json +3 -3
- package/scripts/verify-packed-consumer.mjs +1 -0
- package/scripts/verify-pier-agent.mts +34 -100
- package/src/pier-agent.ts +19 -1
- package/src/published.test.mts +29 -6
- package/src/published.ts +53 -8
package/src/published.ts
CHANGED
|
@@ -103,6 +103,18 @@ export interface PublishedTaskScore {
|
|
|
103
103
|
score: number
|
|
104
104
|
notes?: string
|
|
105
105
|
raw?: Record<string, number>
|
|
106
|
+
/** Observed provider counters retained by the publisher. A subtotal keeps tokensKnown false. */
|
|
107
|
+
tokenUsage?: RunRecord['tokenUsage']
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function nonnegativeCounter(value: unknown): number | undefined {
|
|
111
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0
|
|
112
|
+
? value
|
|
113
|
+
: undefined
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function nonnegativeMeasurement(value: unknown): number | undefined {
|
|
117
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined
|
|
106
118
|
}
|
|
107
119
|
|
|
108
120
|
export interface PublishedBenchmark {
|
|
@@ -178,13 +190,32 @@ export const PUBLISHED_BENCHMARKS: Readonly<Record<string, PublishedBenchmark>>
|
|
|
178
190
|
...(options.args ?? []),
|
|
179
191
|
],
|
|
180
192
|
parse: async (resultPath) => {
|
|
181
|
-
const tasks = (JSON.parse(await readFile(resultPath, 'utf8')) as { tasks?: Array<
|
|
193
|
+
const tasks = (JSON.parse(await readFile(resultPath, 'utf8')) as { tasks?: Array<Record<string, unknown>> }).tasks
|
|
182
194
|
if (!Array.isArray(tasks)) throw new Error('AutomationBench result has no tasks array')
|
|
183
195
|
return tasks.map((task) => {
|
|
184
196
|
if (typeof task.name !== 'string' || typeof task.score !== 'number' || typeof task.passed !== 'boolean') {
|
|
185
197
|
throw new Error(`AutomationBench task result is malformed: ${JSON.stringify(task).slice(0, 200)}`)
|
|
186
198
|
}
|
|
187
|
-
|
|
199
|
+
// This export can fall back to counting text characters. Its pricing is also calculated by
|
|
200
|
+
// the publisher. Keep these fields with the score without attesting provider usage or billing.
|
|
201
|
+
const raw: Record<string, number> = {}
|
|
202
|
+
const counters = {
|
|
203
|
+
publisherInputTokens: task.input_tokens,
|
|
204
|
+
publisherOutputTokens: task.output_tokens,
|
|
205
|
+
publisherCachedInputTokens: task.cached_input_tokens,
|
|
206
|
+
publisherReasoningTokens: task.reasoning_tokens,
|
|
207
|
+
publisherModelCalls: task.num_model_calls,
|
|
208
|
+
}
|
|
209
|
+
for (const [key, counter] of Object.entries(counters)) {
|
|
210
|
+
const value = nonnegativeCounter(counter)
|
|
211
|
+
if (value !== undefined) raw[key] = value
|
|
212
|
+
}
|
|
213
|
+
const estimate = nonnegativeMeasurement(task.cost)
|
|
214
|
+
if (estimate !== undefined) raw.publisherEstimatedCostUsd = estimate
|
|
215
|
+
return {
|
|
216
|
+
id: task.name, passed: task.passed, score: task.score,
|
|
217
|
+
...(Object.keys(raw).length && { raw }),
|
|
218
|
+
}
|
|
188
219
|
})
|
|
189
220
|
},
|
|
190
221
|
},
|
|
@@ -254,17 +285,30 @@ export const PUBLISHED_BENCHMARKS: Readonly<Record<string, PublishedBenchmark>>
|
|
|
254
285
|
const runs = (await readFile(path.join(resultPath, 'tasks.tsv'), 'utf8')).trim().split('\n').map((line) => line.split('\t') as [string, string])
|
|
255
286
|
return Promise.all(runs.map(async ([run, task]) => {
|
|
256
287
|
const read = (file: string) => readFile(path.join(resultPath, run, file), 'utf8').then((text) => JSON.parse(text) as Record<string, unknown>, () => null)
|
|
288
|
+
const metrics = await read('metrics.json')
|
|
289
|
+
const input = nonnegativeCounter(metrics?.input_tokens)
|
|
290
|
+
const output = nonnegativeCounter(metrics?.output_tokens)
|
|
291
|
+
const agentSeconds = nonnegativeMeasurement(metrics?.wall_clock_seconds)
|
|
292
|
+
const raw = agentSeconds === undefined ? undefined : { publisherAgentWallMs: agentSeconds * 1_000 }
|
|
293
|
+
// The publisher retains supported response counters, without a per-call completeness flag.
|
|
294
|
+
const telemetry: Pick<PublishedTaskScore, 'tokenUsage' | 'raw'> = {
|
|
295
|
+
...(raw && { raw }),
|
|
296
|
+
...(input !== undefined && output !== undefined && {
|
|
297
|
+
tokenUsage: { input, output, tokensKnown: false },
|
|
298
|
+
}),
|
|
299
|
+
}
|
|
257
300
|
const dual = await read('scores_dual.json')
|
|
258
|
-
if (dual) return { id: task, passed: dual.all_pass === true, score: Number(dual.dual_all_pass_rate), notes: `dual-judge criterion pass ${String(dual.dual_criterion_pass)}
|
|
301
|
+
if (dual) return { id: task, passed: dual.all_pass === true, score: Number(dual.dual_all_pass_rate), notes: `dual-judge criterion pass ${String(dual.dual_criterion_pass)}`, ...telemetry }
|
|
259
302
|
const single = await read('scores.json')
|
|
260
303
|
if (single) {
|
|
261
304
|
const criteria = Array.isArray(single.criteria_results) ? single.criteria_results as Array<{ id?: unknown; verdict?: unknown }> : []
|
|
262
305
|
return { id: task, passed: single.all_pass === true, score: single.all_pass === true ? 1 : 0,
|
|
263
306
|
notes: `${String(single.n_passed)} of ${String(single.n_criteria)} criteria passed${single.n_grading_errors ? `; ${String(single.n_grading_errors)} grading errors` : ''}`,
|
|
264
|
-
|
|
307
|
+
...telemetry,
|
|
308
|
+
raw: { ...raw, criteria_passed: Number(single.n_passed) || 0, criteria_total: Number(single.n_criteria) || 0,
|
|
265
309
|
...Object.fromEntries(criteria.filter((c) => typeof c.id === 'string').map((c) => [`crit.${String(c.id)}`, c.verdict === 'pass' ? 1 : 0])) } }
|
|
266
310
|
}
|
|
267
|
-
return { id: task, passed: false, score: 0, notes: 'no scores: the harness or the grader failed (see the runner log)' }
|
|
311
|
+
return { id: task, passed: false, score: 0, notes: 'no scores: the harness or the grader failed (see the runner log)', ...telemetry }
|
|
268
312
|
}))
|
|
269
313
|
},
|
|
270
314
|
},
|
|
@@ -467,8 +511,8 @@ export async function runPublished(name: string, target: string, options: Publis
|
|
|
467
511
|
}
|
|
468
512
|
|
|
469
513
|
/**
|
|
470
|
-
* One agent-eval RunRecord per task, validated by agent-eval's own validator.
|
|
471
|
-
*
|
|
514
|
+
* One agent-eval RunRecord per task, validated by agent-eval's own validator. Preserve an observed publisher subtotal
|
|
515
|
+
* and leave missing provider bills unknown. A RunRecord's model must name a served snapshot; a subscription harness
|
|
472
516
|
* reports none, and a snapshot invented from the date would be false, so such rows record `unknown` with terminal outcome
|
|
473
517
|
* `unknown` and keep the requested model in `candidateId`. A pinned model id (a Router snapshot) is recorded as served.
|
|
474
518
|
*/
|
|
@@ -483,7 +527,8 @@ function runRecords(run: PublishedRun, options: PublishedRunOptions): RunRecord[
|
|
|
483
527
|
// The publisher owns the prompt; an app run's prompt is its profile.
|
|
484
528
|
promptHash: run.app?.profileDigest ?? sha(run.target), configHash, commitSha: run.ref,
|
|
485
529
|
wallMs: Math.max(0, Date.parse(run.finishedAt) - Date.parse(run.startedAt)),
|
|
486
|
-
costUsd: null, costProvenance: { kind: 'uncaptured', usd: null },
|
|
530
|
+
costUsd: null, costProvenance: { kind: 'uncaptured', usd: null },
|
|
531
|
+
tokenUsage: task.tokenUsage ?? { input: 0, output: 0, tokensKnown: false },
|
|
487
532
|
terminalOutcome: 'succeeded',
|
|
488
533
|
outcome: { [split === 'holdout' ? 'holdoutScore' : 'searchScore']: task.score, raw: { passed: task.passed ? 1 : 0, ...task.raw } },
|
|
489
534
|
splitTag: split, scenarioId: `${run.benchmark}:${task.id}`,
|