Problem
GeminiSessionLocator.discoverSessions (packages/agent-manager/src/providers/gemini/GeminiSessionLocator.ts) runs for Gemini processes not already cached in the registry.
- It walks every
~/.gemini/tmp/<id>/chats/ directory and readFileSyncs every chat file in full (readCandidateSession).
- It keeps all of their contents in
contentCache at once.
- There is no date window, so every refresh costs O(total Gemini history) in both bytes read and peak memory.
Proposed approach
- Skip
chats/ directories that can't belong to a live process, using the project-hash ↔ cwd mapping that is already computed (cwdHashMap), before reading any file.
- Consider only files whose mtime is at or after the earliest candidate process start time (with some slack).
- Extract
projectHash and sessionId from a bounded head read where the format allows; otherwise cache the parsed metadata keyed by path, inode, size and mtime.
- Remove
contentCache; matched sessions are parsed once and cached by the same key.
Acceptance criteria
Problem
GeminiSessionLocator.discoverSessions(packages/agent-manager/src/providers/gemini/GeminiSessionLocator.ts) runs for Gemini processes not already cached in the registry.~/.gemini/tmp/<id>/chats/directory andreadFileSyncs every chat file in full (readCandidateSession).contentCacheat once.Proposed approach
chats/directories that can't belong to a live process, using the project-hash ↔ cwd mapping that is already computed (cwdHashMap), before reading any file.projectHashandsessionIdfrom a bounded head read where the format allows; otherwise cache the parsed metadata keyed by path, inode, size and mtime.contentCache; matched sessions are parsed once and cached by the same key.Acceptance criteria
contentCacheis removed or bounded.