mastra-ai/mastra · error · MastraError
AGENT_GENERATE_UNKNOWN_ERROR
AGENT_GENERATE_UNKNOWN_ERROR
Error message
An unknown error occurred while streaming
What it means
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.
Source
Thrown at packages/core/src/agent/agent.ts:8045
// Use agent's maxProcessorRetries as default, allow options to override
maxProcessorRetries: mergedOptions.maxProcessorRetries ?? this.#maxProcessorRetries,
} as unknown as InnerAgentExecutionOptions<any> & { _threadStreamPubSub?: PubSub };
const result = await this.#execute(executeOptions);
if (result.status !== 'success') {
if (result.status === 'failed') {
throw new MastraError(
{
id: 'AGENT_GENERATE_FAILED',
domain: ErrorDomain.AGENT,
category: ErrorCategory.USER,
},
// pass original error to preserve stack trace
result.error,
);
}
throw new MastraError({
id: 'AGENT_GENERATE_UNKNOWN_ERROR',
domain: ErrorDomain.AGENT,
category: ErrorCategory.USER,
text: 'An unknown error occurred while streaming',
});
}
if (typeof result.result?.getFullOutput !== 'function') {
throw new MastraError({
id: 'AGENT_GENERATE_MALFORMED_RESULT',
domain: ErrorDomain.AGENT,
category: ErrorCategory.SYSTEM,
text: 'Execution workflow produced a result without getFullOutput',
});
}
const fullOutput = await result.result.getFullOutput();
View on GitHub (pinned to 75dd419e61)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await agent.generate(prompt);
} catch (e) {
if (e instanceof MastraError && e.id === 'AGENT_GENERATE_UNKNOWN_ERROR') {
logger.error('Unknown generate status — report bug with repro', { e });
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Version drift between @mastra/core internals; workflow execution ending in an unexpected terminal state; bugs in custom middlewares/processors that short-circuit execution.
Related errors
- AGENT_GENERATE_MALFORMED_RESULT
- AGENT_GENERATE_V1_MODEL_NOT_SUPPORTED
- AGENT_GENERATE_FAILED
- AGENT_STREAM_UNKNOWN_ERROR
- ${message.errors.join('\n') || `Claude Agent SDK failed with
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/bfda8693a73b8a85.
Report an issue: GitHub.