fix: resolve Gemini CLI 0.37.0 session capture failures (#1664) (#1692)

Three root causes prevented Gemini sessions from persisting prompts,
observations, and summaries:

1. BeforeAgent was mapped to user-message (display-only) instead of
   session-init (which initialises the session and starts the SDK agent).

2. The transcript parser expected Claude Code JSONL (type: "assistant")
   but Gemini CLI 0.37.0 writes a JSON document with a messages array
   where assistant entries carry type: "gemini". extractLastMessage now
   detects the format and routes to the correct parser, preserving
   full backward compatibility with Claude Code JSONL transcripts.

3. The summarize handler omitted platformSource from the
   /api/sessions/summarize request body, causing sessions to be recorded
   without the gemini-cli source tag.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Ben Younes
2026-04-15 09:58:20 +02:00
committed by GitHub
parent 544e9d39f5
commit 983be42998
5 changed files with 321 additions and 4 deletions
@@ -80,7 +80,7 @@ const HOOK_TIMEOUT_MS = 10000;
*/
const GEMINI_EVENT_TO_INTERNAL_EVENT: Record<string, string> = {
'SessionStart': 'context',
'BeforeAgent': 'user-message',
'BeforeAgent': 'session-init',
'AfterAgent': 'observation',
'BeforeTool': 'observation',
'AfterTool': 'observation',