{"record":{"id":"8d8de547520595b8","repo":"JuliusBrussee/caveman","slug":"caveman-agent-eval-needs-at-least-one-quality-gra","errorCode":null,"errorMessage":"caveman agent: eval needs at least one quality grader","messagePattern":"caveman agent: eval needs at least one quality grader","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/agent/src/primitives.ts","lineNumber":444,"sourceCode":"  readonly approved: boolean;\n  readonly required: boolean;\n  readonly input: unknown;\n  readonly tools: { mode: \"fixture\" | \"live\"; sandbox?: string };\n  readonly quality: readonly QualityGrader[];\n  readonly guardrails: readonly EvalGuardrail[];\n}\n\nexport function evalFixture(options: {\n  id: string;\n  approved?: boolean;\n  required?: boolean;\n  input: unknown;\n  tools?: { mode: \"fixture\" | \"live\"; sandbox?: string };\n  quality: QualityGrader[];\n  guardrails?: EvalGuardrail[];\n}): EvalDefinition {\n  if (options.id.trim() === \"\") throw new Error(\"caveman agent: eval id is required\");\n  if (options.quality.length === 0) throw new Error(\"caveman agent: eval needs at least one quality grader\");\n  const known = new Set([\"contains\", \"tool_called\", \"exact_match\", \"json_schema\"]);\n  for (const grader of options.quality) {\n    if (!known.has(grader.type)) {\n      throw new Error(`caveman agent: unknown grader ${(grader as { type: string }).type}`);\n    }\n  }\n  for (const guardrail of options.guardrails ?? []) {\n    if (guardrail.type === \"latency_threshold\" &&\n        (!Number.isSafeInteger(guardrail.p95_ms) || guardrail.p95_ms <= 0)) {\n      throw new Error(\"caveman agent: latency guardrail requires positive integer p95_ms\");\n    }\n    if (guardrail.type === \"error_rate\" &&\n        (!Number.isFinite(guardrail.max) || guardrail.max < 0 || guardrail.max > 1)) {\n      throw new Error(\"caveman agent: error-rate guardrail max must be in [0,1]\");\n    }\n  }\n  const tools = options.tools ?? { mode: \"fixture\" as const };\n  if (tools.mode === \"live\" && !tools.sandbox) {","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/primitives.ts#L426-L462","documentation":"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.","triggerScenarios":"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.","commonSituations":"Building quality arrays conditionally so the filter removed everything; copying a fixture template and forgetting to fill in graders; JSON config with quality: [].","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."],"exampleFix":"// before\nevalFixture({ id: \"e1\", input: \"q\", quality: [] });\n// after\nevalFixture({ id: \"e1\", input: \"q\", quality: [{ type: \"contains\", value: \"answer\" }] });","handlingStrategy":"validation","validationCode":"function hasGraders(q) { return Array.isArray(q) && q.length > 0; }\nif (!hasGraders(fixture.quality)) throw new Error(\"eval fixture needs at least one quality grader\");","typeGuard":"function hasQuality(o: { quality?: unknown[] }): o is { quality: [unknown, ...unknown[]] } { return Array.isArray(o.quality) && o.quality.length > 0; }","tryCatchPattern":"let ev;\ntry { ev = evalFixture(opts); }\ncatch (e) { if (String(e.message).includes(\"quality grader\")) ev = evalFixture({ ...opts, quality: [{ type: \"contains\", value: defaultExpectation }] }); else throw e; }","preventionTips":["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."],"tags":["validation","eval","quality-grader","empty-array"],"backgroundTag":"empty-required-field","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}