{"record":{"id":"246d043c7096dd93","repo":"mastra-ai/mastra","slug":"storage-is-not-configured-on-this-agentcontroller","errorCode":null,"errorMessage":"Storage is not configured on this AgentController","messagePattern":"Storage is not configured on this AgentController","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/agent-controller/agent-controller.ts","lineNumber":978,"sourceCode":"    }\n  }\n\n  private async runInit(): Promise<void> {\n    await this.initStorage();\n\n    // Propagate harness-level Mastra, memory, workspace, browser, and pubsub\n    // to the agent(s) that back each mode. Workspaces initialize lazily when used.\n    for (const agent of this.backingAgents()) {\n      this.propagateRuntimeServicesToAgent(agent);\n    }\n\n    this.startIntervals();\n  }\n\n  private async getMemoryStorage(): Promise<MemoryStorage> {\n    const storage = this.#resolveStorage();\n    if (!storage) {\n      throw new Error('Storage is not configured on this AgentController');\n    }\n    const memoryStorage = await storage.getStore('memory');\n    if (!memoryStorage) {\n      throw new Error('Storage does not have a memory domain configured');\n    }\n    return memoryStorage;\n  }\n\n  /**\n   * The shared-host storage gateway the Session's thread domain reads/writes\n   * through. The Session owns the thread-domain logic; this adapter maps raw\n   * storage rows to AgentController types and uses the active session only when\n   * resolving configured memory for a clone.\n   */\n  private createThreadDataStore(session: Session<TState>): ThreadDataStore {\n    return {\n      listThreads: ({ resourceId, includeForkedSubagents, metadata }) =>\n        this.queryThreads({ resourceId, includeForkedSubagents, metadata }),","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent-controller/agent-controller.ts#L960-L996","documentation":"getMemoryStorage resolves the AgentController's storage gateway and throws when no storage is configured at all. Memory operations (threads, messages) require a storage backend; without one the controller cannot serve memory APIs.","triggerScenarios":"Calling memoryStorage/memory/result/createMessagesList... style APIs on an AgentController constructed without a storage (or memory) entry in its config, so #resolveStorage() returns undefined.","commonSituations":"Creating an AgentController for stateless/streaming-only use and later invoking memory-dependent methods; forgetting the storage option in config; environment-specific config where storage is only set in production.","solutions":["Configure storage on the AgentController config (e.g. new MastraStorage-backed store) before calling memory APIs","Alternatively provide config.memory so memory access goes through the memory instance instead of raw storage","Guard the call site: check whether storage is configured (or wrap in try/catch) when memory is optional in your host"],"exampleFix":"// before\nconst controller = new AgentController({ instructions: '...' });\nconst threads = await controller.memory.listThreads({ resourceId });\n// after\nconst controller = new AgentController({\n  instructions: '...',\n  storage: new MastraStorage({ store: new LibSQLStore({ url: process.env.DATABASE_URL }) }),\n});","handlingStrategy":"validation","validationCode":"if (!controller.config.storage) throw new Error('Controller requires storage for memory APIs');","typeGuard":"function hasStorage(c): c is typeof c & { storage: NonNullable<typeof c.storage> } {\n  return !!c.storage;\n}","tryCatchPattern":"try {\n  const storage = await controller.memoryStorage;\n  return await storage.listThreads({ resourceId });\n} catch (e) {\n  if (e instanceof Error && /Storage is not configured/.test(e.message)) return [];\n  throw e;\n}","preventionTips":["Always pass storage when the controller will serve memory/thread APIs","Centralize controller construction in one factory so config can't drift per call site","Assert required config at startup with a fail-fast check"],"tags":["configuration","storage","memory"],"backgroundTag":"storage-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}