Skip to content

fix(model-fallback): transform gemini-3 models to -preview for google provider#1435

Open
filipemsilv4 wants to merge 3 commits intocode-yeongyu:devfrom
filipemsilv4:fix/gemini-3-flash-google-provider-transform
Open

fix(model-fallback): transform gemini-3 models to -preview for google provider#1435
filipemsilv4 wants to merge 3 commits intocode-yeongyu:devfrom
filipemsilv4:fix/gemini-3-flash-google-provider-transform

Conversation

@filipemsilv4
Copy link

@filipemsilv4 filipemsilv4 commented Feb 3, 2026

Summary

Fix ProviderModelNotFoundError when subagents try to use Gemini 3 models via the Google provider.

Problem

When a subagent attempts to use google/gemini-3-flash or google/gemini-3-pro, opencode throws:

ProviderModelNotFoundError: ProviderModelNotFoundError
providerID: "google",
modelID: "gemini-3-flash",
suggestions: [ "gemini-3-flash-preview", "antigravity-gemini-3-flash" ]

This happens because the Google provider only has gemini-3-flash-preview and gemini-3-pro-preview registered - not the base model names without the -preview suffix.

Solution

Add the same model name transformation for the google provider that was already implemented for the github-copilot provider:

  • gemini-3-flashgemini-3-flash-preview
  • gemini-3-progemini-3-pro-preview

Changes

  • src/cli/model-fallback.ts: Added google provider to transformModelForProvider() function
  • src/cli/model-fallback.test.ts: Added tests for the new transformations (TDD approach)
  • Updated snapshots: Reflect the new model names for google provider

Testing

  • Added unit tests (TDD RED → GREEN)
  • All existing tests pass
  • Snapshots updated
  • Typecheck passes
  • LSP diagnostics clean

Summary by cubic

Fixes ProviderModelNotFoundError by mapping Google Gemini 3 model names to their preview variants across config generation and runtime resolution. Subagents can now use Google Gemini 3 without errors.

  • Bug Fixes
    • Added idempotent transformation in transformModelForProvider and resolveModelPipeline to map gemini-3-pro → gemini-3-pro-preview and gemini-3-flash → gemini-3-flash-preview (prevents -preview-preview; covers category defaults and fallback chain).
    • Updated unit tests and snapshots for both config generation and runtime resolution.

Written for commit 72481a3. Summary will update on new commits.

… provider

Google provider only has gemini-3-flash-preview and gemini-3-pro-preview,
not gemini-3-flash and gemini-3-pro. This was causing ProviderModelNotFoundError
when subagents tried to use these models via the google provider.

The fix adds the same transformation that was already applied for github-copilot
provider to the google provider as well.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@filipemsilv4
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Feb 3, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

…n pipeline

The previous fix only addressed config generation (model-fallback.ts).
This commit fixes the runtime model resolution when availableModels is
empty but connected providers cache exists.

Without this fix, the pipeline returns 'google/gemini-3-pro' directly
without transformation, causing ProviderModelNotFoundError in opencode
since Google provider only has 'gemini-3-pro-preview'.
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/shared/model-resolution-pipeline.ts">

<violation number="1" location="src/shared/model-resolution-pipeline.ts:10">
P2: transformModelForProvider performs unconditional substring replacement, so models already containing the preview suffix (e.g., gemini-3-flash-preview) will be transformed to gemini-3-flash-preview-preview or mutate other variants. This non-idempotent transformation can generate invalid model IDs when inputs are already preview models.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

… suffix

Use negative lookahead (?!-) to only transform base model names like
'gemini-3-pro' and 'gemini-3-flash', not models that already have
suffixes like '-preview', '-high', '-low', '-medium'.

This prevents 'gemini-3-flash-preview' from becoming
'gemini-3-flash-preview-preview'.
leoisadev1 pushed a commit to leoisadev1/oh-my-opencode that referenced this pull request Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant