Skip to content

Measurement ​

declareMeasurement ​

File: parameters/tasks/<task>/measurements/<name>.ts

What is measured after each run. Its instrument runs once per run, and what it returns, the measure, is stored as it is. Each of its metrics reads a score from the measure whenever results are read, so a metric can be added, changed or removed without measuring again.

ts
export default declareMeasurement({
  instrument: "bunTestFile",
  config: { subject: "**/isPrime.ts", test: "./isPrime.test.ts" },
  metrics: {
    // bunTestFile's default score is the pass rate: passed / total, or undefined when total is 0.
    passRate: { stat: "mean", better: "higher" },
    // Anything else reads the stored { passed, total } with a score.
    passed: { score: (v) => v.passed, stat: "mean", better: "higher" },
  },
});

instrument ​

Type: "fileCreated" | "grep" | "bunTestFile" | "replyMatches" | "shell" | "commits" | "filesChanged" | "jsAst"

What to measure. Each instrument takes its own config, and returns its own value, the measure:

InstrumentconfigValueDefault score
fileCreated{ glob }boolean: whether the agent left a matching filethe value
grep{ glob, pattern }number: lines across the matching files that match patternthe value
bunTestFile{ subject, test }{ passed, total }: tests passed, of all the teststhe pass rate, passed / total
replyMatches{ pattern, turn? }boolean: whether the agent's reply matches patternthe value
shell{ command }{ exitCode, stdout, stdoutTruncated }whether command exits 0
filesChanged{ glob? }FileChanges: { added, modified, deleted } paths changed since the startnone: give each metric a score
commits{}Commit[], oldest first: { sha, message, files: { added, modified, deleted } }none: give each metric a score
jsAst{ glob, selectors }{ file, matches, parseError? }[]: for each matching JS or TS file, how many nodes each esquery selector matchesnone: give each metric a score

shell stores command's stdout as it is, up to 64 KiB, in the run data store. A command that prints secrets or other sensitive data will persist them: nothing transforms its output before it's stored.

metrics ​

Type: Record<string, { score?: (value) => number | boolean | undefined; stat: Stat; better?: "higher" | "lower" }>

Required, with at least one entry. What to read from each run's value, keyed by the metric's name, which must be an identifier. Each metric has:

  • score: reads one run's value as a number or a boolean, or undefined when the metric doesn't apply to that run. Never return 0 or false to mean that. Leave it out to use the instrument's default score.
  • stat: the one statistic across a permutation's iterations. Booleans: rate, count. Numbers: mean, median, min, max, sum.
  • better: "higher" or "lower", if either is better. Left out, neither is.