fix(agents): resolve Gemini 3.1 forward-compat for all Google provider variants#36156
fix(agents): resolve Gemini 3.1 forward-compat for all Google provider variants#36156xinhuagu wants to merge 1 commit intoopenclaw:mainfrom
Conversation
…r variants (openclaw#36134) When sessions_spawn targets a Google Gemini model (e.g. google/gemini-3.1-flash-lite-preview), the provider is stored as "google" on the session. At runtime, resolveModel() could not find the model because the forward-compat fallback only checked "google-gemini-cli", causing a silent FailoverError that fell back to Anthropic — with modelApplied: true still reported. Fix: expand resolveGoogleGeminiCli31ForwardCompatModel to accept all Google provider variants (google, google-gemini-cli, google-vertex, google-antigravity). When the template model lives under a different variant in the pi-ai catalog, try all variants and re-stamp the provider to match the caller's request. Fixes openclaw#36134
Greptile SummaryThis PR correctly fixes the silent Anthropic fallback that occurred when Key changes:
The fix correctly prevents the silent fallback by ensuring that model lookups succeed across all supported Google variants, addressing the root cause of the issue. Confidence Score: 5/5
Last reviewed commit: e908439 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e908439428
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Re-stamp the provider to match what the caller requested so the | ||
| // returned model routes through the correct auth/transport layer. | ||
| (result as { provider: string }).provider = normalizedProvider; |
There was a problem hiding this comment.
Keep fallback API aligned with restamped Google provider
When this fallback resolves a template from a different Google variant, it rewrites only result.provider before returning. That creates mixed models such as provider: "google" with api: "google-gemini-cli"/Cloud Code base URL inherited from the template; downstream logic keys Gemini-CLI schema handling off provider (src/agents/pi-embedded-runner/google.ts:248), so these mixed models skip required sanitization and can fail tool-call requests for 3.1 forward-compat IDs whenever tool schemas include keywords Gemini CLI rejects.
Useful? React with 👍 / 👎.
|
Duplicate of #36160, closing. |
Summary
Fixes #36134 — sessions_spawn silently falls back to Anthropic when targeting Google Gemini models.
Root Cause
When
sessions_spawntargetsgoogle/gemini-3.1-flash-lite-preview, the model override is stored withproviderOverride: "google". At runtime,resolveModel()can't find the model because:gemini-3.1-flash-lite-previewyetresolveGoogleGeminiCli31ForwardCompatModel) only checked the"google-gemini-cli"provider — not"google"gemini-3-flash-preview) exist under"google-gemini-cli"in the registryFailoverErroris thrown and silently caught byrunWithModelFallback, falling back to AnthropicmodelApplied: truewas already returned to the caller — misleadingFix
Expand
resolveGoogleGeminiCli31ForwardCompatModelto accept all Google provider variants (google,google-gemini-cli,google-vertex,google-antigravity). When the template model lives under a different variant in the pi-ai catalog, try all variants and re-stamp the provider to match the caller's request.Tests
Added 3 new test cases covering:
google/gemini-3.1-flash-lite-preview(the exact model from the bug report)google/gemini-3.1-pro-previewgoogle-vertex/gemini-3.1-flash-previewAll existing tests continue to pass.