Skip to content

fix(agents): resolve Gemini 3.1 forward-compat for all Google provider variants#36156

Closed
xinhuagu wants to merge 1 commit intoopenclaw:mainfrom
xinhuagu:fix/36134-google-subagent-model-forward-compat
Closed

fix(agents): resolve Gemini 3.1 forward-compat for all Google provider variants#36156
xinhuagu wants to merge 1 commit intoopenclaw:mainfrom
xinhuagu:fix/36134-google-subagent-model-forward-compat

Conversation

@xinhuagu
Copy link
Copy Markdown
Contributor

@xinhuagu xinhuagu commented Mar 5, 2026

Summary

Fixes #36134 — sessions_spawn silently falls back to Anthropic when targeting Google Gemini models.

Root Cause

When sessions_spawn targets google/gemini-3.1-flash-lite-preview, the model override is stored with providerOverride: "google". At runtime, resolveModel() can't find the model because:

  1. pi-ai's built-in catalog doesn't have gemini-3.1-flash-lite-preview yet
  2. The forward-compat fallback (resolveGoogleGeminiCli31ForwardCompatModel) only checked the "google-gemini-cli" provider — not "google"
  3. Template models (e.g. gemini-3-flash-preview) exist under "google-gemini-cli" in the registry
  4. FailoverError is thrown and silently caught by runWithModelFallback, falling back to Anthropic
  5. modelApplied: true was already returned to the caller — misleading

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.

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-preview
  • google-vertex/gemini-3.1-flash-preview

All existing tests continue to pass.

…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-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 5, 2026

Greptile Summary

This PR correctly fixes the silent Anthropic fallback that occurred when sessions_spawn targeted a Google Gemini 3.1 model via the bare "google" provider.

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

  • Safe to merge — the fix is well-scoped, directly addresses the reported bug, and maintains backward compatibility with existing code.
  • The implementation correctly resolves the silent fallback issue by expanding provider variant support in the forward-compat resolver. The fix follows established patterns, integrates cleanly with existing code, and is covered by focused smoke tests that validate the reported bug scenario. No logic errors, regressions, or security concerns identified.
  • No files require special attention

Last reviewed commit: e908439

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +225 to +227
// 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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@xinhuagu
Copy link
Copy Markdown
Contributor Author

xinhuagu commented Mar 5, 2026

Duplicate of #36160, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: sessions_spawn silently falls back to Anthropic (set fallback model) when targeting Google Gemini models on spawned subagent tasks.

1 participant