{"record":{"id":"bfda8693a73b8a85","repo":"mastra-ai/mastra","slug":"agent-generate-unknown-error","errorCode":"AGENT_GENERATE_UNKNOWN_ERROR","errorMessage":"An unknown error occurred while streaming","messagePattern":"An unknown error occurred while streaming","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/agent.ts","lineNumber":8045,"sourceCode":"      // Use agent's maxProcessorRetries as default, allow options to override\n      maxProcessorRetries: mergedOptions.maxProcessorRetries ?? this.#maxProcessorRetries,\n    } as unknown as InnerAgentExecutionOptions<any> & { _threadStreamPubSub?: PubSub };\n\n    const result = await this.#execute(executeOptions);\n\n    if (result.status !== 'success') {\n      if (result.status === 'failed') {\n        throw new MastraError(\n          {\n            id: 'AGENT_GENERATE_FAILED',\n            domain: ErrorDomain.AGENT,\n            category: ErrorCategory.USER,\n          },\n          // pass original error to preserve stack trace\n          result.error,\n        );\n      }\n      throw new MastraError({\n        id: 'AGENT_GENERATE_UNKNOWN_ERROR',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        text: 'An unknown error occurred while streaming',\n      });\n    }\n\n    if (typeof result.result?.getFullOutput !== 'function') {\n      throw new MastraError({\n        id: 'AGENT_GENERATE_MALFORMED_RESULT',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.SYSTEM,\n        text: 'Execution workflow produced a result without getFullOutput',\n      });\n    }\n\n    const fullOutput = await result.result.getFullOutput();\n","sourceCodeStart":8027,"sourceCodeEnd":8063,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/agent.ts#L8027-L8063","documentation":"This is the fall-through case in Agent.generate(): #execute() returned a result whose status is neither 'success' nor 'failed' (an unexpected status), so Mastra throws a generic AGENT_GENERATE_UNKNOWN_ERROR because there is no original error to attach.","triggerScenarios":"agent.generate() where the internal execution result.status is an unrecognized value (not 'success' and not 'failed') — e.g. internal state machine produced 'suspended'/'aborted'-like status in a context where it shouldn't occur.","commonSituations":"Version drift between @mastra/core internals; workflow execution ending in an unexpected terminal state; bugs in custom middlewares/processors that short-circuit execution.","solutions":["Update @mastra/core to the latest patch version — this indicates an unhandled internal status.","Log the full result object just before the call (or enable debug logging) to capture the actual status.","Report the issue with reproduction steps if it persists, including middleware/processor configuration."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await agent.generate(prompt);\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'AGENT_GENERATE_UNKNOWN_ERROR') {\n    logger.error('Unknown generate status — report bug with repro', { e });\n  }\n  throw e;\n}","preventionTips":["Keep @mastra/core and all @mastra/* packages on aligned versions.","Avoid mocking internal execution paths in tests.","Report persistent occurrences to the maintainers with a reproduction."],"tags":["agent","generate","unknown-status","internal"],"backgroundTag":"unexpected-execution-status","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}