GC Agent KV Blobs silently skips all deletion forever because of one corrupt blob (and never logs which one)

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

“GC Agent KV Blobs” never deletes anything if a single blob fails to decode, and it never logs which one. My state.vscdb had grown to 25 GB (agentKv:blob ~17 GB) and Cursor was laggy. Two GC runs both ended with “541,397 total, 377,710 live, 0 deleted (1 errors)” and “[AgentKvGC] Skipping deletion: reachability walk hit 1 errors”. Each run’s full compaction also ballooned the WAL file to ~25 GB, temporarily dropping my C: drive from 60 GB free to 34 GB.

Separately, long sessions make the whole app laggy. Starting a session is easy, but I want one session to own a whole workstream, and chats of ~600-800 turns (~1 GB stored each) push INP to ~370 ms. Summarizing doesn’t help, because the full history stays stored and loaded.

Steps to Reproduce

  1. Have a chat that contains one corrupt agentKv:blob. In my case it was an agent.v1.ConversationStep (10 KB) that failed to decode with “premature EOF”. A length byte had been replaced by EF BF BD (U+FFFD), which looks like it went through a text-encoding round trip at some point.
  2. Run “GC Agent KV Blobs”.
  3. Result: 0 deleted (1 errors). The log doesn’t name the composer or blob, so this can’t be fixed from the UI.
  4. I replicated the reachability walk myself, found that one blob, and replaced it with the empty marker (0x00). The next GC run deleted 173,869 blobs, and state.vscdb went from 25.1 GB to 11.2 GB.

Expected Behavior

  1. Log the composer ID and blob key for every reachability error.
  2. Don’t let one undecodable blob block the whole GC. Treat it as a leaf, skip it, or offer to repair it.
  3. Warn about free disk space before the full compaction, since the WAL temporarily grows to roughly the size of the whole DB.
  4. Fix whatever is corrupting step blobs and duplicating conversations (the self-fork / resume:“self” bloat).
  5. Lazy-load long chats, and let compaction actually shrink stored history, so a single long-lived session stays fast.

Operating System

Windows 10/11

Version Information

Version: 3.24.18
VSCode Version: 1.128.0
Commit: be4c9e5350d77747b42cd467cbd3370a753d4640
Date: 2026-10-13T18:12:58.182Z
OS: Windows 11 Insider Preview 10.0.26340

Additional Information

Windows 11, state.vscdb in %APPDATA%\Cursor\User\globalStorage. 1,257 composers, 645k bubbles, 541k agentKv blobs before the fix.

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey @Stan_Shih, thanks for the detailed report, and for tracking down the exact blob.

You read it correctly: when one stored step can’t be decoded, the cleanup counts it as an error, skips deleting anything for safety, and doesn’t say which entry caused it. Because the same entry fails on every run, nothing gets cleaned up until it’s repaired, which is what you saw. I’ve flagged this to the team, including the missing log detail, the “one bad entry blocks everything” behavior, and the free-space spike during compaction.

On the disk spike: GC Agent KV Blobs always rewrites the whole database at the end, even when it deletes nothing, so it can briefly need about the size of the database again (sometimes up to roughly double) in free space. Until that changes, it’s worth having that much headroom before running it.

The text-encoding damage you found inside a binary entry is useful too, and I’ve passed it along. If you remember how that chat was used (imported, synced, edited by a tool, or opened on another machine), let us know, since that could help find where the corruption came from.

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

I ran Developer: GC Agent KV Blobs on Windows. It completed with:

GC complete in 2072.8s (GC: 825.0s, compact: 1247.8s): 1,091,095 total, 720,476 live, 0 deleted, 160,678 unlisted message rows deleted, 102 message rows of deleted chats kept until a cleanup at least a week after they were first seen (3 errors)

After fully exiting Cursor, state.vscdb is still about 34 GB. Could you clarify whether the 3 errors caused blob deletion to be skipped, and provide a supported way to identify and repair the failing records without damaging retained chats? The completion log does not identify them.

Cursor version: 3.25.6 (user setup)

Steps to Reproduce

Not sure.

Expected Behavior

The database should be much smaller.

Operating System

Windows 10/11

Version Information

3.25.6 (user setup)

Does this stop you from using Cursor

No - Cursor works, but with this issue

Thanks Colin! Here’s what I could dig up about the corrupted chat (all read-only from state.vscdb):

  • It was a normal local IDE agent chat on Windows (agentType=ide, model grok-4.6), with no import, sync, or cloud flags. It was never resumed via the CLI, and no external tool wrote to the DB during that period.
  • The bad step was in an assistant message written on 2026-09-04 at 15:32 UTC (the 141st of 152 turns, step 10 of 10). The bubble JSON for that same message is intact. Only the agentKv ConversationStep blob was damaged: it had EF BF BD at 3 offsets, including offset 4, where a nested length varint should be (the original bytes were likely 9B 07, i.e. 923). I’ve since replaced that blob with a single 0x00 byte so GC could run; the original is kept in a backup.
  • The composer’s createdAt (2026-08-27 13:15 UTC) is about 14d 18h after its conversationStartedTimestampMs (2026-08-12 19:07 UTC).
  • On 2026-09-04 at 19:25 UTC, another composer was created that shares the exact same first 141 turn blobs as this chat, including the one pointing at the broken step. The chat also had 12 subagents.
  • I don’t know which Cursor build I was on, because logs from that period have already rotated away.

The damage pattern is exactly what you get when a nested binary field goes through a lossy UTF-8 decode/encode round-trip; I can reproduce the same bytes in Node. I couldn’t pin down which code path wrote it, though.

A rough heuristic scan also flagged a few other blobs with EF BF BD right after a length tag. I haven’t confirmed whether any of them are actually corrupt.

@Jan_Moravec Yes. Going by Colin’s reply above and what I found in Cursor’s GC code, any reachability error makes it skip all blob deletion. That’s why it says “0 deleted” even though about 370k blobs are unreachable. (The “unlisted message rows deleted” part is a separate cleanup, so that one still runs.)

In my case, the error came from a ConversationStep blob that exists but won’t decode. A missing blob doesn’t count as an error, only one that exists and fails to parse. I found mine by reimplementing the reachability walk with the protobuf schemas from Cursor’s bundle and logging every blob that failed to decode. Mine had EF BF BD bytes in it, which points to a lossy UTF-8 round trip.

Once I replaced that one blob with the empty marker (a single 0x00 byte), the next GC deleted 173k blobs, and the DB went from 25 GB to 11 GB. If you try this, fully quit Cursor first, back up each blob you change, and make sure you have about the DB’s size free (up to 2×) before rerunning GC.

There’s no supported tool for this yet, so hopefully the team adds logging of the failing keys.

Thank you, I agree, there should be official tools for that - backing-up, fixing and compacting the huge database.

Also, is there at least some tool for exporting the conversation so I can back them up? I would then just use new database.