💎 fix: Handle usage_metadata in Title Transaction for Gemini Models (#12386)

* fix: handle `usage_metadata` in title transaction for Gemini models

Gemini models return token usage via `usage_metadata` instead of `usage`
or `tokenUsage`. The `collectedUsage` mapping in `titleConvo` only
handled the latter two, causing title generation transactions to be
silently skipped for Gemini. Adds an `else if (item.usage_metadata)`
branch to extract `input_tokens`/`output_tokens`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: remove trailing whitespace in usage_metadata handler

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
kojinseok-del 2026-04-15 23:09:37 +09:00 committed by GitHub
parent 6183303653
commit edd4c6d60c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1120,6 +1120,9 @@ class AgentClient extends BaseClient {
} else if (item.tokenUsage) {
input_tokens = item.tokenUsage.promptTokens;
output_tokens = item.tokenUsage.completionTokens;
} else if (item.usage_metadata) {
input_tokens = item.usage_metadata.input_tokens;
output_tokens = item.usage_metadata.output_tokens;
}
return {