{"record":{"id":"b2069c76a76321c8","repo":"mastra-ai/mastra","slug":"failed-to-rehydrate-registry-entry-for-run-runid","errorCode":null,"errorMessage":"Failed to rehydrate registry entry for run ${runId}. Cannot resume.","messagePattern":"Failed to rehydrate registry entry for run (.+?)\\. Cannot resume\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/durable/durable-agent.ts","lineNumber":1997,"sourceCode":"        : undefined;\n      const memory = threadId\n        ? {\n            ...options?.memory,\n            thread: threadId,\n            resource: resourceId ?? options?.memory?.resource,\n          }\n        : options?.memory;\n\n      await this.prepare([], {\n        ...(options as AgentExecutionOptions<TOutput>),\n        runId,\n        requestContext: options?.requestContext ?? snapshotRequestContext,\n        memory,\n      });\n      entry = this.#runRegistry.get(runId);\n    }\n    if (!entry) {\n      throw new Error(`Failed to rehydrate registry entry for run ${runId}. Cannot resume.`);\n    }\n\n    const memoryInfo = this.#runRegistry.getMemoryInfo(runId);\n    const registeredMemory = memoryInfo?.threadId\n      ? ({\n          ...options?.memory,\n          thread: memoryInfo.threadId,\n          resource: memoryInfo.resourceId ?? options?.memory?.resource,\n        } as DurableAgentStreamOptions<TOutput>['memory'])\n      : options?.memory;\n\n    const resolvedOptions = (await this.#resolveExecutionOptions({\n      ...(options as DurableAgentStreamOptions<TOutput>),\n      requestContext:\n        options?.requestContext ??\n        (entry.requestContext as DurableAgentStreamOptions<TOutput>['requestContext'] | undefined),\n      memory: registeredMemory ?? options?.memory,\n    })) as DurableAgentResumeOptions<TOutput>;","sourceCodeStart":1979,"sourceCodeEnd":2015,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/durable/durable-agent.ts#L1979-L2015","documentation":"After loading the persisted snapshot and calling prepare() to rebuild non-serializable runtime state, the code re-reads the in-memory run registry. If the entry still isn't there, rehydration failed and this Error is thrown from durable-agent.ts:1997.","triggerScenarios":"prepare() did not register the run (e.g. internal setup failed silently or skipped registration); a concurrent resume raced the rehydration pass; the run registry dropped the entry immediately after rehydration (TTL/eviction); getWorkflowRunById returned a snapshot but the workflow registration itself is missing on this Mastra instance.","commonSituations":"Resuming a run for a durable workflow that isn't registered in the current Mastra instance's workflow map; racing resume() calls from multiple handlers right after a process restart; registry cleared by hot reload in dev.","solutions":["Ensure the durable agentic-loop workflow is registered on the Mastra instance used at resume time.","Avoid calling resume() concurrently for the same runId; serialize resumes or gate on run state.","Retry the resume once — transient rehydration races often succeed on a second attempt.","If it persists, check prepare()/internal registration logs and upgrade to a version with the rehydration fix."],"exampleFix":"// before\nawait agent.resume(runId, data);\n// after\ntry {\n  await agent.resume(runId, data);\n} catch (e) {\n  if (String(e).includes('Failed to rehydrate registry entry')) await new Promise(r => setTimeout(r, 250)) || await agent.resume(runId, data);\n  throw e;\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"let lastErr;\nfor (let i = 0; i < 3; i++) {\n  try { return await agent.resume(runId, data); }\n  catch (e) {\n    if (!String(e).includes('Failed to rehydrate registry entry')) throw e;\n    lastErr = e;\n    await new Promise(r => setTimeout(r, 200 * (i + 1)));\n  }\n}\nthrow lastErr;","preventionTips":["Serialize resume calls for the same runId.","Register the durable workflow on the Mastra instance before resuming.","Avoid hot-reload patterns that clear the in-memory run registry mid-run."],"tags":["durable-agent","resume","rehydration","registry"],"backgroundTag":"rehydration-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}