Skip to content

fix(gemini): restore Gemma model discovery in model picker#42693

Open
BorisDay wants to merge 2 commits into
NousResearch:mainfrom
BorisDay:fix/gemini-provider-gemma-model-discovery
Open

fix(gemini): restore Gemma model discovery in model picker#42693
BorisDay wants to merge 2 commits into
NousResearch:mainfrom
BorisDay:fix/gemini-provider-gemma-model-discovery

Conversation

@BorisDay

@BorisDay BorisDay commented Jun 9, 2026

Copy link
Copy Markdown

Summary

Fixes three independent bugs that conspired to hide Gemma models from the Hermes /model picker:

Bug Symptom Root Cause
Auth Google API returns 401 fetch_models() sends Bearer token; Google requires ?key= query param
Parsing Empty model list fetch_models() reads m["id"]; Google returns "name": "models/gemma-4-31b-it"
Fallback No Gemma shown _PROVIDER_MODELS["gemini"] only had Gemini models

Changes

1. plugins/model-providers/gemini/__init__.py (+61 lines)

Override fetch_models() in GeminiProfile to:

  • Use ?key={api_key} query-param auth (matching Google API requirements)
  • Parse "name" field with models/ prefix stripping
  • Return the full live model list including Gemma

2. hermes_cli/models.py (+2 lines)

Add gemma-4-31b-it and gemma-4-26b-a4b-it to _PROVIDER_MODELS["gemini"] as static fallback when live fetch fails (belt and suspenders).

3. agent/transports/chat_completions.py (5 lines changed)

Update _build_gemini_thinking_config() to accept gemma-4 models. Google's API now lists both Gemma 4 models with "thinking": true, indicating they support thinking_config. Limited to gemma-4 prefix to avoid regressions with older Gemma <=3 models (#17426).

Verification

Live fetch from Google AI Studio now returns Gemma models:

>>> gemma-4-26b-a4b-it  (thinking=true)
>>> gemma-4-31b-it      (thinking=true)

Both models appear in /model picker with selectable reasoning effort.

Related

BorisDay added 2 commits June 9, 2026 10:52
Three bugs conspired to hide Gemma models (gemma-4-31b-it, gemma-4-26b-a4b-it)
from the /model picker despite the Google API listing them with thinking support:

1. fetch_models() used Bearer auth — Google requires ?key= query param (HTTP 401)
2. fetch_models() read m['id'] — Google returns 'name': 'models/gemma-4-...'
3. _PROVIDER_MODELS static fallback omitted Gemma models entirely

Fixes:
- GeminiProfile.fetch_models(): override with ?key= auth + name-field parser
- _PROVIDER_MODELS['gemini']: add gemma-4-31b-it and gemma-4-26b-a4b-it
- _build_gemini_thinking_config(): accept gemma-4 models (API lists thinking:true)

Closes: NousResearch#17426 (related — thinking_config now safe for Gemma 4)
- Fix auth bypass when models_url is set: always append ?key= to URL
- Move stdlib imports to module level (matching codebase style)
- Sanitize debug log to avoid API key leakage in exception strings
- Use URLError-specific catch with safe log message
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have provider/gemini Google Gemini (AI Studio, Cloud Code) labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have provider/gemini Google Gemini (AI Studio, Cloud Code) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Model calls to google provider return 400 error with Invalid JSON payload on thinking_config

2 participants