{"record":{"id":"8e4751b770e201bb","repo":"mastra-ai/mastra","slug":"conversation-id-requires-the-target-agent-to-have","errorCode":null,"errorMessage":"conversation_id requires the target agent to have memory configured","messagePattern":"conversation_id requires the target agent to have memory configured","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/responses.ts","lineNumber":201,"sourceCode":"\n  if (previousResponseTurnRecord) {\n    return {\n      threadId: previousResponseTurnRecord.thread.id,\n      resourceId: previousResponseTurnRecord.thread.resourceId,\n    };\n  }\n\n  const effectiveThreadId = getEffectiveThreadId(requestContext, undefined);\n  const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n  if (!store && !conversationId && !effectiveThreadId) {\n    return null;\n  }\n\n  const memory = await agent.getMemory({ requestContext });\n  if (!memory) {\n    if (conversationId) {\n      throw new HTTPException(400, {\n        message: 'conversation_id requires the target agent to have memory configured',\n      });\n    }\n\n    return null;\n  }\n\n  if (conversationId) {\n    const existingThread = await memory.getThreadById({ threadId: conversationId });\n    if (!existingThread) {\n      throw new HTTPException(404, { message: `Conversation ${conversationId} was not found` });\n    }\n\n    await enforceThreadAccess({\n      mastra: agent.getMastraInstance(),\n      requestContext,\n      threadId: conversationId,\n      thread: existingThread,","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/responses.ts#L183-L219","documentation":"conversation_id implies server-side conversation persistence, which only works when the target agent has memory configured. resolveThreadExecutionContext checks agent.getMemory(); if no memory is configured and conversation_id was supplied, it rejects the request with this 400 instead of silently dropping the conversation.","triggerScenarios":"POST /api/responses with body.conversation_id set while the resolved agent (from body.agent_id) was created without a memory instance.","commonSituations":"Adding conversation_id to an existing client call after switching to an agent that has no Memory configured; forgetting to pass memory when constructing the Agent; an agent defined in a config file where memory wiring was omitted.","solutions":["Configure memory on the agent: new Memory({ storage }) passed in the Agent constructor","Remove conversation_id from the request if persistence is not needed","Verify agent.getMemory() resolves for the agent_id you are targeting (it is resolved per-request via requestContext)","Confirm you are hitting the agent you think — agent_id typos can resolve a different, memory-less agent"],"exampleFix":"// before\nnew Agent({ name: 'support', instructions: '...', model: 'openai/gpt-4o' });\n// after\nnew Agent({ name: 'support', instructions: '...', model: 'openai/gpt-4o', memory: new Memory({ storage: new LibSQLStore({ url: process.env.DATABASE_URL }) }) });","handlingStrategy":"validation","validationCode":"const memory = await agent.getMemory({ requestContext });\nif (!memory && body.conversation_id) throw new Error('conversation_id set but agent has no memory');","typeGuard":"function supportsConversation(agent) { return typeof agent.getMemory === 'function'; }","tryCatchPattern":"null","preventionTips":["Configure memory on every agent exposed via /api/responses","Add a startup assertion that agent.getMemory() resolves","Keep agent_id → memory config in one shared definition"],"tags":["server","validation","memory","http-400"],"backgroundTag":"memory-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}