{"record":{"id":"20d786ac9d2b633e","repo":"mastra-ai/mastra","slug":"durable-agent-resume-invalid-snapshot","errorCode":"DURABLE_AGENT_RESUME_INVALID_SNAPSHOT","errorMessage":"DurableAgent \"${this.name}\" resume(${runId}): persisted snapshot does not contain a durable-agent workflow input.","messagePattern":"DurableAgent \"(.+?)\" resume\\((.+?)\\): persisted snapshot does not contain a durable-agent workflow input\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/durable/durable-agent.ts","lineNumber":1954,"sourceCode":"      const workflowsStore = await this.#mastra?.getStorage()?.getStore('workflows');\n      const persisted = await workflowsStore?.getWorkflowRunById({\n        runId,\n        workflowName: DurableStepIds.AGENTIC_LOOP,\n      });\n      if (!persisted) {\n        throw new Error(`No registry entry found for run ${runId}. Cannot resume.`);\n      }\n\n      const snapshot =\n        typeof persisted.snapshot === 'string'\n          ? (JSON.parse(persisted.snapshot) as WorkflowRunState)\n          : persisted.snapshot;\n      if (snapshot?.status !== 'suspended') {\n        throw new Error('This workflow run was not suspended');\n      }\n      const workflowInput = snapshot?.context?.input as DurableAgenticWorkflowInput | undefined;\n      if (!workflowInput || workflowInput.__workflowKind !== 'durable-agent') {\n        throw new MastraError({\n          id: 'DURABLE_AGENT_RESUME_INVALID_SNAPSHOT',\n          domain: ErrorDomain.AGENT,\n          category: ErrorCategory.SYSTEM,\n          text: `DurableAgent \"${this.name}\" resume(${runId}): persisted snapshot does not contain a durable-agent workflow input.`,\n          details: { agentName: this.name, runId },\n        });\n      }\n      if (workflowInput.agentId !== this.id) {\n        throw new MastraError({\n          id: 'DURABLE_AGENT_RESUME_AGENT_MISMATCH',\n          domain: ErrorDomain.AGENT,\n          category: ErrorCategory.USER,\n          text: `DurableAgent \"${this.name}\" resume(${runId}): persisted run belongs to agent \"${workflowInput.agentId}\", not \"${this.id}\".`,\n          details: { agentName: this.name, runId, ownerAgentId: workflowInput.agentId },\n        });\n      }\n\n      const messageListMemoryInfo = (","sourceCodeStart":1936,"sourceCodeEnd":1972,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/durable/durable-agent.ts#L1936-L1972","documentation":"When rehydrating a persisted run, DurableAgent expects snapshot.context.input to be a durable-agent workflow input carrying __workflowKind === 'durable-agent'. If the input is missing or has a different kind, the snapshot is not a durable-agent run and resume aborts with MastraError DURABLE_AGENT_RESUME_INVALID_SNAPSHOT.","triggerScenarios":"Passing the runId of a plain (non-durable) workflow run to DurableAgent.resume(); storage rows polluted or written by an older/incompatible schema version without __workflowKind; snapshot JSON hand-edited or partially migrated.","commonSituations":"Sharing one workflows table across durable agents and regular workflows and mixing up runIds; upgrading Mastra across a version where the durable snapshot shape changed without migrating stored rows; copying snapshot data between environments.","solutions":["Confirm the runId belongs to a run started via DurableAgent.stream()/generate(), not a plain Workflow run or base Agent run.","Check stored snapshot.context.input.__workflowKind directly to see what kind of run the id refers to.","If rows come from an older Mastra version, re-run them through a migration or discard them and start new runs.","Do not hand-edit persisted snapshots; recreate the run."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"const snap = typeof persisted.snapshot === 'string' ? JSON.parse(persisted.snapshot) : persisted.snapshot;\nconst kind = (snap as any)?.context?.input?.__workflowKind;\nif (kind !== 'durable-agent') return; // not a durable-agent run","typeGuard":"function isDurableAgentSnapshot(s: unknown): s is { context: { input: { __workflowKind: 'durable-agent' } } } {\n  return (s as any)?.context?.input?.__workflowKind === 'durable-agent';\n}","tryCatchPattern":"try {\n  await agent.resume(runId, data);\n} catch (e) {\n  if ((e as any).id === 'DURABLE_AGENT_RESUME_INVALID_SNAPSHOT') {\n    // runId belongs to a non-durable run; route to the right API\n  } else throw e;\n}","preventionTips":["Keep durable-agent runIds separate from plain workflow runIds.","Don't hand-edit or partially migrate persisted snapshots.","Run storage migrations when upgrading Mastra versions."],"tags":["durable-agent","snapshot","schema-mismatch"],"backgroundTag":"invalid-snapshot","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}