Skip to content

fix(core): record response's modelVersion in session transcript#25633

Open
nadja-y wants to merge 1 commit intogoogle-gemini:mainfrom
nadja-y:pr-model-version-session
Open

fix(core): record response's modelVersion in session transcript#25633
nadja-y wants to merge 1 commit intogoogle-gemini:mainfrom
nadja-y:pr-model-version-session

Conversation

@nadja-y
Copy link
Copy Markdown

@nadja-y nadja-y commented Apr 18, 2026

Fixes #25632.

GeminiChat.processStreamResponse wrote the pre-request resolved model to the session record, ignoring chunk.modelVersion from the server. On aliasing / A/B routing the two diverge, and uiTelemetry.hydrate() keys per-model stats on message.model.

Aligned with LoggingContentGenerator which already uses responses[0]?.modelVersion || req.model for telemetry.

@nadja-y nadja-y requested a review from a team as a code owner April 18, 2026 19:50
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 ensures that the session transcript accurately reflects the model version returned by the server during streaming responses. By capturing the model version from the response chunks, the system correctly handles scenarios where aliasing or A/B routing causes the actual model used to diverge from the requested model, ensuring consistency in telemetry and logging.

Highlights

  • Model Version Tracking: Introduced logic to capture the model version directly from the stream response chunks.
  • Session Recording Update: Updated the session recording service to prioritize the observed model version from the response over the initial request model.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. 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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces logic to capture the specific model version from the response stream in GeminiChat, ensuring that the recorded message reflects the actual model used rather than the initial request model. A potential runtime error was identified where the code attempts to access a property on a potentially null or undefined stream chunk.

Comment thread packages/core/src/core/geminiChat.ts Outdated
@nadja-y nadja-y force-pushed the pr-model-version-session branch from b7937f3 to dd91275 Compare April 18, 2026 19:56
@gemini-cli gemini-cli bot added the area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality label Apr 18, 2026
GeminiChat.processStreamResponse wrote the pre-request resolved model to
the session record, ignoring chunk.modelVersion from the server. On
aliasing / A/B routing the two diverge, and uiTelemetry.hydrate() keys
per-model stats on message.model.

Align with LoggingContentGenerator which already uses
responses[0]?.modelVersion || req.model for telemetry.

Fixes google-gemini#25632
@nadja-y nadja-y force-pushed the pr-model-version-session branch from dd91275 to aa34b29 Compare April 18, 2026 20:38
@nadja-y nadja-y changed the title core: record response's modelVersion in session transcript fix(core): record response's modelVersion in session transcript Apr 18, 2026
@nadja-y
Copy link
Copy Markdown
Author

nadja-y commented Apr 19, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the GeminiChat class to capture the specific model version from the response stream. The captured observedModel is then used when recording the message via chatRecordingService, falling back to the default model name if the version is not available in the stream. I have no feedback to provide.

@Jordanwaslistening
Copy link
Copy Markdown

Jordanwaslistening commented Apr 19, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: session transcript records pre-request model, not response's modelVersion

2 participants