Skip to content

fix: pass through custom model names in Gemini provider#12137

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/gemini-custom-model-passthrough
Draft

fix: pass through custom model names in Gemini provider#12137
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/gemini-custom-model-passthrough

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 bot commented Apr 16, 2026

Related GitHub Issue

Closes: #12136

Description

This PR attempts to address Issue #12136. Feedback and guidance are welcome.

Root cause: In src/api/providers/gemini.ts, the getModel() method checked if the user-provided model ID existed in the predefined geminiModels map. If not found, it silently fell back to geminiDefaultModelId (gemini-3.1-pro) instead of passing through the custom model name.

Fix: Updated getModel() to handle three cases (matching the pattern already applied to vertex.ts in commit 9724a28 for #12074):

  1. If modelId is in geminiModels: use the curated ModelInfo (existing behavior).
  2. If modelId is provided but not in the map: pass it through as-is with sensible default ModelInfo (new -- fixes the bug).
  3. If no modelId is provided: fall back to geminiDefaultModelId (existing behavior).

Test Procedure

  • Updated existing test in gemini.spec.ts that previously asserted custom models fall back to the default. It now verifies custom model names are passed through as-is.
  • Added a new test verifying the default model is still used when no model ID is specified.
  • All 20 tests in gemini.spec.ts pass. All 17 tests in vertex.spec.ts and gemini-handler.spec.ts continue to pass.
  • Run: cd src && npx vitest run api/providers/__tests__/gemini.spec.ts

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue.
  • Scope: Changes are focused on the linked issue.
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and updated tests have been added to cover changes.
  • Documentation Impact: No documentation updates are required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This is structurally identical to the fix already applied for Vertex AI in #12074 (commit 9724a28). The same silent-fallback pattern existed in the Gemini provider and is now resolved with the same approach.

Interactively review PR in Roo Code Cloud

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.

[BUG] Custom model names for Google Gemini / GCP Vertex AI are silently ignored and fallback to default model (gemini-3.1-pro)

1 participant