mastra-ai/mastra · error · MastraError
DURABLE_AGENT_RESUME_INVALID_SNAPSHOT
DURABLE_AGENT_RESUME_INVALID_SNAPSHOT
Error message
DurableAgent "${this.name}" resume(${runId}): persisted snapshot does not contain a durable-agent workflow input. What it means
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.
Source
Thrown at packages/core/src/agent/durable/durable-agent.ts:1954
const workflowsStore = await this.#mastra?.getStorage()?.getStore('workflows');
const persisted = await workflowsStore?.getWorkflowRunById({
runId,
workflowName: DurableStepIds.AGENTIC_LOOP,
});
if (!persisted) {
throw new Error(`No registry entry found for run ${runId}. Cannot resume.`);
}
const snapshot =
typeof persisted.snapshot === 'string'
? (JSON.parse(persisted.snapshot) as WorkflowRunState)
: persisted.snapshot;
if (snapshot?.status !== 'suspended') {
throw new Error('This workflow run was not suspended');
}
const workflowInput = snapshot?.context?.input as DurableAgenticWorkflowInput | undefined;
if (!workflowInput || workflowInput.__workflowKind !== 'durable-agent') {
throw new MastraError({
id: 'DURABLE_AGENT_RESUME_INVALID_SNAPSHOT',
domain: ErrorDomain.AGENT,
category: ErrorCategory.SYSTEM,
text: `DurableAgent "${this.name}" resume(${runId}): persisted snapshot does not contain a durable-agent workflow input.`,
details: { agentName: this.name, runId },
});
}
if (workflowInput.agentId !== this.id) {
throw new MastraError({
id: 'DURABLE_AGENT_RESUME_AGENT_MISMATCH',
domain: ErrorDomain.AGENT,
category: ErrorCategory.USER,
text: `DurableAgent "${this.name}" resume(${runId}): persisted run belongs to agent "${workflowInput.agentId}", not "${this.id}".`,
details: { agentName: this.name, runId, ownerAgentId: workflowInput.agentId },
});
}
const messageListMemoryInfo = (View on GitHub (pinned to 75dd419e61)
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.
Defensive patterns
Strategy: type-guard
Validate before calling
const snap = typeof persisted.snapshot === 'string' ? JSON.parse(persisted.snapshot) : persisted.snapshot; const kind = (snap as any)?.context?.input?.__workflowKind; if (kind !== 'durable-agent') return; // not a durable-agent run
Type guard
function isDurableAgentSnapshot(s: unknown): s is { context: { input: { __workflowKind: 'durable-agent' } } } {
return (s as any)?.context?.input?.__workflowKind === 'durable-agent';
} Try / catch
try {
await agent.resume(runId, data);
} catch (e) {
if ((e as any).id === 'DURABLE_AGENT_RESUME_INVALID_SNAPSHOT') {
// runId belongs to a non-durable run; route to the right API
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- DURABLE_AGENT_RECOVER_INVALID_SNAPSHOT
- DURABLE_AGENT_RECOVER_SNAPSHOT_NOT_FOUND
- Structure mismatch in snapshot: Expected: ${expectedStructu
- Snapshot has ${mismatches.length} mismatch${mismatches.lengt
- DURABLE_AGENT_RECOVER_ALREADY_IN_PROGRESS
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/20d786ac9d2b633e.
Report an issue: GitHub.