/** * Metric-threshold graders — check trajectory metrics against configurable limits. * * These graders wrap the metrics already computed by {@link computeMetrics} * (token usage, tool calls, turns, errors, wall time) — plus `step-count`, * which counts agent steps directly from the event stream — and expose them as * first-class graders with a `max` threshold in eval.yaml: * * ```yaml * graders: * - type: token-budget * config: { max: 50000 } * - type: tool-call-count * config: { max: 20 } * - type: step-count * config: { max: 40 } * - type: wall-time * config: { max: "2m" } * ``` * * `max` is required — these graders always enforce a budget. * `wall-time` accepts duration strings (`"30s"`, `"2m"`); the others accept numbers. * * All are deterministic and language-agnostic. Five are free — they read values * the pipeline has already computed. `step-count` is free but scans the event * stream (and applies regex matching when `tools` is set) rather than reading * a precomputed metric. */ import type { Grader, GraderInput, GraderMetadata, GraderResult } from "../types.js"; /** * Configuration for metric-threshold graders. * * @example * ```yaml * graders: * - type: token-budget * config: { max: 50000 } * - type: wall-time * config: { max: "2m" } * ``` */ export interface MetricThresholdConfig { /** * Upper bound for the metric. The trajectory fails if the metric exceeds this value. * * For most graders this is a number (e.g. token count, tool calls). * For `wall-time` this is a duration string (e.g. `"30s"`, `"2m"`, `"1h"`). * * Required — omitting `max` is a validation error. */ max?: number | string; } /** Shared config for metric graders that accept a `tools` regex filter. */ export interface ToolFilteredMetricThresholdConfig extends MetricThresholdConfig { /** * Regex patterns selecting entries to count. `step-count` also matches * `response` and system event names. */ tools?: string[]; } /** @deprecated Use {@link ToolFilteredMetricThresholdConfig}. */ export type ToolCallCountConfig = ToolFilteredMetricThresholdConfig; interface MetricDef { /** Grader type string used in eval.yaml. */ name: string; /** Human-readable description. */ description: string; /** Extract the metric value from a trajectory. */ extract: (input: GraderInput) => number; /** Unit label for evidence strings. */ unit: string; /** Whether `max` requires a duration string (e.g. "30s", "2m") instead of a number. */ acceptsDuration?: boolean; /** Whether this metric can be restricted to selected tool names. */ acceptsTools?: boolean; /** * Noun describing what a `tools` pattern matches, for config-error messages * (e.g. "an empty regex matches every ${noun}"). Defaults to `"tool"`. */ watchNoun?: string; /** * Count the metric directly from events when a tool filter is configured. * Metrics without it fall back to `metrics.toolCallBreakdown`. */ extractFiltered?: (input: GraderInput, watch: (name: string) => boolean) => number; } export declare class MetricThresholdGrader implements Grader { metadata: GraderMetadata; private def; constructor(def: MetricDef); /** `token-budget max 5000` — the threshold is the only varying config. */ defaultName(config: Record): string; grade(input: GraderInput): Promise; /** Resolve the metric value, optionally counting only selected tool calls. */ private resolveMetricValue; /** Parse and validate the `max` config value. */ private resolveMax; } /** Create all metric-threshold grader instances. */ export declare function createMetricThresholdGraders(): Grader[]; export {}; //# sourceMappingURL=metric-threshold-grader.d.ts.map