{"record":{"id":"7cfe05f0510db215","repo":"mastra-ai/mastra","slug":"durable-agent-recover-no-storage","errorCode":"DURABLE_AGENT_RECOVER_NO_STORAGE","errorMessage":"DurableAgent \"${this.name}\" recover() requires persistent storage to load the run snapshot. Register the agent on a Mastra instance with persistent storage (e.g. PostgreSQL, LibSQL).","messagePattern":"DurableAgent \"(.+?)\" recover\\(\\) requires persistent storage to load the run snapshot\\. Register the agent on a Mastra instance with persistent storage \\(e\\.g\\. PostgreSQL, LibSQL\\)\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/durable/durable-agent.ts","lineNumber":2346,"sourceCode":"   * ```\n   */\n  async recover(\n    runId: string,\n    options?: DurableAgentRecoverOptions<TOutput>,\n  ): Promise<DurableAgentStreamResult<TOutput>> {\n    if (!this.#mastra) {\n      throw new MastraError({\n        id: 'DURABLE_AGENT_RECOVER_NO_MASTRA',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        text: `DurableAgent \"${this.name}\" recover() requires the agent to be registered on a Mastra instance.`,\n        details: { agentName: this.name, runId },\n      });\n    }\n\n    const workflowsStore = await this.#mastra.getStorage()?.getStore('workflows');\n    if (!workflowsStore) {\n      throw new MastraError({\n        id: 'DURABLE_AGENT_RECOVER_NO_STORAGE',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        text:\n          `DurableAgent \"${this.name}\" recover() requires persistent storage to load the run snapshot. ` +\n          `Register the agent on a Mastra instance with persistent storage (e.g. PostgreSQL, LibSQL).`,\n        details: { agentName: this.name, runId },\n      });\n    }\n\n    // 1. Validate the persisted durable-agent input before claiming ownership\n    //    so obvious caller errors fail fast.\n    let workflowInput = await this.#loadRecoverableWorkflowInput(workflowsStore, runId);\n\n    // 2. Claim recovery ownership before resolving any live dependencies so a\n    //    concurrent caller cannot finish first and leave this attempt using a\n    //    stale snapshot.\n    const abortController = new AbortController();","sourceCodeStart":2328,"sourceCodeEnd":2364,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/durable/durable-agent.ts#L2328-L2364","documentation":"recover() must load the run snapshot from persistent storage via mastra.getStorage()?.getStore('workflows'). If no storage is configured (or the storage exposes no workflows store), MastraError DURABLE_AGENT_RECOVER_NO_STORAGE is thrown, advising persistent storage such as PostgreSQL or LibSQL.","triggerScenarios":"Creating a Mastra instance without the storage option and calling recover(); configuring storage that doesn't implement the workflows store; passing an in-memory/volatile storage where the snapshot has already been evicted so the store lookup fails.","commonSituations":"Dev environments defaulting to no storage while production uses Postgres; misconfigured DATABASE_URL so the storage adapter never initializes; swapping storage backends between runs of the app.","solutions":["Configure persistent storage: new Mastra({ storage: new PostgresStore({ ... }) }) (or LibSQL/Upstash etc.).","Verify getStorage() returns an instance and that the same storage was used when the run was created.","Check the storage connection config (DATABASE_URL etc.) — a failed adapter init can leave storage undefined.","For tests, use a file-backed or persistent-compatible store rather than pure in-memory."],"exampleFix":"// before\nconst mastra = new Mastra({ agents: { helper: agent } });\nawait mastra.getAgent('helper').recover(runId); // throws\n// after\nconst mastra = new Mastra({ agents: { helper: agent }, storage: new PostgresStore({ connectionString: process.env.DATABASE_URL }) });\nawait mastra.getAgent('helper').recover(runId);","handlingStrategy":"validation","validationCode":"if (!mastra.getStorage()?.getStore('workflows')) {\n  throw new Error('Durable agent recovery requires persistent storage');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agent.recover(runId);\n} catch (e) {\n  if ((e as any).id === 'DURABLE_AGENT_RECOVER_NO_STORAGE') {\n    // configure storage before retrying\n  } else throw e;\n}","preventionTips":["Always configure storage (Postgres/LibSQL) for apps using durable agents.","Assert storage presence at app startup, not at recover time.","Validate DB connection env vars in a startup health check."],"tags":["durable-agent","recover","storage","configuration"],"backgroundTag":"missing-storage-config","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}