mastra-ai/mastra · error · HTTPException
Memory is not configured for this agent
Error message
Memory is not configured for this agent
What it means
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.
Source
Thrown at packages/server/src/server/handlers/memory.ts:696
return {
record: recordResult.record ? toLocalOMRecord(recordResult.record) : null,
history: historyResult.records?.length > 0 ? historyResult.records.map(toLocalOMRecord) : undefined,
};
}
// No threadId or resourceId yet (e.g. /chat/new) — return empty
return { record: null, history: undefined };
}
const omConfig = await getOMConfigFromAgent(agent, requestContext);
if (!omConfig?.enabled) {
throw new HTTPException(400, { message: 'Observational Memory is not enabled for this agent' });
}
// Get storage from the agent's memory (not mastra.getStorage())
// This ensures we use the same storage the agent uses for OM
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
if (!memory) {
throw new HTTPException(400, { message: 'Memory is not configured for this agent' });
}
let memoryStore: MemoryStorage | undefined;
try {
memoryStore = await memory.storage.getStore('memory');
} catch {
throw new HTTPException(400, { message: 'Memory storage is not initialized' });
}
if (!memoryStore) {
throw new HTTPException(400, { message: 'Memory storage is not initialized' });
}
// Determine the resourceId to use
const effectiveResourceId = resourceId;
if (!effectiveResourceId) {
throw new HTTPException(400, { message: 'resourceId is required for observational memory lookup' });
}
View on GitHub (pinned to 75dd419e61)
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.
Example fix
// before
new Agent({ name: 'helper', instructions }) // no memory -> 400
// after
new Agent({ name: 'helper', instructions, memory }); Defensive patterns
Strategy: type-guard
Validate before calling
const agent = mastra.getAgent(agentId);
const memory = await agent?.getMemory?.();
if (!memory) throw new Error(`Agent '${agentId}' has no Memory attached; required for OM history`); Type guard
function hasMemory(a: Agent | undefined): a is Agent & { getMemory(): Promise<Memory> } {
return !!a && typeof (a as any).getMemory === 'function';
} Try / catch
try {
const history = await fetchOmHistory(agentId);
} catch (e) {
if (isHttpError(e, 400) && /Memory is not configured/.test(e.message)) {
// attach memory to the agent or stop requesting OM history for it
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Observational Memory is not enabled for this agent
- Stored responses require the target agent to have memory con
- sendStateSignal requires Mastra memory
- Storage is not configured on this AgentController
- Storage does not have a memory domain configured
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/6d14a7dc72cd4747.
Report an issue: GitHub.