{"record":{"id":"a0d463e14c426e12","repo":"linshenkx/prompt-optimizer","slug":"evaluation-result-is-missing-a-valid-overall-score","errorCode":null,"errorMessage":"Evaluation result is missing a valid overall score.","messagePattern":"Evaluation result is missing a valid overall score\\.","errorType":"exception","errorClass":"EvaluationParseError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":3232,"sourceCode":"        }\n      }\n    }\n\n    // 如果 overall 缺失，但维度存在，则按平均分计算。\n    if (overall === null && dimensions.length > 0) {\n      const avg = Math.round(\n        dimensions.reduce((sum, d) => sum + d.score, 0) / dimensions.length\n      );\n      overall = Math.max(0, Math.min(100, avg));\n    }\n\n    // 如果维度缺失，但 overall 存在，则返回一个最小维度数组。\n    if (dimensions.length === 0 && overall !== null) {\n      dimensions = [{ key: 'overall', label: '综合评分', score: overall }];\n    }\n\n    if (overall === null) {\n      throw new EvaluationParseError('Evaluation result is missing a valid overall score.');\n    }\n\n    const score: EvaluationScore = {\n      overall,\n      dimensions,\n    };\n\n    // 解析 improvements（最多3条）\n    const improvements = Array.isArray(data.improvements)\n      ? data.improvements.map((x: any) => String(x)).filter(Boolean).slice(0, 3)\n      : typeof data.improvements === 'string' && data.improvements.trim()\n        ? [data.improvements.trim()].slice(0, 3)\n        : [];\n\n    // 解析 patchPlan（最多3条）\n    const patchPlan = this.normalizePatchPlan(data.patchPlan || []).slice(0, 3);\n\n    const summary = typeof data.summary === 'string' ? data.summary : '';","sourceCodeStart":3214,"sourceCodeEnd":3250,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L3214-L3250","documentation":"Thrown by EvaluationService when parsing an evaluation result yields no valid overall score (overall is null). The service can synthesize a minimal dimensions array from overall, but if overall itself is missing it cannot construct an EvaluationScore and aborts with EvaluationParseError.","triggerScenarios":"Calling EvaluationService's parse/evaluation API with a model response or JSON payload that contains no parseable overall score field (or a non-numeric one), e.g. an LLM returning only per-dimension scores or malformed JSON.","commonSituations":"LLM output format drift after a prompt/model change; evaluation prompt not instructing the model to emit an overall score; locale-specific number formats that fail numeric parsing; truncated responses.","solutions":["Inspect the raw evaluation payload and confirm the overall score field name/format expected by the parser","Update the evaluation prompt to explicitly require a numeric overall score in the response schema","Add pre-validation of the model response before passing it to EvaluationService","If dimensions exist but overall is absent, compute overall yourself and pass it in"],"exampleFix":"// before\nconst result = await evaluationService.evaluate(rawModelOutput);\n// after\nconst parsed = JSON.parse(rawModelOutput);\nif (typeof parsed.overall !== 'number') throw new Error('model output lacks overall');\nconst result = await evaluationService.evaluate(rawModelOutput);","handlingStrategy":"validation","validationCode":"function hasOverall(raw: unknown): boolean {\n  const o = typeof raw === 'string' ? JSON.parse(raw) : raw;\n  return o != null && typeof (o as any).overall === 'number' && Number.isFinite((o as any).overall);\n}","typeGuard":"const isEvalPayload = (p: unknown): p is { overall: number } =>\n  typeof p === 'object' && p !== null && typeof (p as any).overall === 'number';","tryCatchPattern":"try { await svc.evaluate(raw); } catch (e) { if (e instanceof EvaluationParseError) { /* re-prompt model or fallback */ } throw e; }","preventionTips":["Validate model output contains a numeric overall before evaluation","Pin the evaluation prompt schema and add output-format examples","Add regression tests for malformed model responses"],"tags":["evaluation","parsing","llm-output","validation"],"backgroundTag":"llm-response-parse-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}