{"record":{"id":"a656a58563d47967","repo":"mastra-ai/mastra","slug":"weather-agent-not-found","errorCode":null,"errorMessage":"Weather agent not found","messagePattern":"Weather agent not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent-builder/src/defaults.ts","lineNumber":346,"sourceCode":"\nconst planActivities = createStep({\n  id: 'plan-activities',\n  description: 'Suggests activities based on weather conditions',\n  inputSchema: forecastSchema,\n  outputSchema: z.object({\n    activities: z.string(),\n  }),\n  execute: async (inputData, context) => {\n    const mastra = context?.mastra;\n    const forecast = inputData;\n\n    if (!forecast) {\n      throw new Error('Forecast data not found');\n    }\n\n    const agent = mastra?.getAgent('weatherAgent');\n    if (!agent) {\n      throw new Error('Weather agent not found');\n    }\n\n    const prompt = \\${weatherWorkflowPrompt}\n\n    const response = await agent.stream([\n      {\n        role: 'user',\n        content: prompt,\n      },\n    ]);\n\n    let activitiesText = '';\n\n    for await (const chunk of response.textStream) {\n      process.stdout.write(chunk);\n      activitiesText += chunk;\n    }\n","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/agent-builder/src/defaults.ts#L328-L364","documentation":"The default workflow step fetches the Mastra instance from context and calls mastra.getAgent('weatherAgent'), throwing 'Weather agent not found' when the lookup returns undefined. This means the Mastra instance wiring into the workflow does not contain a registered agent with id 'weatherAgent'.","triggerScenarios":"Executing the forecast-reporting step inside a Mastra instance whose agents map has no 'weatherAgent' registration — e.g. the agent was removed/renamed in defaults.ts, the step runs with context.mastra undefined or a bare Mastra created without registering the default agent.","commonSituations":"Custom Mastra instantiation that includes the default workflow but not the default agent; renaming the agent id while the workflow hardcodes 'weatherAgent'; DI/config in mastra/ omitting the defaults agent; tests constructing a partial Mastra.","solutions":["Register the default weather agent with id 'weatherAgent' in the Mastra instance used to run the workflow (new Mastra({ agents: { weatherAgent } }))","Verify context?.mastra is defined at execute time — if undefined, the getAgent chain silently yields undefined","Keep the agent id in sync if you renamed it, or update the hardcoded 'weatherAgent' string in the step","Run the workflow through the fully-assembled default Mastra (as built in defaults.ts/mastra config) rather than a partial instance"],"exampleFix":"// before\nconst mastra = new Mastra({ workflows: { weatherWorkflow } }); // agent missing\n\n// after\nconst mastra = new Mastra({\n  agents: { weatherAgent },\n  workflows: { weatherWorkflow },\n});","handlingStrategy":"validation","validationCode":"const mastra = new Mastra({ agents: { weatherAgent }, workflows: { weatherWorkflow } });\nif (!mastra.getAgent('weatherAgent')) {\n  throw new Error('weatherAgent must be registered before running weatherWorkflow');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register every agent a workflow references in the same Mastra instance","Avoid renaming the default 'weatherAgent' id without updating workflow code","Run workflows through the fully-assembled Mastra, not partial instances in tests"],"tags":["configuration","dependency-injection","agent-builder"],"backgroundTag":"agent-not-registered","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}