{"record":{"id":"d1b6254b258bde65","repo":"mastra-ai/mastra","slug":"agent-agent-id-does-not-have-memory-configure","errorCode":null,"errorMessage":"Agent \"${agent.id}\" does not have memory configured","messagePattern":"Agent \"(.+?)\" does not have memory configured","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/conversations.ts","lineNumber":65,"sourceCode":"  path: '/v1/conversations',\n  responseType: 'json',\n  bodySchema: createConversationBodySchema,\n  responseSchema: conversationObjectSchema,\n  summary: 'Create a conversation',\n  description: 'Creates a new thread-backed conversation for agent-backed Responses API requests',\n  tags: ['Responses'],\n  requiresAuth: true,\n  requiresPermission: MastraFGAPermissions.AGENTS_CREATE,\n  handler: async ({ mastra, requestContext, agent_id, conversation_id, resource_id, title, metadata }) => {\n    try {\n      if (!mastra) {\n        throw new HTTPException(500, { message: 'Mastra instance is required for conversations' });\n      }\n\n      const agent = await getAgentFromSystem({ mastra, agentId: agent_id });\n      const memory = await agent.getMemory({ requestContext });\n      if (!memory) {\n        throw new HTTPException(400, { message: `Agent \"${agent.id}\" does not have memory configured` });\n      }\n      if (!(await getAgentMemoryStore({ agent, requestContext }))) {\n        throw new HTTPException(400, { message: `Memory storage is not configured for agent \"${agent.id}\"` });\n      }\n\n      const threadId = conversation_id ?? randomUUID();\n      const resourceId = getEffectiveResourceId(requestContext, resource_id) ?? threadId;\n      const thread = await memory.createThread({\n        threadId,\n        resourceId,\n        title,\n        metadata,\n      });\n\n      return buildConversationObject({ thread });\n    } catch (error) {\n      return handleError(error, 'Error creating conversation');\n    }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/conversations.ts#L47-L83","documentation":"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.","triggerScenarios":"POSTing to the create-conversation route with an agent_id whose Agent definition was constructed without a `memory` option, so getMemory() returns undefined/null.","commonSituations":"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.","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"],"exampleFix":"// before\nconst agent = new Agent({ name: 'bot', instructions: '...' });\n// after\nconst agent = new Agent({ name: 'bot', instructions: '...', memory: new Memory({ storage }) });","handlingStrategy":"type-guard","validationCode":"const agent = mastra.getAgent(agentId);\nif (!agent || !(await agent.getMemory())) {\n  throw new Error(`Agent \"${agentId}\" has no memory; conversation APIs unavailable`);\n}","typeGuard":"function agentHasMemory(a: Agent | undefined): a is Agent & { getMemory(): Promise<Memory> } {\n  return !!a && typeof a.getMemory === 'function' && aHasMemoryConfig(a);\n}\n// simpler runtime check:\nasync function memoryConfigured(a: Agent) { return (await a.getMemory()) != null; }","tryCatchPattern":"try {\n  const conv = await client.createConversation({ agent_id });\n} catch (e) {\n  if (e.status === 400 && /does not have memory configured/.test(e.message)) {\n    // fall back to stateless generate/stream for this agent\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["memory","http-400","agent-configuration","conversations"],"backgroundTag":"agent-memory-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}