mastra-ai/mastra · error · MastraError
RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_WORKFLOW_TRAJECTORY
RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_WORKFLOW_TRAJECTORY
Error message
Failed to run experiment: Error running workflow trajectory scorer ${scorer.id} What it means
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.
Source
Thrown at packages/core/src/evals/run/index.ts:1300
}
for (const scorer of scorers.trajectory) {
try {
const score = await scorer.run({
input: targetResult.scoringData?.input,
output: trajectory,
groundTruth: item.groundTruth,
expectedTrajectory: item.expectedTrajectory,
requestContext: item.requestContext,
scoreSource: 'experiment',
targetScope: 'trajectory',
targetEntityType: EntityType.TRAJECTORY,
targetTraceId,
targetSpanId: targetResult.spanId,
});
trajectoryScorerResults[scorer.id] = score;
} catch (error) {
throw new MastraError(
{
domain: 'SCORER',
id: 'RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_WORKFLOW_TRAJECTORY',
category: 'USER',
text: `Failed to run experiment: Error running workflow trajectory scorer ${scorer.id}`,
details: {
scorerId: scorer.id,
item: JSON.stringify(item),
},
},
error,
);
}
}
if (Object.keys(trajectoryScorerResults).length > 0) {
scorerResults.trajectory = trajectoryScorerResults;
}
}View on GitHub (pinned to 75dd419e61)
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.
Example fix
// before: agent-style trajectory scorer applied to workflow runs
scorers: { trajectory: [agentToolUsageScorer] }
// after: use a workflow-appropriate scorer or guard step shapes
extract: ({ run }) => ({ steps: run.stepResults ? Object.keys(run.stepResults) : [] }) Defensive patterns
Strategy: validation
Validate before calling
// only score trajectories of successful workflow runs
if (result.status !== 'success') throw new Error('Workflow run failed; trajectory incomplete for scoring'); Type guard
function hasWorkflowTrajectory(result) {
return result.status === 'success' && Array.isArray(result.stepExecutionPath) && result.stepExecutionPath.length > 0;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED
- RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_TRAJECTORY
- RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_STEP_RESULT
- MASTR_SCORER_FAILED_TO_CREATE_MISSING_ID
- MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/13986ab5bc656169.
Report an issue: GitHub.