{"record":{"id":"f915d6436b8eed25","repo":"linshenkx/prompt-optimizer","slug":"evaluation-result-is-missing-the-score-field","errorCode":null,"errorMessage":"Evaluation result is missing the \"score\" field.","messagePattern":"Evaluation result is missing the \"score\" field\\.","errorType":"exception","errorClass":"EvaluationParseError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":3117,"sourceCode":"    }\n\n    return null;\n  }\n\n  /**\n   * 标准化评估响应（统一结构）\n   */\n  private normalizeEvaluationResponse(\n    data: any,\n    type: EvaluationType,\n    metadata?: EvaluationResponse['metadata']\n  ): EvaluationResponse {\n    if (!data || typeof data !== 'object') {\n      throw new EvaluationParseError('Evaluation result is not a valid object.');\n    }\n\n    if (data.score === undefined || data.score === null) {\n      throw new EvaluationParseError('Evaluation result is missing the \"score\" field.');\n    }\n\n    // 提取分数（0-100，整数）\n    const extractScore = (value: any, fieldName: string): number => {\n      if (value === undefined || value === null) {\n        throw new EvaluationParseError(`Evaluation result is missing score for \"${fieldName}\".`);\n      }\n      const num = typeof value === 'number' ? value : parseInt(String(value));\n      if (isNaN(num)) {\n        throw new EvaluationParseError(`Invalid numeric score for \"${fieldName}\": ${value}`);\n      }\n      return Math.max(0, Math.min(100, num));\n    };\n\n    const tryExtractScore = (value: any, fieldName: string): number | null => {\n      try {\n        return extractScore(value, fieldName);\n      } catch {","sourceCodeStart":3099,"sourceCodeEnd":3135,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L3099-L3135","documentation":"EvaluationParseError thrown when the evaluation result object exists but has no score field (score is undefined or null). score is the mandatory top-level field the normalizer reads; without it the evaluation cannot be quantified. Distinguish from error 56 (not an object) and 58 (nested dimension score missing).","triggerScenarios":"Judge model returns valid JSON like {\"reasoning\": \"...\"} or {\"overall\": 90} without the exact key 'score'; or score is explicitly null.","commonSituations":"Key naming drift between prompt template and parser (overall vs score, rating vs score); model omitting the field; older prompts predating the score-based schema.","solutions":["Fix the judge prompt to output the literal key \"score\"","Check for near-miss keys (overall/rating) in the raw payload and confirm the parser contract","Retry with temperature 0 and an explicit output schema example in the prompt"],"exampleFix":"// prompt instruction (before)\nReturn your assessment as JSON with an overall grade.\n\n// after\nReturn JSON exactly like: { \"score\": <0-100>, \"reasoning\": \"...\" }","handlingStrategy":"validation","validationCode":"if (!('score' in parsed) || parsed.score == null) { parsed.score = parsed.overall ?? parsed.rating; } // pre-map common aliases","typeGuard":"const hasScore = (v: unknown): v is { score: number | string } => { const s = (v as any)?.score; return s !== undefined && s !== null; };","tryCatchPattern":null,"preventionTips":["Pin the exact key 'score' in the judge prompt with a JSON example","Version prompts together with the parser contract"],"tags":["evaluation","parsing","score"],"backgroundTag":"llm-output-parse-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}