Skip to content

fix: Correct usage metadata mapping#426

Merged
VisargD merged 1 commit into
Portkey-AI:mainfrom
kiran-4444:fix/usage-metadata-mapping
May 7, 2026
Merged

fix: Correct usage metadata mapping#426
VisargD merged 1 commit into
Portkey-AI:mainfrom
kiran-4444:fix/usage-metadata-mapping

Conversation

@kiran-4444
Copy link
Copy Markdown
Contributor

@kiran-4444 kiran-4444 commented Apr 22, 2026

Title: Correct usage metadata mapping to responses output
Related Issues: Pylon-4888 (3)

Copy link
Copy Markdown

Copilot AI left a 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 updates the Google ADK integration’s _usage_to_metadata mapping so Portkey Responses usage fields are translated into google.genai.types.GenerateContentResponseUsageMetadata with explicit handling for cached tokens and reasoning (“thoughts”) tokens.

Changes:

  • Switch from simple getattr(...) token extraction to a dict-based extraction via usage.model_dump().
  • Add mapping for cached input tokens and reasoning tokens, and split output tokens into completion vs thoughts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread portkey_ai/integrations/adk.py
Comment thread portkey_ai/integrations/adk.py
Comment thread portkey_ai/integrations/adk.py
Comment thread portkey_ai/integrations/adk.py
@VisargD VisargD merged commit 45c8352 into Portkey-AI:main May 7, 2026
10 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.

4 participants