{"record":{"id":"846f2e88bd371e0f","repo":"mastra-ai/mastra","slug":"step-scorerstep-name-is-not-a-prompt-object","errorCode":null,"errorMessage":"Step \"${scorerStep.name}\" is not a prompt object","messagePattern":"Step \"(.+?)\" is not a prompt object","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/evals/base.ts","lineNumber":1367,"sourceCode":"      return { run, results: accumulatedResults, score };\n    }\n\n    return { run, results: accumulatedResults };\n  }\n\n  private async executeFunctionStep(scorerStep: ScorerStepDefinition, context: any) {\n    return await scorerStep.definition(context);\n  }\n\n  private async executePromptStep(\n    scorerStep: ScorerStepDefinition,\n    observabilityContext: ObservabilityContext,\n    context: any,\n  ): Promise<{ result: unknown; prompt: string; judgeModel?: string; execution: ScorerJudgeExecution }> {\n    const startedAt = performance.now();\n    const originalStep = this.originalPromptObjects.get(scorerStep.name);\n    if (!originalStep) {\n      throw new Error(`Step \"${scorerStep.name}\" is not a prompt object`);\n    }\n\n    const prompt = await originalStep.createPrompt(context);\n    const modelConfig = originalStep.judge?.model ?? this.config.judge?.model;\n    const instructions = originalStep.judge?.instructions ?? this.config.judge?.instructions;\n    const jsonPromptInjection =\n      originalStep.judge?.jsonPromptInjection ?? this.config.judge?.jsonPromptInjection ?? 'auto';\n    // Step-level tools override scorer-level tools. When present, the judge agent\n    // can call them (in its own tool-call loop) before producing the step output.\n    const tools = originalStep.judge?.tools ?? this.config.judge?.tools;\n    const memory = this.config.judge?.memory;\n    const defaultMemoryOptions = this.config.judge?.defaultMemoryOptions;\n    const stepMemoryOptions = originalStep.judge?.memory;\n    const onStream = originalStep.judge?.onStream ?? this.config.judge?.onStream;\n    const onStepFinish = originalStep.judge?.onStepFinish ?? this.config.judge?.onStepFinish;\n    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;","sourceCodeStart":1349,"sourceCodeEnd":1385,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/evals/base.ts#L1349-L1385","documentation":"MastraScorer keeps a registry (`originalPromptObjects`) of the prompt objects registered on the scorer. When a judge step runs, it looks the step up by name via `this.originalPromptObjects.get(scorerStep.name)`; if the name is absent, this plain Error is thrown. It means the step being executed was never registered as a prompt object on this scorer, so the library cannot produce the judge prompt.","triggerScenarios":"Calling `MastraScorer.runJudge`/internal step execution with a `scorerStep.name` that has no entry in `originalPromptObjects` — e.g. a scorer step was renamed, a custom step was injected that bypassed registration, or the scorer was constructed without registering its prompt objects.","commonSituations":"Renaming a scorer step but referencing the old name in config; building scorers programmatically and adding steps directly to internal state instead of via the constructor; version drift where serialized/stored scorer configs reference steps that no longer exist on the scorer class.","solutions":["Ensure every scorer step is registered through the scorer constructor/config so it lands in `originalPromptObjects`","Verify `scorerStep.name` matches the name of a registered prompt object exactly (case-sensitive)","Re-create the scorer from current code/config if it was deserialized from an older schema","If constructing steps dynamically, register each prompt object on the scorer before running it"],"exampleFix":"// before\nscorer.addStep({ name: 'correctness-judge', ... }); // not registered -> throws at runtime\n// after\nconst scorer = new MastraScorer({\n  id: 'my-scorer',\n  judge: { model: 'openai/gpt-4o', instructions: 'Grade the answer' },\n});\n// use the scorer's own judge step (auto-registered) instead of a hand-built step","handlingStrategy":"validation","validationCode":"function isRegisteredPromptStep(scorer, stepName) {\n  // access via the scorer's registered steps / originalPromptObjects surface\n  return !!scorer.getStep?.(stepName) ?? false;\n}\n// assert before running:\nif (!isRegisteredPromptStep(scorer, step.name)) throw new Error(`Step \"${step.name}\" not registered on scorer`);","typeGuard":"function hasRegisteredStep(scorer: MastraScorer, name: string): boolean {\n  return typeof (scorer as any).originalPromptObjects?.get === 'function'\n    && (scorer as any).originalPromptObjects.has(name);\n}","tryCatchPattern":null,"preventionTips":["Always create scorer steps through the scorer's constructor/config API, never by mutating internals","Keep step names in a single shared constant so references can't drift","Re-register steps after deserializing or copying a scorer"],"tags":["scorer","configuration","llm-judge"],"backgroundTag":"scorer-step-not-registered","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}