{"record":{"id":"5b29abef5d1fd715","repo":"mastra-ai/mastra","slug":"run-experiment-scorer-failed-to-score-step-result","errorCode":"RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_STEP_RESULT","errorMessage":"Failed to run experiment: Error running scorer ${scorer.id} on step ${stepId}","messagePattern":"Failed to run experiment: Error running scorer (.+?) on step (.+?)","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/evals/run/index.ts","lineNumber":1245,"sourceCode":"        // TODO : Ideally this would run on the trace.WORKFLOW_STEP span...\n        // then we could directly add the score to that span\n        if (stepResult?.status === 'success' && stepResult.output !== undefined) {\n          const stepResults: Record<string, any> = {};\n          for (const scorer of stepScorers) {\n            try {\n              const score = await scorer.run({\n                input: stepResult.payload !== undefined ? stepResult.payload : targetResult.scoringData.input,\n                output: stepResult.output,\n                groundTruth: item.groundTruth,\n                requestContext: item.requestContext,\n                scoreSource: 'experiment',\n                targetScope: 'span',\n                targetEntityType: EntityType.WORKFLOW_STEP,\n                targetTraceId,\n              });\n              stepResults[scorer.id] = score;\n            } catch (error) {\n              throw new MastraError(\n                {\n                  domain: 'SCORER',\n                  id: 'RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_STEP_RESULT',\n                  category: 'USER',\n                  text: `Failed to run experiment: Error running scorer ${scorer.id} on step ${stepId}`,\n                  details: {\n                    scorerId: scorer.id,\n                    stepId,\n                  },\n                },\n                error,\n              );\n            }\n          }\n          if (Object.keys(stepResults).length > 0) {\n            stepScorerResults[stepId] = stepResults;\n          }\n        }","sourceCodeStart":1227,"sourceCodeEnd":1263,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/evals/run/index.ts#L1227-L1263","documentation":"Thrown when a scorer fails while scoring an individual workflow step result during a workflow experiment run. For each step in the workflow result, scorers run per stepId; any throw is wrapped with id RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_STEP_RESULT and the message includes both scorer id and step id.","triggerScenarios":"Experiment on a Workflow target with scorers defined per-step; scorer.run is called with targetScope 'span' and EntityType.WORKFLOW_STEP for stepId and throws — e.g. the step's output doesn't match what the scorer extracts, or the step failed (status error) leaving no output to score.","commonSituations":"Scoring a step whose StepResult.status is 'failed' so output is undefined; scorer extract assumes fields the step schema doesn't produce; step id renamed in the workflow while scorer config still references the old id; LLM judge failure.","solutions":["Look at the cause and the named stepId to find which step/scorer combination failed.","Check that step's StepResult — if the step itself failed, fix the workflow step first.","Ensure the scorer's extract/process handles the step's actual output schema.","Confirm the stepId in scorer configuration matches the workflow's current step ids.","Skip or guard scoring for failed steps in custom scorer code."],"exampleFix":"// before: scorer assumes step output always exists\nextract: ({ run }) => run.output.text\n// after\nextract: ({ run }) => run.output?.text ?? ''","handlingStrategy":"type-guard","validationCode":"// check step results are scoreable before scoring steps\nfor (const [stepId, step] of Object.entries(result.steps)) {\n  if (step.status !== 'success') console.warn(`Skipping scoring for failed step ${stepId}`);\n}","typeGuard":"function isScoreableStepResult(step) {\n  return step != null && step.status === 'success' && step.output != null;\n}","tryCatchPattern":"try {\n  await experiment.run();\n} catch (e) {\n  if (e?.id === 'RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_STEP_RESULT') {\n    console.error('Per-step scoring failed:', e.message, e.cause);\n  } else throw e;\n}","preventionTips":["Fix failing workflow steps first — scorers run on their outputs","Keep scorer per-step config step ids in sync with the workflow definition","Make step scorers tolerant of optional/missing output fields","Type step outputs with Zod schemas so mismatches surface early"],"tags":["evals","scorer","workflow","error-wrapping"],"backgroundTag":"scorer-run-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}