mastra-ai/mastra · critical · MastraError
MESSAGE_HISTORY_MISSING_STORAGE_ADAPTER
MESSAGE_HISTORY_MISSING_STORAGE_ADAPTER
Error message
Using Mastra Memory message history requires a storage adapter but no attached adapter was detected.
What it means
The lastMessages feature (recent message history recall) reads prior messages from storage. getInputProcessors throws this MastraError (MESSAGE_HISTORY_MISSING_STORAGE_ADAPTER, category USER, domain STORAGE) when lastMessages is configured but memoryStore is undefined when building the message-history input processor.
Source
Thrown at packages/core/src/memory/memory.ts:791
processors.push(
new WorkingMemory({
storage: memoryStore,
template,
scope: typeof effectiveConfig.workingMemory === 'object' ? effectiveConfig.workingMemory.scope : undefined,
useVNext:
typeof effectiveConfig.workingMemory === 'object' &&
'version' in effectiveConfig.workingMemory &&
effectiveConfig.workingMemory.version === 'vnext',
templateProvider: this,
}),
);
}
}
const lastMessages = effectiveConfig.lastMessages;
if (lastMessages) {
if (!memoryStore)
throw new MastraError({
category: 'USER',
domain: ErrorDomain.STORAGE,
id: 'MESSAGE_HISTORY_MISSING_STORAGE_ADAPTER',
text: 'Using Mastra Memory message history requires a storage adapter but no attached adapter was detected.',
});
// Check if user already manually added MessageHistory
const hasMessageHistory = configuredProcessors.some(p => !isProcessorWorkflow(p) && p.id === 'message-history');
// Check if ObservationalMemory is present (via processor or config) - it handles its own message loading and saving
const hasObservationalMemory =
configuredProcessors.some(p => !isProcessorWorkflow(p) && p.id === 'observational-memory') ||
isObservationalMemoryEnabled(effectiveConfig.observationalMemory);
// Skip MessageHistory input processor if ObservationalMemory handles message loading
if (!hasMessageHistory && !hasObservationalMemory) {
processors.push(
new MessageHistory({View on GitHub (pinned to 75dd419e61)
Solutions
- Attach a storage adapter to Memory config, e.g. storage: new LibSQLStore({ url: 'file:memory.db' }).
- Or configure storage on the parent Mastra instance so Memory inherits it.
- If history recall is not needed, remove the lastMessages option.
Example fix
// before
const memory = new Memory({ options: { lastMessages: 10 } });
// after
const memory = new Memory({
storage: new LibSQLStore({ url: 'file:memory.db' }),
options: { lastMessages: 10 },
}); Defensive patterns
Strategy: validation
Validate before calling
function assertLastMessagesStorage(memoryConfig) {
if (memoryConfig?.options?.lastMessages && !memoryConfig?.storage) {
throw new Error('lastMessages requires a storage adapter on Memory (or inherited from Mastra)');
}
} Prevention
- Treat lastMessages and storage as a mandatory pair in Memory configs.
- Set storage once on the Mastra instance and register Memory there.
- Add startup validation that constructs Memory with production config before serving traffic.
When it happens
Trigger: Setting options.lastMessages to a number (or true) on a Memory instance that has no storage adapter attached directly or inherited from the Mastra instance, then running an agent turn that builds input processors.
Common situations: Adding lastMessages to an existing Memory after upgrade without adding storage; Mastra instance lacking storage; test scaffolding with options-only Memory.
Related errors
- Storage is not configured on this AgentController
- Storage does not have a memory domain configured
- Memory is not configured on this AgentController
- Memory requires a storage provider to function. Add a storag
- WORKING_MEMORY_MISSING_STORAGE_ADAPTER
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/1900aba634a29a50.
Report an issue: GitHub.