fix(agents): extend Gemini 3.1 forward-compat to google provider#36145
fix(agents): extend Gemini 3.1 forward-compat to google provider#36145Sid-Qin wants to merge 1 commit intoopenclaw:mainfrom
Conversation
The forward-compat path for gemini-3.1-pro-preview and gemini-3.1-flash-lite-preview only covered the google-gemini-cli provider. Users configuring these models with the google provider (Gemini API key auth) got "Unknown model" errors and silently fell back to Anthropic. Extend resolveGoogleGemini31ForwardCompatModel to accept both google-gemini-cli and google providers by using a provider set. Also add bare-ID normalization for gemini-3.1-pro, gemini-3.1-flash, and gemini-3.1-flash-lite in normalizeGoogleModelId(). Closes openclaw#36134 Closes openclaw#36111
Greptile SummaryThis PR extends the Gemini 3.1 forward-compatibility mechanism to the Key observations:
Confidence Score: 4/5
|
| if (id === "gemini-3.1-pro" || id === "gemini-3-1-pro") { | ||
| return "gemini-3.1-pro-preview"; | ||
| } | ||
| if (id === "gemini-3.1-flash" || id === "gemini-3-1-flash") { | ||
| return "gemini-3.1-flash-preview"; | ||
| } | ||
| if (id === "gemini-3.1-flash-lite" || id === "gemini-3-1-flash-lite") { | ||
| return "gemini-3.1-flash-lite-preview"; | ||
| } |
There was a problem hiding this comment.
No tests for new normalizeGoogleModelId entries
The existing test (models-config.normalizes-gemini-3-ids-preview-google-providers.test.ts) only covers gemini-3-pro and gemini-3-flash. The three new normalization mappings added here (gemini-3.1-pro, gemini-3-1-pro, gemini-3.1-flash, gemini-3-1-flash, gemini-3.1-flash-lite, gemini-3-1-flash-lite) are not exercised by any test. A regression in these branches would be invisible until it surfaces at runtime as an "Unknown model" error.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/models-config.providers.ts
Line: 447-455
Comment:
**No tests for new `normalizeGoogleModelId` entries**
The existing test (`models-config.normalizes-gemini-3-ids-preview-google-providers.test.ts`) only covers `gemini-3-pro` and `gemini-3-flash`. The three new normalization mappings added here (`gemini-3.1-pro`, `gemini-3-1-pro`, `gemini-3.1-flash`, `gemini-3-1-flash`, `gemini-3.1-flash-lite`, `gemini-3-1-flash-lite`) are not exercised by any test. A regression in these branches would be invisible until it surfaces at runtime as an "Unknown model" error.
How can I resolve this? If you propose a fix, please make it concise.
Summary
gemini-3.1-pro-preview,gemini-3.1-flash-lite-preview) are not recognized when used with thegoogleprovider (Gemini API key auth). The existing forward-compat only coveredgoogle-gemini-cli, sogoogle/gemini-3.1-*gets "Unknown model" and silently falls back to Anthropic withmodelApplied: true— a 10x cost increase with no visibility.sessions_spawnor fallback chains get silent, expensive fallback to Anthropic instead of an error or correct routing.src/agents/model-forward-compat.ts— extendedresolveGoogleGemini31ForwardCompatModelto accept bothgoogle-gemini-cliandgoogleproviders viaGOOGLE_GEMINI_31_ELIGIBLE_PROVIDERSset. The function clones the nearest gemini-3 template model and setsreasoning: true.src/agents/models-config.providers.ts— added bare-ID normalization forgemini-3.1-pro,gemini-3.1-flash,gemini-3.1-flash-lite(and dash variants) innormalizeGoogleModelId().google-gemini-cliforward-compat behavior is preserved. Default aliases remain unchanged.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
google/gemini-3.1-pro-preview,google/gemini-3.1-flash-preview, andgoogle/gemini-3.1-flash-lite-previewnow resolve correctly via thegoogleprovider.gemini-3.1-proandgemini-3.1-flash-liteare normalized to their-previewcounterparts.Security Impact (required)
NoNoNoNoNoRepro + Verification
Environment
Steps
anthropicandgoogleauth profilessessions_spawn({ task: "Identify yourself", model: "google/gemini-3.1-flash-lite-preview", mode: "run" })Expected
Actual
modelApplied: trueEvidence
Forward-compat test matrix:
gemini-3.1-pro-previewgooglegemini-3.1-flash-lite-previewgooglegemini-3.1-flash-previewgoogle-gemini-cligemini-3.1-pro(bare)google-previewHuman Verification (required)
google-gemini-clipath unchanged; non-3.1 models unaffectedCompatibility / Migration
Yes—google-gemini-clibehavior unchangedNoNoFailure Recovery (if this breaks)
Risks and Mitigations