Skip to content

fix(vertexai): compact for gemini-3.1-flash-lite in non-stream mode#1204

Open
woorui wants to merge 2 commits intomasterfrom
feat/gemini-3.1-flash-compact
Open

fix(vertexai): compact for gemini-3.1-flash-lite in non-stream mode#1204
woorui wants to merge 2 commits intomasterfrom
feat/gemini-3.1-flash-compact

Conversation

@woorui
Copy link
Collaborator

@woorui woorui commented Mar 18, 2026

Fix a bug where the gemini-3.1-flash-lite-preview model in non-stream mode requires non-user messages to have the "model" role instead of their original roles

…ew in non-stream mode

Fix a bug where the gemini-3.1-flash-lite-preview model in non-stream mode requires non-user messages to have the "model" role instead of their original roles
@gemini-code-assist
Copy link
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 addresses a specific compatibility bug within the Vertex AI provider, ensuring that the gemini-3.1-flash-lite-preview model functions correctly in non-streaming scenarios. The change specifically targets message role handling, aligning it with the model's expectations to prevent errors and facilitate smooth communication.

Highlights

  • Bug Fix: Fixed an issue where the gemini-3.1-flash-lite-preview model in non-stream mode incorrectly required non-user messages to have the "model" role instead of their original roles.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.42%. Comparing base (8ca34ed) to head (adf74f6).

Files with missing lines Patch % Lines
pkg/bridge/ai/provider/vertexai/provider.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1204      +/-   ##
==========================================
+ Coverage   48.09%   48.42%   +0.33%     
==========================================
  Files          93       93              
  Lines        5510     5507       -3     
==========================================
+ Hits         2650     2667      +17     
+ Misses       2664     2640      -24     
- Partials      196      200       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
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 a workaround for a bug in the gemini-3.1-flash-lite-preview model when used in non-streaming mode, by ensuring non-user messages have the model role. The change is specific and seems correct. My review includes a suggestion to improve code maintainability by replacing hardcoded strings with constants.

Comment on lines +179 to +183
if req.Model == "google/gemini-3.1-flash-lite-preview" && req.Stream == false {
if msg.Role != openai.ChatMessageRoleUser {
msg.Role = "model"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve readability and maintainability, it's a good practice to avoid magic strings. The model name "google/gemini-3.1-flash-lite-preview" and the role "model" should be extracted into package-level constants.

For example:

const (
	modelGeminiFlashLitePreview = "google/gemini-3.1-flash-lite-preview"
	roleModel                   = "model"
)

Then you can use these constants in the if condition. Also, req.Stream == false can be simplified to !req.Stream, which is more idiomatic in Go.

@woorui woorui requested a review from venjiang March 19, 2026 04:35
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.

1 participant