{"record":{"id":"75e88924e5bdf532","repo":"mastra-ai/mastra","slug":"errormessage","errorCode":null,"errorMessage":"${errorMessage}","messagePattern":"\\$\\{errorMessage\\}","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/responses.ts","lineNumber":324,"sourceCode":"  if (!mastra) {\n    throw new HTTPException(500, { message: 'Mastra instance is required for agent-backed responses' });\n  }\n\n  return getAgentFromSystem({ mastra, agentId });\n}\n\nasync function resolveAgentMemoryStore({\n  agent,\n  requestContext,\n  errorMessage,\n}: {\n  agent: Agent<any, any, any, any>;\n  requestContext: RequestContext;\n  errorMessage: string;\n}): Promise<MemoryStorage> {\n  const agentMemoryStore = await getAgentMemoryStore({ agent, requestContext });\n  if (!agentMemoryStore) {\n    throw new HTTPException(400, { message: errorMessage });\n  }\n\n  return agentMemoryStore;\n}\n\n/**\n * Executes a non-streaming Responses API request through the resolved Mastra agent.\n */\nasync function executeGenerate({\n  agent,\n  resolvedModel,\n  modelOverride,\n  instructions,\n  text,\n  providerOptions,\n  input,\n  requestContext,\n  abortSignal,","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/responses.ts#L306-L342","documentation":"resolveAgentMemoryStore wraps getAgentMemoryStore and converts 'agent has no memory store' into a 400 carrying the caller-supplied errorMessage. It is thrown when an operation that requires persistence (e.g., storing a response turn or loading conversation history) targets an agent with no memory configured.","triggerScenarios":"Any responses flow requiring a MemoryStorage handle (history retrieval, thread persistence) where the agent resolved from agent_id has no memory instance attached.","commonSituations":"Same as memory-not-configured: agent defined without new Memory({ storage }); storage omitted in a refactor; targeting the wrong agent_id.","solutions":["Attach memory to the agent: memory: new Memory({ storage: <MastraStorage> })","Remove the persistence-requiring option from the request (e.g., don't pass conversation_id / rely on stored history) if stateless use is intended","Confirm agent_id refers to the intended memory-backed agent"],"exampleFix":"// before\nnew Agent({ name: 'bot', model: 'openai/gpt-4o', instructions: 'x' });\n// after\nnew Agent({ name: 'bot', model: 'openai/gpt-4o', instructions: 'x', memory: new Memory({ storage }) });","handlingStrategy":"validation","validationCode":"const memory = await agent.getMemory({ requestContext });\nif (!memory) throw new Error('This operation requires the agent to have memory configured');","typeGuard":"null","tryCatchPattern":"try {\n  await op();\n} catch (e) {\n  if (e?.status === 400 && /memory/i.test(e.message)) {\n    // fall back to stateless mode or fix agent config\n  }\n  throw e;\n}","preventionTips":["Attach Memory with a storage backend to all agents requiring persistence","Assert memory presence in CI for memory-dependent flows","Avoid persistence-requiring request options for stateless agents"],"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"}