mastra-ai/mastra · error
Storage is not configured on this AgentController
Error message
Storage is not configured on this AgentController
What it means
getMemoryStorage resolves the AgentController's storage gateway and throws when no storage is configured at all. Memory operations (threads, messages) require a storage backend; without one the controller cannot serve memory APIs.
Source
Thrown at packages/core/src/agent-controller/agent-controller.ts:978
}
}
private async runInit(): Promise<void> {
await this.initStorage();
// Propagate harness-level Mastra, memory, workspace, browser, and pubsub
// to the agent(s) that back each mode. Workspaces initialize lazily when used.
for (const agent of this.backingAgents()) {
this.propagateRuntimeServicesToAgent(agent);
}
this.startIntervals();
}
private async getMemoryStorage(): Promise<MemoryStorage> {
const storage = this.#resolveStorage();
if (!storage) {
throw new Error('Storage is not configured on this AgentController');
}
const memoryStorage = await storage.getStore('memory');
if (!memoryStorage) {
throw new Error('Storage does not have a memory domain configured');
}
return memoryStorage;
}
/**
* The shared-host storage gateway the Session's thread domain reads/writes
* through. The Session owns the thread-domain logic; this adapter maps raw
* storage rows to AgentController types and uses the active session only when
* resolving configured memory for a clone.
*/
private createThreadDataStore(session: Session<TState>): ThreadDataStore {
return {
listThreads: ({ resourceId, includeForkedSubagents, metadata }) =>
this.queryThreads({ resourceId, includeForkedSubagents, metadata }),View on GitHub (pinned to 75dd419e61)
Solutions
- Configure storage on the AgentController config (e.g. new MastraStorage-backed store) before calling memory APIs
- Alternatively provide config.memory so memory access goes through the memory instance instead of raw storage
- Guard the call site: check whether storage is configured (or wrap in try/catch) when memory is optional in your host
Example fix
// before
const controller = new AgentController({ instructions: '...' });
const threads = await controller.memory.listThreads({ resourceId });
// after
const controller = new AgentController({
instructions: '...',
storage: new MastraStorage({ store: new LibSQLStore({ url: process.env.DATABASE_URL }) }),
}); Defensive patterns
Strategy: validation
Validate before calling
if (!controller.config.storage) throw new Error('Controller requires storage for memory APIs'); Type guard
function hasStorage(c): c is typeof c & { storage: NonNullable<typeof c.storage> } {
return !!c.storage;
} Try / catch
try {
const storage = await controller.memoryStorage;
return await storage.listThreads({ resourceId });
} catch (e) {
if (e instanceof Error && /Storage is not configured/.test(e.message)) return [];
throw e;
} Prevention
- Always pass storage when the controller will serve memory/thread APIs
- Centralize controller construction in one factory so config can't drift per call site
- Assert required config at startup with a fail-fast check
When it happens
Trigger: Calling memoryStorage/memory/result/createMessagesList... style APIs on an AgentController constructed without a storage (or memory) entry in its config, so #resolveStorage() returns undefined.
Common situations: Creating an AgentController for stateless/streaming-only use and later invoking memory-dependent methods; forgetting the storage option in config; environment-specific config where storage is only set in production.
Related errors
- 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
- MESSAGE_HISTORY_MISSING_STORAGE_ADAPTER
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/246d043c7096dd93.
Report an issue: GitHub.