Feat/a2a expose usage metadata#27288
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enables token usage tracking for the Gemini Code Assist feature by exposing usageMetadata from the agent's streaming responses. By capturing these metrics at the end of a task and including them in the final status update, the system can now provide users with visibility into their context window utilization. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request implements token usage tracking in the Task class of the a2a-server package. It adds a usageMetadata field to store token counts, captures this information from GeminiEventType.Finished events, and includes it in the final status update metadata. A corresponding test case was added to task.test.ts to ensure correct functionality. I have no feedback to provide.
Summary
This PR introduces the functionality to expose
usageMetadatafrom the Gemini API's streaming responses within thea2a-serverin agent mode.Details
Changes:
a2a-serverto extractusageMetadata.usageMetadataobject in the final event sent to the client.Reasoning:
This change is required to enable token usage tracking and display in Gemini Code Assist, providing users with insights into context window utilization.
Related Issues
Fixes b/436499242 # Internal contribution for GCA feature
How to Validate
bash npm test -w @google/gemini-cli-a2a-serverPre-Merge Checklist