import type { MastraModelConfig } from '@mastra/core/llm'; import type { ScorerRunInputForLLMJudge, ScorerRunOutputForLLMJudge } from '../../utils.js'; /** * A single rubric criterion the agent's output is graded against. */ export interface RubricCriterion { /** Optional stable identifier for the criterion. */ id?: string; /** What the output must satisfy, e.g. "All tests pass" or "Includes a recommendations section". */ description: string; /** * Whether this criterion must be satisfied for the task to be considered complete. * Defaults to `true`. Optional criteria are graded and reported but do not gate completion. */ required?: boolean; } /** * Rubric input accepted by the scorer factory and by the dynamic `rubric` context value. * A string is treated as a newline-delimited checklist; leading list markers ("-", "*", "1.") * are stripped. Every parsed line becomes a required criterion. */ export type RubricInput = RubricCriterion[] | string; export interface RubricScorerOptions { /** Scale applied to the final score. Defaults to 1. Only relevant for standalone evals — `isTaskComplete` gates on `=== 1`. */ scale?: number; } /** * Creates an LLM-as-judge scorer that grades an agent's output against a rubric and returns a * **binary** score: `1` only when every required criterion is satisfied, otherwise `0`. The * `generateReason` output lists each unmet criterion with the judge's reasoning. * * It is designed to drop into `isTaskComplete`, which treats `score === 1` as "task complete" and * injects the reason back into the conversation as feedback, so the agent iterates until the rubric * is satisfied (or `maxSteps` is reached): * * @example * ```typescript * import { createRubricScorer } from '@mastra/evals/scorers/prebuilt'; * * const rubricScorer = createRubricScorer({ * model: '__GATEWAY_OPENAI_MODEL_MINI__', * criteria: [ * { description: 'The response includes an analysis section' }, * { description: 'The response includes concrete recommendations' }, * ], * }); * * await supervisor.stream('Research AI in education', { * maxSteps: 10, * isTaskComplete: { scorers: [rubricScorer], strategy: 'all' }, * }); * ``` * * The rubric can also be supplied dynamically per run via request/additional context under the * `rubric` key (string checklist or `RubricCriterion[]`). If no rubric resolves, the scorer is a * no-op and returns `1` (so it does not gate the loop), mirroring "if the rubric is absent, do nothing". */ export declare function createRubricScorer({ model, criteria, options, }: { model: MastraModelConfig; criteria?: RubricInput; options?: RubricScorerOptions; }): import("@mastra/core/evals").MastraScorer & Record<"generateScoreStepResult", number> & Record<"generateReasonStepResult", string>>; //# sourceMappingURL=index.d.ts.map