{"record":{"id":"6d14a7dc72cd4747","repo":"mastra-ai/mastra","slug":"memory-is-not-configured-for-this-agent","errorCode":null,"errorMessage":"Memory is not configured for this agent","messagePattern":"Memory is not configured for this agent","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/memory.ts","lineNumber":696,"sourceCode":"          return {\n            record: recordResult.record ? toLocalOMRecord(recordResult.record) : null,\n            history: historyResult.records?.length > 0 ? historyResult.records.map(toLocalOMRecord) : undefined,\n          };\n        }\n        // No threadId or resourceId yet (e.g. /chat/new) — return empty\n        return { record: null, history: undefined };\n      }\n\n      const omConfig = await getOMConfigFromAgent(agent, requestContext);\n      if (!omConfig?.enabled) {\n        throw new HTTPException(400, { message: 'Observational Memory is not enabled for this agent' });\n      }\n\n      // Get storage from the agent's memory (not mastra.getStorage())\n      // This ensures we use the same storage the agent uses for OM\n      const memory = await getMemoryFromContext({ mastra, agentId, requestContext });\n      if (!memory) {\n        throw new HTTPException(400, { message: 'Memory is not configured for this agent' });\n      }\n\n      let memoryStore: MemoryStorage | undefined;\n      try {\n        memoryStore = await memory.storage.getStore('memory');\n      } catch {\n        throw new HTTPException(400, { message: 'Memory storage is not initialized' });\n      }\n      if (!memoryStore) {\n        throw new HTTPException(400, { message: 'Memory storage is not initialized' });\n      }\n\n      // Determine the resourceId to use\n      const effectiveResourceId = resourceId;\n      if (!effectiveResourceId) {\n        throw new HTTPException(400, { message: 'resourceId is required for observational memory lookup' });\n      }\n","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/memory.ts#L678-L714","documentation":"Thrown after OM is confirmed enabled when `agent.getMemory()` returns null/undefined — i.e., the agent has no Memory instance attached, so there is no storage to read OM records/history from. The endpoint requires an agent-level Memory configuration.","triggerScenarios":"OM history route where the agent was created without a `memory` option (or with memory explicitly null), yet an OM history request is made for it.","commonSituations":"Agents built purely for tool-less workflows without Memory; constructor refactor accidentally dropping the `memory` option; passing an agent id that resolves to a different, memory-less agent.","solutions":["Attach a Memory instance to the agent: `new Agent({ ..., memory })`.","If the agent shouldn't have memory, remove the OM history calls for it.","Verify the resolved agentId is the one you intended (not a similarly-named memory-less agent).","Check DI/conditional code that may skip setting memory in this environment."],"exampleFix":"// before\nnew Agent({ name: 'helper', instructions }) // no memory -> 400\n// after\nnew Agent({ name: 'helper', instructions, memory });","handlingStrategy":"type-guard","validationCode":"const agent = mastra.getAgent(agentId);\nconst memory = await agent?.getMemory?.();\nif (!memory) throw new Error(`Agent '${agentId}' has no Memory attached; required for OM history`);","typeGuard":"function hasMemory(a: Agent | undefined): a is Agent & { getMemory(): Promise<Memory> } {\n  return !!a && typeof (a as any).getMemory === 'function';\n}","tryCatchPattern":"try {\n  const history = await fetchOmHistory(agentId);\n} catch (e) {\n  if (isHttpError(e, 400) && /Memory is not configured/.test(e.message)) {\n    // attach memory to the agent or stop requesting OM history for it\n  }\n  throw e;\n}","preventionTips":["Always pass a Memory instance when constructing agents used with memory/OM features.","Add a startup check that every OM-enabled agent resolves a Memory instance.","Avoid duplicated agent names that could resolve to a memory-less agent."],"tags":["memory","configuration","http-400"],"backgroundTag":"memory-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}