{"record":{"id":"82f0c8af2c500aac","repo":"can1357/oh-my-pi","slug":"cursor-blob-not-found","errorCode":null,"errorMessage":"Cursor blob not found","messagePattern":"Cursor blob not found","errorType":"validation","errorClass":"AIError.ValidationError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/providers/cursor.ts","lineNumber":4564,"sourceCode":"\tif (output.usage.contextTokens !== usedTokens) {\n\t\toutput.usage.contextTokens = usedTokens;\n\t}\n}\n\nfunction createBlobId(data: Uint8Array): Uint8Array {\n\treturn new Uint8Array(createHash(\"sha256\").update(data).digest());\n}\n\nfunction storeCursorBlob(blobStore: Map<string, Uint8Array>, data: Uint8Array): Uint8Array {\n\tconst blobId = createBlobId(data);\n\tblobStore.set(Buffer.from(blobId).toString(\"hex\"), data);\n\treturn blobId;\n}\n\nfunction readCursorBlob(blobStore: Map<string, Uint8Array>, blobId: Uint8Array): Uint8Array {\n\tconst data = blobStore.get(Buffer.from(blobId).toString(\"hex\"));\n\tif (!data) {\n\t\tthrow new AIError.ValidationError(\"Cursor blob not found\");\n\t}\n\treturn data;\n}\n\n/**\n * Cursor AgentService reconstructs the model prompt from `requestContext.rules`,\n * not from the client-supplied `rootPromptMessagesJson` system blobs. Map each\n * OMP system-prompt entry to a global CursorRule so always-apply rules survive\n * that reconstruction.\n */\nexport function buildCursorRequestContextRules(systemPrompt: readonly string[] | undefined): CursorRule[] {\n\treturn normalizeSystemPrompts(systemPrompt).map((content, index) =>\n\t\tcreate(CursorRuleSchema, {\n\t\t\tfullPath: `/omp/system-prompt/${index}.mdc`,\n\t\t\tcontent,\n\t\t\tsource: CursorRuleSource.USER,\n\t\t\ttype: create(CursorRuleTypeSchema, {\n\t\t\t\ttype: {","sourceCodeStart":4546,"sourceCodeEnd":4582,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/ai/src/providers/cursor.ts#L4546-L4582","documentation":"Cursor's AgentService protocol references prompt blobs by id; readCursorBlob looks the id up in the per-conversation in-memory blob store and throws ValidationError when nothing is stored under that hex key. The blob needed to reconstruct the request is missing, so the conversation cannot continue.","triggerScenarios":"Reading a blob id that was never written to the store for the current conversation — e.g. continuing a conversation whose blob store was discarded (process restart), referencing a blob from a different conversationId, or a stale/rotated conversation id mapping to a fresh empty Map.","commonSituations":"Server restart wiping the in-memory conversationBlobStores while conversation ids persist; resuming a session across processes; a blob id serialized/mismatched (hex vs raw bytes) so lookup misses.","solutions":["Start a new conversation/session so blobs are written to a fresh store before being referenced.","Keep the conversation and its blob store alive in the same process for the conversation's duration; persist blobs externally if sessions must survive restarts.","Verify the blob id key encoding matches (hex string of the Uint8Array) on both write and read.","Ensure conversationId rotation logic copies blob store entries to the rotated id."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"if (!conversationBlobStores.get(conversationId)?.has(Buffer.from(blobId).toString(\"hex\"))) {\n  // blob missing — start a fresh conversation instead of continuing\n}","typeGuard":"null","tryCatchPattern":"try {\n  await streamCursor(model, ctx, { conversationId, ...options });\n} catch (err) {\n  if (err instanceof AIError.ValidationError && err.message === \"Cursor blob not found\") {\n    // restart with a new conversationId (fresh blob store)\n    return streamCursor(model, ctx, { conversationId: crypto.randomUUID(), ...options });\n  }\n  throw err;\n}","preventionTips":["Persist blobs alongside conversation state if sessions must survive restarts.","Keep conversation lifetime tied to its in-process blob store.","Copy blob entries when rotating conversation ids."],"tags":["cursor","state","blob-storage","validation"],"backgroundTag":"missing-blob-reference","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}