JuliusBrussee/caveman · error · Error
caveman agent: eval needs at least one quality grader
Error message
caveman agent: eval needs at least one quality grader
What it means
evalFixture() requires at least one quality grader and throws when the quality array is empty. Every eval must define how output quality is measured; without a grader the eval cannot produce a pass/fail verdict, so the library rejects it at definition time.
Solutions
- Include at least one grader, e.g. quality: [{ type: "contains", value: "expected" }] or exact_match/json_schema/tool_called.
- After building the quality array dynamically, assert quality.length > 0 before calling evalFixture.
- Provide a default grader (e.g. contains) when no specific one is configured.
Example fix
// before
evalFixture({ id: "e1", input: "q", quality: [] });
// after
evalFixture({ id: "e1", input: "q", quality: [{ type: "contains", value: "answer" }] }); Defensive patterns
Strategy: validation
Validate before calling
function hasGraders(q) { return Array.isArray(q) && q.length > 0; }
if (!hasGraders(fixture.quality)) throw new Error("eval fixture needs at least one quality grader"); Type guard
function hasQuality(o: { quality?: unknown[] }): o is { quality: [unknown, ...unknown[]] } { return Array.isArray(o.quality) && o.quality.length > 0; } Try / catch
let ev;
try { ev = evalFixture(opts); }
catch (e) { if (String(e.message).includes("quality grader")) ev = evalFixture({ ...opts, quality: [{ type: "contains", value: defaultExpectation }] }); else throw e; } Prevention
- Assert quality.length > 0 after building graders dynamically.
- Always give each eval fixture at least one default grader in config templates.
- Check that filters over grader lists haven't emptied the array.
When it happens
Trigger: evalFixture({ id, input, quality: [] }) or passing a quality value that defaults to an empty array; constructing quality dynamically by filtering graders that all get filtered out.
Common situations: Building quality arrays conditionally so the filter removed everything; copying a fixture template and forgetting to fill in graders; JSON config with quality: [].
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- caveman agent: error-rate guardrail max must be in [0,1]
- caveman agent: eval id is required
- caveman agent: latency guardrail requires positive integer…
- caveman agent: live eval tools require an explicit sandbox
- caveman agent: unknown grader
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/8d8de547520595b8.
Report an issue: GitHub.
Appendix: source
Thrown at packages/agent/src/primitives.ts:444
readonly approved: boolean;
readonly required: boolean;
readonly input: unknown;
readonly tools: { mode: "fixture" | "live"; sandbox?: string };
readonly quality: readonly QualityGrader[];
readonly guardrails: readonly EvalGuardrail[];
}
export function evalFixture(options: {
id: string;
approved?: boolean;
required?: boolean;
input: unknown;
tools?: { mode: "fixture" | "live"; sandbox?: string };
quality: QualityGrader[];
guardrails?: EvalGuardrail[];
}): EvalDefinition {
if (options.id.trim() === "") throw new Error("caveman agent: eval id is required");
if (options.quality.length === 0) throw new Error("caveman agent: eval needs at least one quality grader");
const known = new Set(["contains", "tool_called", "exact_match", "json_schema"]);
for (const grader of options.quality) {
if (!known.has(grader.type)) {
throw new Error(`caveman agent: unknown grader ${(grader as { type: string }).type}`);
}
}
for (const guardrail of options.guardrails ?? []) {
if (guardrail.type === "latency_threshold" &&
(!Number.isSafeInteger(guardrail.p95_ms) || guardrail.p95_ms <= 0)) {
throw new Error("caveman agent: latency guardrail requires positive integer p95_ms");
}
if (guardrail.type === "error_rate" &&
(!Number.isFinite(guardrail.max) || guardrail.max < 0 || guardrail.max > 1)) {
throw new Error("caveman agent: error-rate guardrail max must be in [0,1]");
}
}
const tools = options.tools ?? { mode: "fixture" as const };
if (tools.mode === "live" && !tools.sandbox) {View on GitHub (pinned to 3ee70a1026)