{"record":{"id":"1ade0e32d7344c4a","repo":"mastra-ai/mastra","slug":"mastr-scorer-failed-to-run-missing-model-or-instru","errorCode":"MASTR_SCORER_FAILED_TO_RUN_MISSING_MODEL_OR_INSTRUCTIONS","errorMessage":"Step \"${scorerStep.name}\" requires a model and instructions","messagePattern":"Step \"(.+?)\" requires a model and instructions","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/evals/base.ts","lineNumber":1401,"sourceCode":"    const onFinish = originalStep.judge?.onFinish ?? this.config.judge?.onFinish;\n    const maxSteps = originalStep.judge?.maxSteps ?? this.config.judge?.maxSteps;\n    const inputProcessors = originalStep.judge?.inputProcessors ?? this.config.judge?.inputProcessors;\n    const outputProcessors = originalStep.judge?.outputProcessors ?? this.config.judge?.outputProcessors;\n    const errorProcessors = originalStep.judge?.errorProcessors ?? this.config.judge?.errorProcessors;\n    const maxProcessorRetries = originalStep.judge?.maxProcessorRetries ?? this.config.judge?.maxProcessorRetries;\n    const memoryOptions = stepMemoryOptions\n      ? {\n          ...defaultMemoryOptions,\n          ...stepMemoryOptions,\n          options:\n            defaultMemoryOptions?.options || stepMemoryOptions.options\n              ? { ...defaultMemoryOptions?.options, ...stepMemoryOptions.options }\n              : undefined,\n        }\n      : defaultMemoryOptions;\n\n    if (!modelConfig || !instructions) {\n      throw new MastraError({\n        id: 'MASTR_SCORER_FAILED_TO_RUN_MISSING_MODEL_OR_INSTRUCTIONS',\n        domain: ErrorDomain.SCORER,\n        category: ErrorCategory.USER,\n        text: `Step \"${scorerStep.name}\" requires a model and instructions`,\n        details: {\n          scorerId: this.config.id ?? this.config.name,\n          step: scorerStep.name,\n        },\n      });\n    }\n\n    // Resolve the model configuration to a LanguageModel instance\n    // Pass the Mastra instance to enable custom gateway resolution\n    const resolvedModel = await resolveModelConfig(\n      modelConfig,\n      this.config.judge?.requestContext ?? undefined,\n      this.#mastra,\n    );","sourceCodeStart":1383,"sourceCodeEnd":1419,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/evals/base.ts#L1383-L1419","documentation":"A judge step needs both a model (to call the LLM) and instructions (the prompt rubric). When `modelConfig` or `instructions` resolve to undefined after falling back from `originalStep.judge` to `this.config.judge`, a MastraError (id MASTR_SCORER_FAILED_TO_RUN_MISSING_MODEL_OR_INSTRUCTIONS, category USER) is thrown. This is a user configuration error: the scorer was defined without a complete judge configuration.","triggerScenarios":"Running a scorer whose step has no `judge.model` and the scorer-level `config.judge.model` is also missing (or the same for `instructions`) — e.g. `new MastraScorer({ id })` with no judge block, or a step-level judge overriding only one of the two fields while the top-level judge is absent.","commonSituations":"Creating a scorer with only `name`/`id` and forgetting the `judge` config; setting `judge.instructions` but no `judge.model` (or vice versa); env-based model resolution (e.g. missing OPENAI_API_KEY helper) returning undefined at construction time; copy-pasting a scorer template and deleting the judge block.","solutions":["Add both `judge.model` and `judge.instructions` to the scorer config","Or set them per-step in the step's `judge` block so the fallback resolves for every step","Use a model helper (e.g. `openai('gpt-4o')`) to guarantee a valid model instance instead of a possibly-undefined string/env value","Log/print the resolved `modelConfig` and `instructions` before running to confirm they are non-null"],"exampleFix":"// before\nconst scorer = new MastraScorer({ id: 'tone' }); // no judge\n// after\nconst scorer = new MastraScorer({\n  id: 'tone',\n  judge: {\n    model: openai('gpt-4o'),\n    instructions: 'Rate the response tone from 1-5 and explain.',\n  },\n});","handlingStrategy":"validation","validationCode":"function validateJudgeConfig(config) {\n  const judge = config.judge ?? {};\n  if (!judge.model || !judge.instructions) {\n    throw new Error(`Scorer \"${config.id ?? config.name}\" needs judge.model and judge.instructions`);\n  }\n}\nvalidateJudgeConfig(scorerConfig); // before constructing/running","typeGuard":"function hasCompleteJudge(c: { judge?: { model?: unknown; instructions?: unknown } }):\n  c is { judge: { model: NonNullable<typeof c.judge>['model']; instructions: string } } {\n  return !!c.judge && !!c.judge.model && typeof c.judge.instructions === 'string' && c.judge.instructions.length > 0;\n}","tryCatchPattern":"try {\n  await scorer.run(runInput);\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'MASTR_SCORER_FAILED_TO_RUN_MISSING_MODEL_OR_INSTRUCTIONS') {\n    console.error(`Scorer ${e.details.scorerId}: set judge.model and judge.instructions`);\n  } else throw e;\n}","preventionTips":["Always define the judge block at scorer level as the default for all steps","Centralize judge model/instructions in a factory helper so they can't be omitted","Assert judge config completeness in unit tests for every scorer"],"tags":["scorer","configuration","missing-model","missing-instructions"],"backgroundTag":"missing-required-config","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}