Skip to content

fix(core): support multimodal function response for dotted Gemini 3 models and aliases - #29611

Closed
bodapatisaikrishna wants to merge 1 commit into
google-gemini:mainfrom
bodapatisaikrishna:fix/multimodal-function-response-gemini-3
Closed

bodapatisaikrishna wants to merge 1 commit into
google-gemini:mainfrom
bodapatisaikrishna:fix/multimodal-function-response-gemini-3

Conversation

@bodapatisaikrishna

Copy link
Copy Markdown

Summary

Resolve model aliases and support dotted Gemini 3 model versions in supportsMultimodalFunctionResponse(). This prevents multimodal tool outputs (such as images read via read_file) from being emitted as invalid sibling parts on Gemini 3 models like gemini-3.8-flash, which triggers HTTP 400 errors.

Details

supportsMultimodalFunctionResponse checked model.startsWith('gemini-3-'), which missed dotted model versions (gemini-3.8-flash, gemini-3.5-flash, gemini-3.1-*) and aliases like auto. When it evaluated to false, convertToFunctionResponse() pushed binary parts to siblingParts outside functionResponse, causing Vertex / Gemini API calls to fail.

The check now resolves the model identifier in both static and dynamic configuration paths and uses /^gemini-3(\.|-|$)/ consistent with isGemini3Model().

Related Issues

Fixes #29574

How to Validate

npx vitest run packages/core/src/config/models.test.ts packages/core/src/utils/generateContentResponseUtilities.test.ts
npm run lint

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run

@bodapatisaikrishna
bodapatisaikrishna requested a review from a team as a code owner October 2, 2026 13:29
@github-actions github-actions Bot added the size/m A medium sized PR label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 107
  • Additions: +102
  • Deletions: -5
  • Files changed: 3

@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 addresses issues with multimodal function responses for Gemini 3 models by improving how model identifiers are resolved and matched. By correctly identifying dotted model versions and aliases, the system now avoids generating invalid sibling parts that previously caused API errors, ensuring that multimodal content is properly nested within function responses.

Highlights

  • Improved Model Resolution: Updated supportsMultimodalFunctionResponse to resolve model aliases and support dotted Gemini 3 versions, ensuring correct handling of multimodal tool outputs.
  • Regex-based Model Matching: Replaced strict string prefix matching with a regex check (/^gemini-3(\.|-|$)/) to consistently identify Gemini 3 models.
  • Enhanced Test Coverage: Added comprehensive test cases for various Gemini 3 model versions and aliases to verify correct multimodal function response behavior.
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 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 .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 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

  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. ↩

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

Copy link
Copy Markdown
Contributor

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 supportsMultimodalFunctionResponse to resolve model aliases and names using resolveModel before performing capability checks, and expands the test coverage for Gemini 3 models and aliases. A review comment points out that calling resolveModel in the fallback path without passing the config context or the preview access flag can lead to incorrect model resolution (e.g., resolving to a preview model when the user does not have preview access), and suggests passing the context and preview flags to ensure accurate capability detection.

Comment thread packages/core/src/config/models.ts Outdated
Comment on lines +674 to +675
const resolved = resolveModel(model);
return /^gemini-3(\.|-|$)/.test(resolved);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

In the fallback path of supportsMultimodalFunctionResponse, calling resolveModel(model) without passing the config context or hasAccessToPreview flag can lead to incorrect model resolution. For example, if a user does not have preview access, 'pro' should resolve to gemini-2.5-pro (which does not support multimodal function responses). However, without passing hasAccessToPreview, it will default to true and resolve to gemini-3-pro-preview, incorrectly returning true and potentially causing HTTP 400 errors at runtime. Passing the context and preview access flags ensures accurate capability detection.

  const hasAccessToPreview = config?.getHasAccessToPreviewModel?.() ?? true;
  const resolved = resolveModel(
    model,
    false,
    false,
    hasAccessToPreview,
    config,
  );
  return /^gemini-3(\|-|$)/.test(resolved);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch, updated to pass preview access and config in both paths and added a test for it.

…odels and aliases

supportsMultimodalFunctionResponse checked startsWith('gemini-3-'), which excluded dotted model versions like gemini-3.8-flash and aliases like auto. Resolve model IDs and respect preview access in both static and dynamic configuration paths so multimodal output stays nested in functionResponse.
@bodapatisaikrishna
bodapatisaikrishna force-pushed the fix/multimodal-function-response-gemini-3 branch from a969ab4 to df02d03 Compare October 2, 2026 13:39
@gemini-cli gemini-cli Bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Oct 2, 2026
@gemini-cli

gemini-cli Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'.

This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality labels Oct 12, 2026
@gemini-cli

gemini-cli Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

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 area/core Issues related to User Interface, OS Support, Core Functionality priority/p2 Important but can be addressed in a future release. size/m A medium sized PR status/pr-nudge-sent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(core): 400 Bad Request "Requests ending with a model turn are not supported" when reading image files via ReadFile tool

2 participants