{"record":{"id":"24c68f1a281f172e","repo":"mastra-ai/mastra","slug":"sub-agent-agent-id-returned-a-v1-model-but-does-24c68f","errorCode":null,"errorMessage":"Sub-agent ${agent.id} returned a v1 model but does not implement streamLegacy","messagePattern":"Sub-agent (.+?) returned a v1 model but does not implement streamLegacy","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/agent.ts","lineNumber":5598,"sourceCode":"                  });\n                }\n\n                // Use streamResult.text (a delayed promise) which resolves to the\n                // output-processor-modified text, rather than the raw accumulated text-deltas.\n                const processedText = await streamResult.text;\n                const subAgentFinishReason = await streamResult.finishReason;\n                const subAgentUsage = await streamResult.usage;\n                result = {\n                  text: processedText,\n                  finishReason: subAgentFinishReason,\n                  subAgentThreadId: effectiveStreamThreadId,\n                  subAgentResourceId: effectiveStreamResourceId,\n                  subAgentToolResults,\n                  usage: subAgentUsage,\n                };\n              } else {\n                if (typeof resolvedAgent.streamLegacy !== 'function') {\n                  throw new Error(`Sub-agent ${agent.id} returned a v1 model but does not implement streamLegacy`);\n                }\n                const streamResult = await resolvedAgent.streamLegacy(effectivePrompt, {\n                  requestContext: subAgentRequestContext,\n                  actor: invocationActor,\n                  ...resolveObservabilityContext(context ?? {}),\n                  ...subAgentAbortOptions,\n                });\n\n                let fullText = '';\n                for await (const chunk of streamResult.fullStream) {\n                  if (context?.writer) {\n                    // Data chunks from writer.custom() should bubble up directly without wrapping\n                    if (chunk.type.startsWith('data-')) {\n                      // Write data chunks directly to original stream to bubble up\n                      await context.writer.custom(chunk as any);\n                    } else {\n                      await context.writer.write(chunk);\n                    }","sourceCodeStart":5580,"sourceCodeEnd":5616,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/agent.ts#L5580-L5616","documentation":"Streaming counterpart to the generateLegacy error: when a sub-agent resolves to a 'v1' model version but its instance lacks a `streamLegacy` function, the parent's streaming delegation path throws instead of attempting to call an undefined method.","triggerScenarios":"Parent agent delegation/streaming call where `resolvedModelVersion === 'v1'` and `typeof resolvedAgent.streamLegacy !== 'function'`; typically caused by mixed @mastra/core/model-provider versions across parent and sub-agents.","commonSituations":"Same mixed-version migration scenarios as the generate variant, surfaced via `stream()`/loop streaming calls; custom Agent implementations that implement modern stream but not streamLegacy while still holding a v1 model.","solutions":["Upgrade the sub-agent's model to the current version so streaming uses the modern path","Align @mastra/core versions across all agents in the network","If keeping a v1 model, use a core version where Agent provides streamLegacy","Inspect custom Agent subclasses for a missing streamLegacy implementation"],"exampleFix":"// before\nmodel: openai('gpt-4o') /* legacy v1 adapter */\n// after\nmodel: currentProviderAdapter('gpt-4o') /* v2 */","handlingStrategy":"validation","validationCode":"function subAgentSupportsStream(agent) {\n  return typeof agent.stream === 'function' &&\n    (agent.streamLegacy !== undefined || agent.__modelVersion !== 'v1');\n}","typeGuard":"function canStreamLegacy(agent) {\n  return typeof (agent as { streamLegacy?: unknown })?.streamLegacy === 'function';\n}","tryCatchPattern":"try {\n  return await parentAgent.stream(prompt, { agents: [subAgent] });\n} catch (e) {\n  if (typeof e?.message === 'string' && e.message.includes('does not implement streamLegacy')) {\n    logger.error('sub-agent model is v1 without streamLegacy; upgrade model or core');\n    return errorStream('sub-agent-incompatible');\n  }\n  throw e;\n}","preventionTips":["Upgrade legacy v1 model adapters to current provider adapters","Run a smoke stream against every sub-agent in CI","Avoid custom Agent subclasses that drop streamLegacy while keeping v1 models","Align model-provider and core package versions in lockfile"],"tags":["agent","delegation","sub-agent","streaming","model-version","v1-legacy"],"backgroundTag":"model-version-mismatch","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}