fix: extract thoughtsTokenCount for Gemini thinking models#5604
fix: extract thoughtsTokenCount for Gemini thinking models#5604colegottdank wants to merge 1 commit intomainfrom
Conversation
- Add reasoning_tokens extraction from Gemini usageMetadata.thoughtsTokenCount in worker's getDetailedUsage() - Add reasoningTokens to GoogleBodyProcessor output in Jawn - Fix promptTokens calculation when no caching is present (was returning undefined instead of raw promptTokenCount) This fixes incorrect token counting and cost calculations for Gemini thinking models (2.5 Flash, 3.x Pro) where thoughtsTokenCount was not being stored separately. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Claude finished @colegottdank's task —— View job PR Review: Gemini Thinking Tokens ExtractionReviewing changes for:
AnalysisChanges Overview:
Detailed Review✅ Code Quality - Excellent
✅ Test Coverage - Comprehensive
✅ Performance & Security - No Issues
✅ API Consistency - Backward Compatible
Score: 9/10 - Excellent implementation, ready to mergeMinor Suggestions:
Suggestions Summary:
Recommendation: Merge with confidence. This PR correctly fixes a significant gap in Gemini thinking model token tracking and includes proper testing. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Summary
reasoning_tokensextraction from GeminiusageMetadata.thoughtsTokenCountin worker'sgetDetailedUsage()reasoningTokenstoGoogleBodyProcessoroutput in JawnpromptTokenscalculation when no caching is present (was returningundefinedinstead of rawpromptTokenCount)Problem
Gemini thinking models (2.5 Flash, 3.x Pro) return
thoughtsTokenCountseparately fromcandidatesTokenCount:This caused:
Test plan
thoughtsTokenCount🤖 Generated with Claude Code