-
Notifications
You must be signed in to change notification settings - Fork 125
fix gemini tokenUsage in metadata.json for manual commit strategy #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes missing Gemini token usage calculation in the manual commit strategy's metadata.json. Previously, token usage was only calculated for Claude Code transcripts (JSONL format), but not for Gemini CLI transcripts (JSON format).
Changes:
- Added agent-specific token calculation that detects Gemini JSON format and uses the appropriate parser
- Removed TODO comments indicating the missing Gemini token usage implementation
- Imported the
geminiclipackage to access Gemini-specific token calculation
4869e39 to
653bd44
Compare
653bd44 to
43948cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Entire-Checkpoint: de97f1e9cd68
Entire-Checkpoint: 7e8913fc02f4
Entire-Checkpoint: 5448526d1c9e
Entire-Checkpoint: 021a892a9da1
4658987 to
318a41a
Compare
countTranscriptLines was added on main and referenced the deleted isGeminiJSONTranscript function. Replace call sites with the PR's countTranscriptItems(agentType, content), remove the redundant function and its test, and drop the unused geminicli import. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: eba6021005ae
Note
Medium Risk
Touches condensation logic that writes checkpoint metadata and changes transcript parsing/token accounting paths for multiple agent formats; mistakes could skew stored metadata or summaries but do not affect core git history or authentication/security.
Overview
Manual-commit condensation now threads
CheckpointTranscriptStartintoextractSessionDataand uses it to compute checkpoint-scoped token usage for both Claude (JSONL line offsets) and Gemini (JSON message indexes).Transcript processing is refactored to centralize format-aware counting (
countTranscriptItems), prompt extraction (extractUserPromptswith IDE-tag stripping), and token calculation (calculateTokenUsage), and commit summarization avoids line-slicing for Gemini transcripts to prevent malformed input.Tests are updated and expanded with new Gemini condensation coverage, including a multi-checkpoint regression test that verifies token usage only counts messages after the checkpoint start.
Written by Cursor Bugbot for commit 8bfa341. This will update automatically on new commits. Configure here.