docs(hooks): document all three usageMetadata token fields for LLMResponse#28146
docs(hooks): document all three usageMetadata token fields for LLMResponse#28146abhay-codes07 wants to merge 1 commit into
Conversation
…ponse
The hooks reference documented the stable `LLMResponse.usageMetadata` as
`{ totalTokenCount }`, but the hook-facing translator
(`toHookLLMResponse` in `packages/core/src/hooks/hookTranslator.ts`)
forwards `promptTokenCount` and `candidatesTokenCount` as well, and the
exported `LLMResponse` interface declares all three. Update the schema in
the reference so the documented stable API matches the fields a
BeforeModel/AfterModel hook actually receives.
Fixes google-gemini#28048
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 updates the hooks reference documentation to accurately reflect the usageMetadata structure provided to BeforeModel and AfterModel hooks. By documenting all three available token fields, it ensures developers have access to the full token breakdown provided by the underlying implementation, preventing confusion regarding available data. 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 updates the documentation in docs/hooks/reference.md to expand the usageMetadata schema definition, adding promptTokenCount and candidatesTokenCount fields alongside the existing totalTokenCount field. There are no review comments, and I have no feedback to provide.
Note: Security Review has been skipped due to the limited scope of the PR.
|
📊 PR Size: size/XS
|
Summary
The hooks reference documents the stable
LLMResponse.usageMetadataschema as a single field:But a
BeforeModel/AfterModelhook actually receives three token fields. The hook-facing translatortoHookLLMResponse()inpackages/core/src/hooks/hookTranslator.tsbuilds:and the exported
LLMResponseinterface in the same file declares all three. Since this section is explicitly presented as the stable API hooks can rely on, the reference should list every field the hook is handed — otherwise integrators assume onlytotalTokenCountis available and miss the input/output token breakdown the code already provides.Change
Expand the
usageMetadataschema indocs/hooks/reference.mdto match the interface and translator:Docs-only change;
prettier --checkpasses.Fixes #28048