{"record":{"id":"91aea48066882364","repo":"mastra-ai/mastra","slug":"claudesdkagent-resumedata-must-include-sessionid-o","errorCode":null,"errorMessage":"ClaudeSDKAgent resumeData must include sessionId or continue: true.","messagePattern":"ClaudeSDKAgent resumeData must include sessionId or continue: true\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent-sdks/claude/src/index.ts","lineNumber":263,"sourceCode":"  if (hasSessionId && hasContinue) {\n    throw new Error('ClaudeSDKAgent resumeData must include either sessionId or continue: true, not both.');\n  }\n\n  if (hasSessionId) {\n    if (typeof resumeData.sessionId !== 'string') {\n      throw new Error('ClaudeSDKAgent resumeData.sessionId must be a string.');\n    }\n    return resumeData;\n  }\n\n  if (hasContinue) {\n    if (resumeData.continue !== true) {\n      throw new Error('ClaudeSDKAgent resumeData.continue must be true when provided.');\n    }\n    return resumeData;\n  }\n\n  throw new Error('ClaudeSDKAgent resumeData must include sessionId or continue: true.');\n}\n\nfunction createClaudeResumeRunOptions<OUTPUT>(\n  resumeData: ClaudeSDKAgentResumeData,\n  options?: ClaudeSDKAgentRunOptions<OUTPUT>,\n): ClaudeSDKAgentRunOptions<OUTPUT> {\n  const sdkOptions: ClaudeSDKOptions = { ...options?.sdkOptions };\n\n  if ('sessionId' in resumeData && typeof resumeData.sessionId === 'string') {\n    sdkOptions.resume = resumeData.sessionId;\n    if (resumeData.forkSession !== undefined) {\n      sdkOptions.forkSession = resumeData.forkSession;\n    }\n    if (resumeData.resumeSessionAt !== undefined) {\n      sdkOptions.resumeSessionAt = resumeData.resumeSessionAt;\n    }\n  } else {\n    sdkOptions.continue = true;","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/agent-sdks/claude/src/index.ts#L245-L281","documentation":"ClaudeSDKAgent.resume() requires resumeData that either carries a sessionId (to restore a previous Claude Agent SDK session) or has continue set to true (to continue the most recent conversation). validateClaudeResumeData throws this when neither is present, meaning the agent has no conversation context to resume from.","triggerScenarios":"Calling claudeSDKAgent.resume({ ... }) with an empty object, with an object missing both sessionId and continue, or with continue set to a value other than true (which triggers the sibling 'continue must be true' error first).","commonSituations":"Persisting only the thread/model metadata instead of the Claude sessionId when checkpointing a conversation; hand-constructing resumeData after a restart; copying resume patterns from other agent SDKs where resumeData shape differs.","solutions":["Pass the sessionId returned from the previous ClaudeSDKAgent run in resumeData.","If you want to continue the latest conversation instead, pass { continue: true } (exactly true, not truthy).","Verify the saved resumeData shape before resuming — it must satisfy ClaudeSDKAgentResumeData with at least one of sessionId or continue: true."],"exampleFix":"// before\nawait agent.resume({ threadId });\n// after\nawait agent.resume({ sessionId: savedState.sessionId });","handlingStrategy":"validation","validationCode":"function canResumeClaude(data: unknown): data is { sessionId?: string; continue?: true } {\n  return typeof data === 'object' && data !== null &&\n    (('sessionId' in data) || (data as any).continue === true);\n}\nif (!canResumeClaude(saved)) throw new Error('No sessionId or continue:true saved');\nawait agent.resume(saved);","typeGuard":"function isClaudeResumeData(v: unknown): v is ClaudeSDKAgentResumeData {\n  if (typeof v !== 'object' || v === null) return false;\n  const d = v as Record<string, unknown>;\n  return (typeof d.sessionId === 'string') || d.continue === true;\n}","tryCatchPattern":"try {\n  await agent.resume(saved);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('resumeData must include sessionId')) {\n    // fall back to starting a fresh conversation\n    await agent.generate(prompt);\n  } else throw e;\n}","preventionTips":["Always persist the sessionId returned by the prior Claude run at checkpoint time.","Use continue: true when you intentionally want the latest conversation rather than a stored session.","Unit-test your resume-data serialization/deserialization round trip."],"tags":["resume","validation","argument-validation","claude"],"backgroundTag":"invalid-resume-data","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}