#22337: fix(models): add fallback Gemini 3.1 Pro Preview catalog entry
agents
size: S
Cluster:
Gemini 3.1 Model Enhancements
## What changed
- Add a built-in fallback entry for Google provider model google/gemini-3.1-pro-preview in `src/agents/model-catalog.ts` when it is missing from discovered models.
- Keep fallback behavior aligned for runtime usage: reasoning enabled, context window set to 1,000,000, and text/image input support.
- Add tests in `src/agents/model-catalog.test.ts` covering:
- model injection when missing,
- no-duplicate behavior when already present.
## Why this fixes the issue
Issue 22323 is caused by discovery missing the new Gemini 3.1 Pro Preview model, which can hide it from built-in provider selection. This fallback guarantees the catalog always contains that model and does not alter discovery semantics when a matching entry already exists.
## Tests run
- `pnpm vitest run --config vitest.unit.config.ts src/agents/model-catalog.test.ts`
- `pnpm test -- src/agents/model-catalog.test.ts`
## Edge cases
- Existing entries for google/gemini-3.1-pro-preview are preserved and not duplicated.
- Existing cache-reset/retry behavior and partial discovery failure handling remain unchanged.
## Infra flake / blockers
- None known.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds fallback catalog entry for `google/gemini-3.1-pro-preview` model when it's missing from SDK discovery, following the same pattern as the existing OpenAI Codex Spark fallback.
**Key changes:**
- Implements `applyGoogle31ProPreviewFallback()` function with deduplication check
- Configures model with `reasoning: true`, 1M context window, and text+image input support
- Adds comprehensive test coverage for both insertion and deduplication scenarios
- Updates existing test to use `toContainEqual` instead of strict equality for better flexibility
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation follows an established pattern (OpenAI Codex fallback), includes proper deduplication logic, and has comprehensive test coverage validating both insertion and non-duplication scenarios. The change is isolated, well-tested, and addresses a specific discoverability issue.
- No files require special attention
<sub>Last reviewed commit: c903811</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#11464: feat(models): add forward-compat fallback for gemini-3-pro-image
by ben-milanko · 2026-02-07
85.6%
#21263: fix: add google-vertex support for Gemini 3.1 models
by pdd-cli · 2026-02-19
82.7%
#21181: fix(models): add gemini-3.1-pro-preview forward-compat for google-g...
by Mellowambience · 2026-02-19
82.4%
#22899: fix(models): synthesize antigravity Gemini 3.1 pro high/low models
by Phineas1500 · 2026-02-21
81.5%
#23424: feat: add Gemini 3.1 Pro Preview support (google-gemini-cli)
by hongchanroh · 2026-02-22
80.3%
#23040: Upgrade default Google model to Gemini 3.1 Pro and add Venice catal...
by Clawborn · 2026-02-21
80.2%
#23034: Add Gemini 3.1 Pro to Google model normalizer and OpenCode Zen catalog
by Clawborn · 2026-02-21
79.1%
#21257: # feat: add Gemini 3.1 Pro (low/high reasoning) model support
by GhadiSaab · 2026-02-19
78.4%
#23129: build(deps): move @discordjs/opus to optionalDependencies
by Imccccc · 2026-02-22
77.1%
#11349: fix(agents): do not filter fallback models by models allowlist
by liuxiaopai-ai · 2026-02-07
76.5%