Skip to content

bug(models): Missing google provider config silently routes Gemini requests to OpenAI #85042

Description

@KurtWoloch

Description

When a Google Gemini model (e.g., gemini-3.5-flash) is added to agents.defaults.models or used in agents.defaults.model.fallbacks, but models.providers.google is omitted/empty in openclaw.json, OpenClaw's model resolution fails to throw a clean config validation error.

Instead, it falls back to the default provider adapter (which is OpenAI) and attempts to route the Gemini request—carrying the Google API key (AIzaSy...)—directly to OpenAI's endpoint!

This results in a highly confusing 401 error being logged and surfaced:

[agent/embedded] embedded run agent end: runId=... isError=true model=gemini-3.5-flash provider=google error=401 Incorrect API key provided: AIzaSyDp***************************Rojc. You can find your API key at https://platform.openai.com/account/api-keys.

Steps to Reproduce

  1. Add google/gemini-3.5-flash to your fallbacks in openclaw.json.
  2. Leave models.providers.google completely undefined or empty in the config.
  3. Trigger a run that falls back to Gemini.
  4. Observe that the Google API key is sent to OpenAI, returning an OpenAI-specific 401 error.

Impact

  1. Confusing UX: The user is left wondering why their Google API key is being rejected by OpenAI's auth server, leading them to think their OpenAI settings are corrupted.
  2. Key exposure: Sending a Google API key to OpenAI's endpoint is a security/privacy leak that should be prevented.

Suggested Fix

The model resolution or config validator should throw a clean, local configuration error (e.g. Google provider is not configured under models.providers) if a model prefix is matched to a provider that has no registered entry, instead of silently falling back to the OpenAI adapter and routing the payload there.

Metadata

Metadata

Assignees

Labels

P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions