Skip to content

Conversation

@shelvick
Copy link
Contributor

Summary

  • Fixed typo in gemini.ex: thinkingTokenCountthoughtsTokenCount (field name was wrong so reasoning tokens were never extracted)
  • Google Gemini thinking tokens are now included in cost calculation (they were being ignored because Gemini reports them separately from candidatesTokenCount)

Scope

This fix is Google Gemini-specific only. All other providers (OpenAI, Azure OpenAI, Anthropic, etc.) maintain their current behavior unchanged via a conservative default (add_reasoning_to_cost: false).

Test plan

  • All 1887 tests pass
  • New tests verify Gemini reasoning tokens are costed when add_reasoning_to_cost: true
  • New tests verify default behavior unchanged (reasoning NOT added to cost)
  • mix quality passes

shelvick and others added 2 commits January 15, 2026 00:08
Fixes two issues with Google Gemini on Vertex AI:

1. Typo fix: `thinkingTokenCount` → `thoughtsTokenCount` in gemini.ex
   The field name was wrong so reasoning tokens were never extracted.

2. Gemini thinking tokens weren't being costed because they're reported
   separately from output tokens (candidatesTokenCount excludes
   thoughtsTokenCount).

This fix is Google Gemini-specific only. All other providers maintain
their current behavior unchanged via a conservative default
(add_reasoning_to_cost: false).
The original implementation had a bug where is_google_gemini_format()
checked for 'thoughtsTokenCount' key, but providers already normalize
this to 'reasoning_tokens' before normalize_usage() runs.

This fix:
- Has Google/Vertex Gemini providers set add_reasoning_to_cost: true
  explicitly in their extract_usage/2 callbacks
- Updates normalize_usage() to preserve provider-set flags via
  get_add_reasoning_to_cost() helper
- Adds comprehensive tests for the usage normalization pipeline
@mikehostetler mikehostetler merged commit eaca283 into agentjido:main Jan 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants