{"record":{"id":"13986ab5bc656169","repo":"mastra-ai/mastra","slug":"run-experiment-scorer-failed-to-score-workflow-tra","errorCode":"RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_WORKFLOW_TRAJECTORY","errorMessage":"Failed to run experiment: Error running workflow trajectory scorer ${scorer.id}","messagePattern":"Failed to run experiment: Error running workflow trajectory scorer (.+?)","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/evals/run/index.ts","lineNumber":1300,"sourceCode":"      }\n\n      for (const scorer of scorers.trajectory) {\n        try {\n          const score = await scorer.run({\n            input: targetResult.scoringData?.input,\n            output: trajectory,\n            groundTruth: item.groundTruth,\n            expectedTrajectory: item.expectedTrajectory,\n            requestContext: item.requestContext,\n            scoreSource: 'experiment',\n            targetScope: 'trajectory',\n            targetEntityType: EntityType.TRAJECTORY,\n            targetTraceId,\n            targetSpanId: targetResult.spanId,\n          });\n          trajectoryScorerResults[scorer.id] = score;\n        } catch (error) {\n          throw new MastraError(\n            {\n              domain: 'SCORER',\n              id: 'RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_WORKFLOW_TRAJECTORY',\n              category: 'USER',\n              text: `Failed to run experiment: Error running workflow trajectory scorer ${scorer.id}`,\n              details: {\n                scorerId: scorer.id,\n                item: JSON.stringify(item),\n              },\n            },\n            error,\n          );\n        }\n      }\n      if (Object.keys(trajectoryScorerResults).length > 0) {\n        scorerResults.trajectory = trajectoryScorerResults;\n      }\n    }","sourceCodeStart":1282,"sourceCodeEnd":1318,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/evals/run/index.ts#L1282-L1318","documentation":"Thrown when a trajectory scorer fails during a workflow experiment run (trajectory over the workflow's execution path). The runner wraps the underlying error with id RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_WORKFLOW_TRAJECTORY, naming the scorer id, targeting EntityType.TRAJECTORY with the workflow run's trace/span.","triggerScenarios":"Experiment on a Workflow target with trajectory scorers; scorer.run against the workflow trajectory throws — e.g. the scorer cannot build a trajectory from workflow step results, or its judge/model call fails.","commonSituations":"Workflow run ended non-success so trajectory data is incomplete; trajectory scorer designed for agent messages fed workflow StepResults instead; LLM judge auth/rate-limit failure; step outputs lacking expected fields.","solutions":["Inspect the wrapped cause for the scorer's internal error.","Verify the workflow run succeeded (status 'success') before trajectory scoring; fix failing steps.","Use trajectory scorers designed for workflow trajectories (or adapt extract to StepResult shapes).","Test the scorer on one recorded workflow trace via scorer.run.","Check judge model credentials if the scorer is LLM-based."],"exampleFix":"// before: agent-style trajectory scorer applied to workflow runs\nscorers: { trajectory: [agentToolUsageScorer] }\n// after: use a workflow-appropriate scorer or guard step shapes\nextract: ({ run }) => ({ steps: run.stepResults ? Object.keys(run.stepResults) : [] })","handlingStrategy":"validation","validationCode":"// only score trajectories of successful workflow runs\nif (result.status !== 'success') throw new Error('Workflow run failed; trajectory incomplete for scoring');","typeGuard":"function hasWorkflowTrajectory(result) {\n  return result.status === 'success' && Array.isArray(result.stepExecutionPath) && result.stepExecutionPath.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Ensure the workflow succeeds before trajectory scoring","Use trajectory scorers built for workflow trajectories (StepResult-based)","Dry-run the trajectory scorer on one recorded workflow trace","Verify judge model credentials for LLM trajectory scorers"],"tags":["evals","scorer","workflow","trajectory"],"backgroundTag":"scorer-run-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}