{"record":{"id":"93d663f538f1c66f","repo":"mastra-ai/mastra","slug":"stored-responses-require-the-target-agent-to-have","errorCode":null,"errorMessage":"Stored responses require the target agent to have memory configured","messagePattern":"Stored responses require the target agent to have memory configured","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/responses.ts","lineNumber":745,"sourceCode":"            : 'conversation_id requires the target agent to have memory storage configured',\n      })\n    : null;\n  const configuredTools = mapMastraToolsToResponseTools(\n    (await Promise.resolve(agent.listTools({ requestContext }))) as Record<string, unknown>,\n  );\n\n  const responseId = createMessageId();\n  const createdAt = Math.floor(Date.now() / 1000);\n  const threadContext = await resolveThreadExecutionContext({\n    agent,\n    store: shouldStore,\n    conversationId: body.conversation_id,\n    previousResponseTurnRecord,\n    requestContext,\n  });\n\n  if (shouldStore && !threadContext) {\n    throw new HTTPException(400, {\n      message: 'Stored responses require the target agent to have memory configured',\n    });\n  }\n\n  const didStore = shouldStore && Boolean(threadContext);\n\n  return {\n    agent,\n    agentMemoryStore,\n    configuredTools,\n    createdAt,\n    didStore,\n    executionInput,\n    previousResponseTurnRecord,\n    resolvedModel,\n    responseId,\n    responseModel,\n    responseMetadata: {","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/responses.ts#L727-L763","documentation":"The responses route rejects a request with store:true when the target agent has no memory configured, so no threadContext could be established to persist the response turn. The server returns HTTP 400 because storing responses requires a memory-backed thread.","triggerScenarios":"POST to the responses route with body.store=true (or body.conversation_id / body.previous_response_id implying persistence) against an agent created without a Memory instance.","commonSituations":"Following the OpenAI responses API convention (store defaults true there) but the Mastra agent was built without memory; new Agent({ memory: undefined }) in a minimal agent; copying example code that assumes memory is wired.","solutions":["Attach a Memory instance (backed by storage) to the agent, then retry.","If persistence is not needed, explicitly send store:false and omit conversation_id/previous_response_id.","Verify the memory/storage package is installed and passed to the Agent constructor."],"exampleFix":"// before\nnew Agent({ name: 'a', instructions: 'i', model: 'openai/gpt-4o' })\n// after\nnew Agent({ name: 'a', instructions: 'i', model: 'openai/gpt-4o', memory: new Memory({ storage: new LibSQLStore({ url: 'file:./mastra.db' }) }) })","handlingStrategy":"validation","validationCode":"// only request storage if the agent has memory\nif ((body.store || body.conversation_id || body.previous_response_id) && !agentHasMemory(agentId)) {\n  // either attach memory server-side or strip persistence fields\n  body = { ...body, store: false, conversation_id: undefined, previous_response_id: undefined };\n}","typeGuard":"function canStore(agent: Agent): boolean {\n  return Boolean((agent as { memory?: unknown }).memory);\n}","tryCatchPattern":"try {\n  return await client.createResponse(body);\n} catch (e) {\n  if (isHttpError(e, 400) && /memory configured/.test(e.message)) {\n    return client.createResponse({ ...body, store: false });\n  }\n  throw e;\n}","preventionTips":["Give every agent that needs conversation history a Memory instance with storage.","Send store:false explicitly when persistence is unwanted (don't rely on defaults).","Keep a registry of which agents have memory before enabling store."],"tags":["http-400","memory","responses-api","configuration"],"backgroundTag":"memory-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}