mastra-ai/mastra · error · HTTPException
Agent "${agent.id}" does not have memory configured
Error message
Agent "${agent.id}" does not have memory configured What it means
Creating a conversation requires the target agent to have Memory configured, since conversations are backed by memory threads. The handler resolves the agent via getAgentFromSystem, calls agent.getMemory(), and throws HTTP 400 if the agent has no memory instance.
Source
Thrown at packages/server/src/server/handlers/conversations.ts:65
path: '/v1/conversations',
responseType: 'json',
bodySchema: createConversationBodySchema,
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
- Add memory to the agent: new Agent({ ..., memory: new Memory({ options: {...} }) })
- Target a different agent_id that has memory configured
- If conversations are not needed for this agent, use the stateless generate/stream APIs instead
- Verify the agent ID resolves to the intended agent (typo check) via the agents list endpoint
Example fix
// before
const agent = new Agent({ name: 'bot', instructions: '...' });
// after
const agent = new Agent({ name: 'bot', instructions: '...', memory: new Memory({ storage }) }); Defensive patterns
Strategy: type-guard
Validate before calling
const agent = mastra.getAgent(agentId);
if (!agent || !(await agent.getMemory())) {
throw new Error(`Agent "${agentId}" has no memory; conversation APIs unavailable`);
} Type guard
function agentHasMemory(a: Agent | undefined): a is Agent & { getMemory(): Promise<Memory> } {
return !!a && typeof a.getMemory === 'function' && aHasMemoryConfig(a);
}
// simpler runtime check:
async function memoryConfigured(a: Agent) { return (await a.getMemory()) != null; } Try / catch
try {
const conv = await client.createConversation({ agent_id });
} catch (e) {
if (e.status === 400 && /does not have memory configured/.test(e.message)) {
// fall back to stateless generate/stream for this agent
}
throw e;
} Prevention
- Give every agent that powers UI conversations a Memory instance
- Validate agent definitions in a unit test (getMemory() non-null)
- Keep agent IDs in one typed registry to avoid targeting the wrong agent
- Document which agents are conversation-capable
When it happens
Trigger: POSTing to the create-conversation route with an agent_id whose Agent definition was constructed without a `memory` option, so getMemory() returns undefined/null.
Common situations: Agents built for stateless use cases being targeted by the playground/API conversation features; memory removed from an agent during refactoring; calling create-conversation against the wrong agent ID; new Agent({}) without memory in a minimal setup.
Related errors
- Memory storage is not configured for agent "${agent.id}"
- Both threadId or resourceId must be provided
- Observational Memory is not enabled for this agent
- Memory is not configured for this agent
- Memory storage is not initialized
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/d1b6254b258bde65.
Report an issue: GitHub.