ai-devkit icon indicating copy to clipboard operation
ai-devkit copied to clipboard

fix(agent-manager): Gemini sessions written as session-*.jsonl (Gemini CLI 0.46+) are never detected

Open codeaholicguy opened this issue 2 months ago • 0 comments

Problem

Current Gemini CLI versions (observed with 0.46) write chat sessions as session-<timestamp>-<id>.jsonl. GeminiSessionLocator.isSessionFile (packages/agent-manager/src/providers/gemini/GeminiSessionLocator.ts) only accepts files ending in .json:

return fileName.startsWith(SESSION_FILE_PREFIX) && fileName.endsWith(".json");

So sessions from current Gemini versions are never discovered. Live Gemini agents show up with no session, summary or preview, and agent sessions doesn't list them.

The format is also different. It isn't one JSON document; it's a log:

  • line 1 is a metadata record (sessionId, projectHash, startTime, lastUpdated, kind);
  • later lines are update records such as {"$set": {"messages": [...]}}.

GeminiSessionParser only understands the single-document .json format.

Found while working on #263.

Proposed approach

  • Accept both session-*.json (legacy) and session-*.jsonl in discovery and history listing.
  • Read sessionId and projectHash for .jsonl from line 1, using the bounded head read introduced in #263.
  • Parse the .jsonl log by applying the update records in order (at least $set; check which other operators Gemini emits) to rebuild the session. That feeds parseSession / getConversation and the summary.
  • Where it fits, reuse the incremental utility (#256) and the tail reader (#260) for the .jsonl format.

Acceptance criteria

  • [ ] Live discovery and listSessions / findSessionsById find session-*.jsonl files.
  • [ ] Session metadata for .jsonl comes from line 1 with a bounded read (≤ 64 KiB).
  • [ ] Parsing a .jsonl log (metadata plus $set updates) gives the same session, messages and summary as the equivalent .json document (fixture test with both formats).
  • [ ] Unknown update operators are ignored without crashing, and a test covers that.
  • [ ] Legacy .json sessions still work (existing tests pass).
  • [ ] Fixtures are synthetic, modelled on the real record shapes, with no real session content.

codeaholicguy avatar Sep 28 '26 11:09 codeaholicguy