{"record":{"id":"1775fbc85fd961e8","repo":"vercel/ai","slug":"invalid-deep-agents-conversation-checkpoint","errorCode":null,"errorMessage":"Invalid Deep Agents conversation checkpoint","messagePattern":"Invalid Deep Agents conversation checkpoint","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/harness-deepagents/src/bridge/persistent-memory-saver.ts","lineNumber":75,"sourceCode":"        decodeBytes(fields[4]),\n        decodeBytes(fields[5]),\n        fields[6] === '' ? undefined : decodeString(fields[6]),\n      ];\n      continue;\n    }\n    if (fields[0] === 'W' && fields.length === 6) {\n      const [, keyValue, indexValue, taskIdValue, channelValue, value] = fields;\n      const key = decodeString(keyValue);\n      const index = decodeString(indexValue);\n      writes[key] ??= Object.create(null);\n      writes[key][index] = [\n        decodeString(taskIdValue),\n        decodeString(channelValue),\n        decodeBytes(value),\n      ];\n      continue;\n    }\n    throw new Error('Invalid Deep Agents conversation checkpoint');\n  }\n\n  saver.storage = storage;\n  saver.writes = writes;\n}\n\nexport async function saveMemorySaver({\n  path,\n  saver,\n}: {\n  path: string;\n  saver: MemorySaver;\n}): Promise<void> {\n  const lines = [SNAPSHOT_HEADER];\n\n  for (const [threadId, namespaces] of Object.entries(saver.storage)) {\n    for (const [namespace, checkpoints] of Object.entries(namespaces)) {\n      for (const [","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-deepagents/src/bridge/persistent-memory-saver.ts#L57-L93","documentation":"Within a v1 snapshot, every data line must be either an `S` record (checkpoint storage: 7 tab-separated fields) or a `W` record (pending writes: 6 fields), all values base64-encoded. Any line with an unexpected record type or wrong field count makes the snapshot invalid and the bridge throws instead of loading partial memory.","triggerScenarios":"Loading a `conversation.checkpoint` whose body contains a malformed line — corrupted bytes, a line with missing/extra tab-separated fields, non-base64 payloads breaking field counts, or manual edits to the file.","commonSituations":"Disk corruption or truncation of the checkpoint file; external tools (formatters, sync tools) rewriting the file and changing tabs/newlines; hand-merging snapshots; writing the file on a system that mangles encoding.","solutions":["Delete the corrupted `conversation.checkpoint` (`.agent-runs/<sessionId>/bridge/`) and start a new session — in-memory state cannot be partially trusted.","Restore the checkpoint from a backup taken while the session was healthy.","Check for tools (editors, sync clients) that may have re-encoded the file (e.g. changed tabs to spaces or line endings) and exclude it from them.","Verify disk health / filesystem integrity if corruption recurs."],"exampleFix":"// remove corrupted checkpoint\nrm .agent-runs/<sessionId>/bridge/conversation.checkpoint","handlingStrategy":"fallback","validationCode":"const lines = (await readFile(path, 'utf8').catch(() => '')).split('\\n').filter(Boolean);\nconst ok = lines.slice(1).every(l => {\n  const f = l.split('\\t');\n  return (f[0] === 'S' && f.length === 7) || (f[0] === 'W' && f.length === 6);\n});","typeGuard":null,"tryCatchPattern":"try {\n  await resumeSession();\n} catch (error) {\n  if (error instanceof Error && error.message.includes('Invalid Deep Agents conversation checkpoint')) {\n    // delete corrupted checkpoint and start a new session\n  }\n  throw error;\n}","preventionTips":["Exclude the bridge state dir from editors/sync tools","Keep checkpoints on reliable storage","Take backups of healthy checkpoints","Don't manually merge or edit snapshots"],"tags":["persistence","corruption","checkpoint"],"backgroundTag":"checkpoint-corrupted","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}