mastra-ai/mastra · error · MastraError
MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED
MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED
Error message
Scorer Run Failed: ${workflowFailure.message} What it means
When a MastraScorer's underlying workflow run fails, run() inspects the failure state and wraps the workflow's error message in a MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED MastraError (SCORER domain, USER category), including completed steps and the failed step in details. It indicates a step inside the scorer's internal pipeline threw, rather than a config problem.
Source
Thrown at packages/core/src/evals/base.ts:1075
cause: workflowFailure,
});
}
throw error;
}
if (workflowResult.status === 'failed') {
const workflowFailure = getErrorFromUnknown(workflowResult.error, {
fallbackMessage: 'Scorer workflow failed',
});
const failedJudgeExecution = takeFailedJudgeExecution(workflowFailure);
const failedStepFromError = takeFailedScorerStep(workflowFailure);
const failureState = this.getWorkflowFailureState(workflowResult);
const failedStep = failedStepFromError ?? failureState.failedStep;
const { completedSteps, latestSuccessfulOutput } = failureState;
evalSpan?.error({ error: workflowFailure, endSpan: true });
if (!failedStep) {
throw new MastraError(
{
id: 'MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED',
domain: ErrorDomain.SCORER,
category: ErrorCategory.USER,
text: `Scorer Run Failed: ${workflowFailure.message}`,
details: {
scorerId: this.config.id ?? this.config.name,
steps: this.steps.map(s => s.name).join(', '),
},
},
workflowFailure,
);
}
const finalStepResult = failedJudgeExecution
? this.appendFailedJudgeExecution(latestSuccessfulOutput, failedStep, failedJudgeExecution)
: latestSuccessfulOutput;
const result = this.hasScorerResultFields(finalStepResult)View on GitHub (pinned to 75dd419e61)
Solutions
- Read the wrapped workflowFailure.message and the failedStep in error.details to find which step threw, then fix that step's root cause.
- Verify LLM credentials, model availability, and rate limits if the failed step calls a model.
- Harden custom steps (preprocess/generateScore) with input validation and try/catch so transient issues don't fail the whole run.
- Catch this error at the call site to mark the evaluation run as failed instead of crashing the batch.
Example fix
// before
const result = await scorer.run({ input, runId }); // crashes batch on step failure
// after
try {
const result = await scorer.run({ input, runId });
} catch (e) {
logger.error('Scorer step failed', { scorerId: 's1', cause: e.message, details: e.details });
} Defensive patterns
Strategy: try-catch
Validate before calling
// validate inputs/credentials each step depends on before running
if (!process.env.OPENAI_API_KEY) throw new Error('Missing OPENAI_API_KEY required by scorer steps'); Type guard
function isScorerWorkflowFailure(e: unknown): e is MastraError & { id: 'MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED' } {
return e instanceof MastraError && e.id === 'MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED';
} Try / catch
try {
const result = await scorer.run({ input, runId });
} catch (e) {
if (isScorerWorkflowFailure(e)) {
logger.error(`Scorer step failed: ${e.details?.failedStep}`, { completedSteps: e.details?.completedSteps, cause: e.message });
return; // mark run failed, continue batch
}
throw e;
} Prevention
- Wrap scorer.run calls in try/catch so one failing item doesn't abort an eval batch.
- Inspect error.details.failedStep and completedSteps to pinpoint the failing step.
- Harden step implementations (LLM retries, input validation) to reduce transient failures.
- Check API keys/model availability before large scoring runs.
When it happens
Trigger: Calling scorer.run(...) where any workflow step (preprocess, generateScore, etc.) throws — the workflow returns a failure and there is a resolvable failedStep (explicitly or from the failure state) — so the raw step error is rethrown with 'Scorer Run Failed: <message>'.
Common situations: A generateScore step calling an LLM that errors (bad API key, rate limits, model outage); a preprocess step throwing on unexpected input data; a custom step with a bug; network failures during score generation.
Related errors
- RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_STEP_RESULT
- RUN_EXPERIMENT_SCORER_FAILED_TO_SCORE_WORKFLOW_TRAJECTORY
- MASTR_SCORER_FAILED_TO_CREATE_MISSING_ID
- MASTR_SCORER_FAILED_TO_RUN_MISSING_GENERATE_SCORE
- RUN_EXPERIMENT_TARGET_FAILED_TO_GENERATE_RESULT
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/4d59fd7009e68e02.
Report an issue: GitHub.