Fix: Allow new Gemini models (gemini-3-pro-preview) to route to native provider #3951
+66
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Allow new Gemini models to route to native provider without constants
Summary
Fixes #3949 where
LLM(model='google/gemini-3-pro-preview')was failing to route to the native Gemini provider because the model wasn't in theGEMINI_MODELSconstants list.Changes:
LLM._validate_model_in_constants()to allow any model starting withgemini-,gemma-, orlearnlm-prefixes to route to the native Gemini provider, even if not explicitly listed in constantsgemini-3-pro-preview)Technical approach:
Instead of strictly requiring models to be in
GEMINI_MODELS, the validation now:This approach is more future-proof and aligns with how Azure models are handled (which also don't have strict validation).
Review & Testing Checklist for Human
LLM(model='google/gemini-3-pro-preview')now routes toGeminiCompletioninstead of falling back to LiteLLMgoogle/gemini-2.0-flash-001andgoogle/gemini-1.5-prostill work correctlyLLM(model='google/unknown-model-xyz')properly falls back to LiteLLM or surfaces an appropriate errortest_gemini_allows_new_preview_models_without_constantsTest Plan
Notes
.lower()for prefix matching, which should handle various capitalizations (e.g., "Gemini-3-Pro", "GEMINI-3-FLASH").Link to Devin run: https://app.devin.ai/sessions/eb9b5faf184046608c23eb6de4e7a067
Requested by: João (joao@crewai.com)