linshenkx/prompt-optimizer · error · EvaluationParseError
Evaluation result is missing score for "${fieldName}".
Error message
Evaluation result is missing score for "${fieldName}". What it means
EvaluationParseError thrown by the inner extractScore helper when a specific dimension/sub-score (fieldName) inside the evaluation result is undefined or null. It fires while extracting individual criterion scores, naming the offending field in the message. The top-level score check has already passed by this point.
Source
Thrown at packages/core/src/services/evaluation/service.ts:3123
* 标准化评估响应(统一结构)
*/
private normalizeEvaluationResponse(
data: any,
type: EvaluationType,
metadata?: EvaluationResponse['metadata']
): EvaluationResponse {
if (!data || typeof data !== 'object') {
throw new EvaluationParseError('Evaluation result is not a valid object.');
}
if (data.score === undefined || data.score === null) {
throw new EvaluationParseError('Evaluation result is missing the "score" field.');
}
// 提取分数(0-100,整数)
const extractScore = (value: any, fieldName: string): number => {
if (value === undefined || value === null) {
throw new EvaluationParseError(`Evaluation result is missing score for "${fieldName}".`);
}
const num = typeof value === 'number' ? value : parseInt(String(value));
if (isNaN(num)) {
throw new EvaluationParseError(`Invalid numeric score for "${fieldName}": ${value}`);
}
return Math.max(0, Math.min(100, num));
};
const tryExtractScore = (value: any, fieldName: string): number | null => {
try {
return extractScore(value, fieldName);
} catch {
return null;
}
};
const toDimension = (key: string, label: string, scoreValue: any): EvaluationDimension | null => {
const score = tryExtractScore(scoreValue, `dimension.${key}`);View on GitHub (pinned to 3e677b1d9f)
Solutions
- Inspect the message for the missing fieldName and check the raw model output for that key
- Require every dimension in the judge prompt explicitly ('you MUST provide a numeric score for each of: ...')
- Increase max_tokens so trailing dimensions aren't truncated
Defensive patterns
Strategy: retry
Validate before calling
const dims = ['accuracy','relevance','clarity']; // assert before/at prompt time const missing = dims.filter(d => parsed?.dimensions?.[d] == null);
Type guard
const hasAllDimensionScores = (v: any, dims: string[]): boolean => dims.every(d => v?.dimensions?.[d] != null);
Try / catch
try { ... } catch (e) { if (e instanceof EvaluationParseError && /missing score for/.test(e.message)) { /* re-prompt with mandatory dimensions, retry */ } else throw e; } Prevention
- Explicitly list every required dimension in the judge prompt with 'MUST provide numeric score'
- Raise max_tokens to avoid truncated trailing dimensions
When it happens
Trigger: A multi-dimension evaluation result where one dimension (e.g. accuracy, relevance) is absent or null in the JSON, e.g. {"score": 80, "dimensions": {"accuracy": null }}.
Common situations: Judge model skipping dimensions it deems not applicable; prompt listing dimensions the model doesn't echo back; partial JSON truncation dropping trailing fields.
Related errors
- Evaluation result is missing the "score" field.
- Invalid numeric score for "${fieldName}": ${value}
- Failed to parse evaluation result: no valid score JSON or re
- Evaluation result is not a valid object.
- Evaluation result is missing a valid overall score.
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/7efc3bae53e1603f.
Report an issue: GitHub.