{"record":{"id":"d45ad7732410cb88","repo":"mastra-ai/mastra","slug":"agent-step-params-id-uses-a-legacy-v1-model-b","errorCode":null,"errorMessage":"Agent step \"${params.id}\" uses a legacy v1 model but does not implement streamLegacy().","messagePattern":"Agent step \"(.+?)\" uses a legacy v1 model but does not implement streamLegacy\\(\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/evented/workflow.ts","lineNumber":602,"sourceCode":"          ...observabilityContext,\n          requestContext,\n          onFinish: (result: any) => {\n            handleFinish(result);\n            void safeOnFinish((agentOptions as any)?.onFinish, result, logger);\n          },\n          abortSignal,\n        });\n        fullStream = modelOutput.fullStream;\n        textPromise = modelOutput.text;\n      } else {\n        // V1 model path: use .streamLegacy() for backwards compatibility\n        let resolveText: (value: string) => void;\n        textPromise = new Promise(resolve => {\n          resolveText = resolve;\n        });\n\n        if (typeof params.streamLegacy !== 'function') {\n          throw new Error(`Agent step \"${params.id}\" uses a legacy v1 model but does not implement streamLegacy().`);\n        }\n\n        const legacyResult = await params.streamLegacy((inputData as { prompt: string }).prompt, {\n          ...(agentOptions ?? {}),\n          ...observabilityContext,\n          requestContext,\n          onFinish: (result: any) => {\n            handleFinish(result);\n            resolveText!(result.text);\n            void safeOnFinish((agentOptions as any)?.onFinish, result, logger);\n          },\n          abortSignal,\n        });\n        fullStream = legacyResult.fullStream;\n      }\n\n      if (abortSignal.aborted) {\n        return abort() as TStepOutput;","sourceCodeStart":584,"sourceCodeEnd":620,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/evented/workflow.ts#L584-L620","documentation":"When createStep wraps an Agent whose model is a legacy v1-style model, the workflow needs the agent to expose streamLegacy() to run it in the evented workflow engine. If the agent reports a legacy model but lacks a streamLegacy() implementation, this Error is thrown because there is no compatible execution path.","triggerScenarios":"Passing an Agent to createStep(agent) where the agent's model is detected as legacy (v1 LanguageModel) and typeof agent.streamLegacy !== 'function' — typically an agent built with an older adapter or a hand-rolled Agent-like object missing streamLegacy.","commonSituations":"Mixing @mastra/core versions (agent built against older core without streamLegacy) inside a newer evented workflow; custom Agent subclasses overriding internals; mock/stub agents in tests that only implement stream.","solutions":["Upgrade @mastra/core (and the agent's model adapter) so the Agent implements streamLegacy, or better, use a v2 model so the legacy path is not needed.","If using a custom/mock agent, add a streamLegacy(prompt, options) method returning the legacy stream result.","Verify all Mastra packages resolve to a single version (pnpm why @mastra/core) to avoid duplicate/mismatched installs."],"exampleFix":"// before\nconst fakeAgent = { id: 'a', model: legacyModel, stream: async () => {} } as any;\ncreateStep(fakeAgent);\n\n// after\nconst fakeAgent = {\n  id: 'a',\n  model: legacyModel,\n  stream: async () => {},\n  streamLegacy: (prompt, opts) => legacyModel.doStream(prompt, opts),\n} as any;\ncreateStep(fakeAgent);","handlingStrategy":"type-guard","validationCode":"if (typeof (agent as any).streamLegacy !== 'function') {\n  throw new Error(`Agent ${agent.id ?? '?'} lacks streamLegacy; upgrade @mastra/core or use a v2 model`);\n}","typeGuard":"const supportsLegacyStream = (a: any): a is { streamLegacy: Function } & Record<string, unknown> =>\n  a != null && typeof a.streamLegacy === 'function';","tryCatchPattern":"try {\n  const step = createStep(agent);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('does not implement streamLegacy()')) {\n    // surface version-mismatch guidance\n  }\n  throw e;\n}","preventionTips":["Keep all @mastra/core-related packages on one version (pnpm why / lockfile check).","Prefer v2-compatible models so the legacy path is never used.","In tests, mock agents should implement both stream and streamLegacy."],"tags":["agent","workflow","version-compat","legacy-model"],"backgroundTag":"missing-streamlegacy-implementation","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}