Skip to content

fix: add Gemma 4 model support and stop silent model ID fallback#12167

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/gemma4-model-support-12166
Draft

fix: add Gemma 4 model support and stop silent model ID fallback#12167
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/gemma4-model-support-12166

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 Bot commented Apr 22, 2026

Related GitHub Issue

Closes: #12166

Description

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

Two changes:

  1. Add Gemma 4 models to the geminiModels map (packages/types/src/providers/gemini.ts):

    • gemma-4-31b-it (131K context, image support)
    • gemma-4-12b-it (131K context, image support)
    • gemma-4-6b-it (32K context, image support)
    • gemma-4-4b-it (32K context, image support)
    • gemma-4-1b-it (32K context, text only)
  2. Fix silent model ID fallback in both GeminiHandler.getModel() and VertexHandler.getModel():

    • Previously, any model ID not in the known models map was silently replaced with the default (gemini-3.1-pro-preview), causing 429 quota errors when users specified custom models like Gemma 4
    • Now the user-provided model ID is always preserved; only the model info (context window, pricing, etc.) falls back to defaults for unknown models
    • This follows the same pattern used by the DeepSeek provider

Test Procedure

  • Ran cd src && npx vitest run api/providers/__tests__/gemini.spec.ts api/providers/__tests__/vertex.spec.ts -- all 28 tests pass
  • Updated existing test that expected unknown model IDs to be replaced with default
  • Added new tests verifying:
    • Unknown model IDs are preserved (not silently replaced)
    • Default model is used when no model ID is provided
    • Gemma 4 models are natively recognized with correct context window and capabilities

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my 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

The fix applies the same pattern used by the DeepSeek provider (deepseek.ts:37-48), which preserves the user-provided model ID and only falls back on model info for unknown models.

Interactively review PR in Roo Code Cloud

…fallback

- Add gemma-4-31b-it, gemma-4-12b-it, gemma-4-6b-it, gemma-4-4b-it,
  and gemma-4-1b-it to the geminiModels map with correct context windows
  and capabilities
- Fix silent fallback in GeminiHandler.getModel() that replaced unknown
  model IDs with geminiDefaultModelId (gemini-3.1-pro-preview)
- Apply the same fix to VertexHandler.getModel()
- Now preserves user-provided model ID and only falls back on model info
- Update tests to verify unknown models are passed through and Gemma 4
  models are natively recognized

Closes #12166
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] Manual Model ID models/gemma-4-31b-it is overridden by gemini-3.1-pro causing 429 Quota Errors

1 participant