{"record":{"id":"bba9a992f49563af","repo":"mastra-ai/mastra","slug":"a-user-or-system-prompt-is-required-for-combined-a","errorCode":null,"errorMessage":"A user or system prompt is required for combined alignment scoring","messagePattern":"A user or system prompt is required for combined alignment scoring","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/evals/src/scorers/llm/prompt-alignment/index.ts","lineNumber":126,"sourceCode":"    },\n  })\n    .analyze({\n      description: 'Analyze prompt-response alignment across multiple dimensions',\n      outputSchema: analyzeOutputSchema,\n      createPrompt: ({ run }) => {\n        const userPrompt = getUserMessageFromRunInput(run.input) ?? '';\n        const systemPrompt = getCombinedSystemPrompt(run.input) ?? '';\n        const agentResponse = getAssistantMessageFromRunOutput(run.output) ?? '';\n\n        // Validation based on evaluation mode\n        if (evaluationMode === 'user' && !userPrompt) {\n          throw new Error('User prompt is required for user prompt alignment scoring');\n        }\n        if (evaluationMode === 'system' && !systemPrompt) {\n          throw new Error('System prompt is required for system prompt alignment scoring');\n        }\n        if (evaluationMode === 'both' && !userPrompt && !systemPrompt) {\n          throw new Error('A user or system prompt is required for combined alignment scoring');\n        }\n        if (!agentResponse) {\n          throw new Error('Agent response is required for prompt alignment scoring');\n        }\n\n        return createAnalyzePrompt({\n          userPrompt,\n          systemPrompt,\n          agentResponse,\n          evaluationMode,\n          conversationHistory: historyOptions && getConversationHistoryFromRunInput(run.input, historyOptions),\n        });\n      },\n    })\n    .generateScore(({ results }) => {\n      const analysis = results.analyzeStepResult;\n\n      if (!analysis) {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/evals/src/scorers/llm/prompt-alignment/index.ts#L108-L144","documentation":"In 'both' evaluation mode the prompt-alignment scorer judges the response against the user prompt and system prompt together. It requires at least one of the two; if neither is present in the run input, the scorer throws because there is nothing to align against.","triggerScenarios":"Running the scorer with evaluationMode = 'both' where run.input contains neither a user message nor a system message — e.g. an input of only tool/tool-result messages or an empty message array.","commonSituations":"Scoring intermediate agent steps that contain only tool calls/results; passing an empty or malformed messages array; misconfigured run capture that dropped prompt messages from the recorded input.","solutions":["Ensure run.input contains a user or system message before scoring","Score complete conversation runs rather than tool-only intermediate steps","Validate run input shape (message roles) before invoking the scorer"],"exampleFix":"// before\nawait scorer.run({ input: { messages: [{ role: 'tool', content: 'result...' }] }, output });\n// after\nif (!hasUserOrSystemPrompt(runInput)) throw new Error('Run input must include a user or system prompt');\nawait scorer.run({ input: fullConversationInput, output });","handlingStrategy":"validation","validationCode":"if (evaluationMode === 'both' && !getUserMessageFromRunInput(run.input) && !getCombinedSystemPrompt(run.input)) {\n  throw new Error('Run has neither user nor system prompt; cannot score combined alignment');\n}","typeGuard":"function hasAnyPrompt(input) {\n  return Boolean(getUserMessageFromRunInput(input) || getCombinedSystemPrompt(input));\n}","tryCatchPattern":"try {\n  const result = await scorer.run({ input, output });\n} catch (e) {\n  if (e.message.includes('combined alignment scoring')) {\n    return { skipped: true, reason: 'no user or system prompt in run input' };\n  }\n  throw e;\n}","preventionTips":["Score only complete conversation runs that include prompt messages","Check that run-capture tooling records prompt messages, not just tool traffic","Pre-filter eval batches with hasAnyPrompt before invoking the scorer"],"tags":["evals","runtime","validation","message-extraction"],"backgroundTag":"missing-required-scorer-option","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}