{"record":{"id":"e549420882f7155f","repo":"mastra-ai/mastra","slug":"agent-generate-malformed-result","errorCode":"AGENT_GENERATE_MALFORMED_RESULT","errorMessage":"Execution workflow produced a result without getFullOutput","messagePattern":"Execution workflow produced a result without getFullOutput","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/agent.ts","lineNumber":8054,"sourceCode":"          {\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\n    const error = fullOutput.error;\n\n    if (error) {\n      throw error;\n    }\n\n    return fullOutput;\n  }\n","sourceCodeStart":8036,"sourceCodeEnd":8072,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/agent.ts#L8036-L8072","documentation":"Agent.generate() expects the execution workflow's result to expose getFullOutput(). If result.result exists but lacks that method, Mastra throws AGENT_GENERATE_MALFORMED_RESULT. Unlike most agent errors this is categorized SYSTEM, meaning it points to an internal contract violation rather than user input.","triggerScenarios":"The workflow returned by #execute() resolves to an object without a getFullOutput function — e.g. a mocked/shimmed workflow result, an incompatible custom workflow implementation, or an internal version mismatch.","commonSituations":"Patching or mocking the internal execution workflow in tests with a partial result shape; mixing @mastra/core versions (e.g. server/core mismatch); subclassing Agent and overriding #execute or related internals incorrectly.","solutions":["Remove any mocks/monkey-patches of the internal execution workflow and use the real result object.","Align all @mastra/* package versions so core internals share one contract.","If subclassing Agent, ensure overridden execute paths return the workflow result with getFullOutput()."],"exampleFix":"// before (test mock)\nvi.spyOn(agent as any, '#execute').mockResolvedValue({ status: 'success', result: {} });\n// after\n.mockResolvedValue({ status: 'success', result: { getFullOutput: async () => output } });","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function hasFullOutput(r: unknown): r is { getFullOutput: () => Promise<unknown> } {\n  return typeof (r as any)?.getFullOutput === 'function';\n}","tryCatchPattern":"try {\n  await agent.generate(prompt);\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'AGENT_GENERATE_MALFORMED_RESULT') {\n    logger.error('Internal result contract violated — check for mocks/version mismatch', { e });\n  }\n  throw e;\n}","preventionTips":["Don't monkey-patch or partially mock Agent internal execution methods.","Use a single aligned version of @mastra/core across server and app.","If subclassing Agent, return results satisfying the full internal contract."],"tags":["agent","generate","internal","contract-violation"],"backgroundTag":"malformed-internal-result","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}