mastra-ai/mastra · error · HTTPException
Memory storage is not configured for agent "${agent.id}"
Error message
Memory storage is not configured for agent "${agent.id}" What it means
Beyond having a Memory instance, the agent's memory must have a storage backend for conversations to persist threads and messages. The handler calls getAgentMemoryStore and throws HTTP 400 when the memory's storage is not configured.
Source
Thrown at packages/server/src/server/handlers/conversations.ts:68
responseSchema: conversationObjectSchema,
summary: 'Create a conversation',
description: 'Creates a new thread-backed conversation for agent-backed Responses API requests',
tags: ['Responses'],
requiresAuth: true,
requiresPermission: MastraFGAPermissions.AGENTS_CREATE,
handler: async ({ mastra, requestContext, agent_id, conversation_id, resource_id, title, metadata }) => {
try {
if (!mastra) {
throw new HTTPException(500, { message: 'Mastra instance is required for conversations' });
}
const agent = await getAgentFromSystem({ mastra, agentId: agent_id });
const memory = await agent.getMemory({ requestContext });
if (!memory) {
throw new HTTPException(400, { message: `Agent "${agent.id}" does not have memory configured` });
}
if (!(await getAgentMemoryStore({ agent, requestContext }))) {
throw new HTTPException(400, { message: `Memory storage is not configured for agent "${agent.id}"` });
}
const threadId = conversation_id ?? randomUUID();
const resourceId = getEffectiveResourceId(requestContext, resource_id) ?? threadId;
const thread = await memory.createThread({
threadId,
resourceId,
title,
metadata,
});
return buildConversationObject({ thread });
} catch (error) {
return handleError(error, 'Error creating conversation');
}
},
});
View on GitHub (pinned to 75dd419e61)
Solutions
- Construct Memory with a storage backend: new Memory({ storage: new LibSQLStore({ url: ... }) }) or your preferred storage adapter
- Verify the storage adapter is correctly instantiated and its connection (DB URL/token) is valid
- Share one storage instance across agents if conversations should be portable, and confirm it is the one wired into the agent
- Check env vars for the storage connection are present at server start
Example fix
// before
memory: new Memory({ options: { lastMessages: 10 } })
// after
memory: new Memory({ storage: new LibSQLStore({ url: process.env.DATABASE_URL }), options: { lastMessages: 10 } }) Defensive patterns
Strategy: validation
Validate before calling
const memory = await agent.getMemory();
if (!memory) throw new Error('No memory configured');
if (!memory.constructor.name.includes('Memory')) throw new Error('Unexpected memory type');
// storage is required for conversations:
const mem = new Memory({ storage: resolveStorageFromEnv() }); // ensure storage present at construction Type guard
function memoryHasStorage(m: Memory | undefined): boolean {
return !!m && 'storage' in m && m.storage != null;
} Try / catch
try {
const conv = await client.createConversation({ agent_id });
} catch (e) {
if (e.status === 400 && /storage is not configured/.test(e.message)) {
console.error('Wire a storage adapter into Memory for this agent');
}
throw e;
} Prevention
- Always pass storage when constructing Memory for conversation-backed agents
- Share a single configured storage instance across agents
- Assert storage presence in an environment/config startup check
- Keep storage credentials in env and validate at boot
When it happens
Trigger: POSTing to create-conversation for an agent whose Memory was constructed without a `storage` option (in-memory only or none), so getAgentMemoryStore resolves to undefined.
Common situations: Memory created only with options (working memory/lastMessages) but no storage in dev setups; storage intentionally omitted for tests then the agent is used with the conversations API; switching deployments and forgetting to wire storage (e.g. LibSQL/Postgres/Upstash) into Memory.
Related errors
- Agent "${agent.id}" does not have memory configured
- Memory storage is not initialized
- @mastra/opencode: failed to initialize memory storage from $
- sendStateSignal could not load thread ${threadId}
- Storage is not configured on this AgentController
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/6c0ac57c4c16ddb3.
Report an issue: GitHub.