Skip to content

[Bug]: /resume extreme RAM spike — unindexed conversations trigger full gen_metadata Protobuf BLOB deserialization #727

Open

Description

@chienhaoc

/resume causes extreme RAM spike (10GB+) before entering any conversation — triggered by AGY's fallback mechanism loading all unindexed conversation SQLite files including bloated gen_metadata Protobuf BLOBs into RAM.

Platform: AGY CLI (Windows)
Version: 1.1.9


Steps to Reproduce

  1. Use AGY with view_file on media/binary files, or run long conversations with heavy tool calls, across several subagent sessions
  2. Allow a number of conversation .db files to accumulate in brain/ over time (especially ones without entries in conversation_summaries.db)
  3. Start a fresh AGY session and run /resume
  4. Observe: RAM spikes to several GB before any conversation is selected or entered

Root Cause Analysis

Two compounding issues cause this:

1. Missing Conversation Summaries Index

When /resume is invoked, AGY reads conversation_summaries.db. If any past conversation has no index entry in that database, AGY's fallback mechanism opens every raw .db file under conversations/ and loads it into RAM for parsing.

In the affected installation: 99 total conversation files, 59 unindexed, with those 59 totalling 4.41 GB on disk.

2. Bloated gen_metadata Protobuf BLOBs (Snowballing Size)

For conversations involving view_file on media files or large tool call payloads, AGY serializes the complete Generation Metadata (protobuf object) into a BLOB in the gen_metadata SQLite table after every turn. Critically, each turn stores the cumulative context snapshot up to that point:

  • Turn 1: ~50 MB BLOB
  • Turn 2: ~150 MB BLOB
  • Turn 4–5: single SQLite column BLOB reaches 740 MB

When /resume hits an unindexed conversation, SQLite loads the entire BLOB chain into RAM and attempts full deserialization. With multiple such conversations, this consumes 10 GB+ RAM instantly — before any conversation is even opened.


Expected Behavior

  • /resume should never require loading full blob data to display the conversation list
  • Missing conversation_summaries.db entries should be gracefully skipped or lazy-loaded — not bulk-loaded
  • conversation_summaries.db should be automatically maintained as sessions complete, so the fallback path is never triggered under normal use

Workaround Applied (Self-diagnosed and fixed)

Manually applied a two-step fix in a separate clean session:

Step 1 — Rebuilt conversation_summaries.db index:
Parsed all 59 unindexed conversations and inserted their summary records. /resume now only reads the ~50 KB index file and responds in milliseconds.

Step 2 — Cleaned bloated gen_metadata BLOBs + SQLite VACUUM:
Removed oversized generation snapshot BLOBs from completed conversations and ran VACUUM to reclaim disk space.

Metric Before After
Total conversation storage 4.68 GB 0.25 GB
Disk space reclaimed — 4.43 GB
/resume load time Tens of seconds / crash < 0.05s
RAM usage on /resume Several GB ~0 MB overhead

Prevention Recommendation

The gen_metadata cumulative snapshot design combined with the unindexed-conversation fallback creates a ticking time bomb for any user who:

  • Uses view_file on media or binary files
  • Runs long conversations with many tool calls
  • Accumulates conversation history over time

Suggested fixes:

  1. Auto-maintain conversation_summaries.db on session end — eliminate the fallback entirely
  2. Cap or prune gen_metadata BLOBs per conversation (e.g., only keep last N snapshots)
  3. Store large binary payloads as separate files with references in SQLite, rather than inline BLOBs

Activity

  1. changed the title [-]/resume causes extreme RAM spike before entering any conversation — unindexed sessions trigger full gen_metadata blob loading[/-] [+][Bug]: /resume extreme RAM spike — unindexed conversations trigger full gen_metadata Protobuf BLOB deserialization[/+] on Aug 2, 2026
  2. added
    performancePerformance issues (e.g., hanging processes, infinite model loops, memory leak)
    subtype:windowsWindows specific issues (e.g., login links, PowerShell statusline)
    comp:conversationsManaging Conversations, Workspace Scoping, Resuming sessions, Branching
    1.1.9Issues related to 1.1.9
    on Aug 23, 2026
  3. rkecodist commented on Sep 10, 2026

    @rkecodist

    Can you share the script you used for "Step 2 — Cleaned bloated gen_metadata BLOBs + SQLite VACUUM" ?

  4. chandrashakherkamasani commented on Oct 14, 2026

    @chandrashakherkamasani
    Collaborator

    Hi all, this issue has been resolved in latest releases. Can you please update AGY CLI using agy update and let us know if you still see the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

1.1.9Issues related to 1.1.9comp:conversationsManaging Conversations, Workspace Scoping, Resuming sessions, BranchingperformancePerformance issues (e.g., hanging processes, infinite model loops, memory leak)subtype:windowsWindows specific issues (e.g., login links, PowerShell statusline)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions