Skip to content

fix(providers): complete native Gemini ListModels discovery - #116509

Open
LordMelkor wants to merge 3 commits into
NousResearch:mainfrom
LordMelkor:codex/fix-gemini-catalog-completeness
Open

LordMelkor wants to merge 3 commits into
NousResearch:mainfrom
LordMelkor:codex/fix-gemini-catalog-completeness

Conversation

@LordMelkor

Copy link
Copy Markdown

What does this PR do?

Gemini live discovery now traverses the complete native ListModels catalog and keeps only models the chat picker can use. Native requests authenticate with x-goog-api-key, follow continuation tokens, require generateContent, and remove embedding, TTS, live, image, music, video, transcription, and other non-conversational families. A repeated continuation token fails discovery instead of returning a partial catalog.

Non-native endpoints retain the existing ProviderProfile.fetch_models() Bearer and data[].id contract, including the Google OpenAI-compatible endpoint and custom relays.

This carries forward the two commits from @PRATHAMESH75 in #62267 and adds the missing capability filtering and complete pagination behavior. It is intended to supersede #62267 rather than compete with it.

Related Issue

Fixes #62259

Supersedes #62267.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • plugins/model-providers/gemini/__init__.py — add native ListModels discovery with header authentication, complete pagination, capability filtering, and non-native endpoint delegation.
  • tests/providers/test_fetch_models_base_url.py — exercise native discovery through a local HTTP server, including two-page traversal, filtering, repeated-token failure, missing credentials, and custom relay delegation.

How to Test

  1. Run scripts/run_tests.sh tests/providers/test_fetch_models_base_url.py tests/plugins/model_providers/test_gemini_profile.py.
  2. Confirm all 11 tests pass.
  3. The new contract tests fail twice on the predecessor implementation: it neither performs the filtered native request nor delegates every non-native endpoint.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass — focused suites passed through the repository's scripts/run_tests.sh wrapper
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.6.2, Python 3.11.15

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A; the provider docstring describes the behavior
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide; the changed paths use standard-library HTTP and existing cross-platform helpers
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

Screenshots / Logs

Focused validation: 11 passed, 0 failed. The Windows footgun scanner reported no findings in the two changed files.

PRATHAMESH75 and others added 3 commits September 19, 2026 20:25
The native Gemini /v1beta endpoint rejects Bearer auth with HTTP 401, so
ProviderProfile.fetch_models()'s OpenAI-style Authorization header returned
None and the /model picker silently fell back to the 4 static fallback
models instead of the 50+ the account can actually call.

Override fetch_models() in GeminiProfile to hit {base_url}/models?key=<key>
(the same query-param auth the native inference client already uses) and
strip the 'models/' prefix each returned name carries, so live discovery
matches inference.

Fixes NousResearch#62259

Co-authored-by: Codex <noreply@openai.com>
Ai-assisted: true
…act errors

Address review: delegate the OpenAI-compat /openai base URL to
ProviderProfile.fetch_models (it speaks Bearer + data[].id) instead of
forcing native query-param auth, and stop logging the caught exception
value — urllib errors embed the request URL, which carries the api_key in
the ?key= query param. Log the exception type only. Add regression tests
for the compat-branch delegation and the no-key-leak failure path.

Co-authored-by: Codex <noreply@openai.com>
Ai-assisted: true
Traverse the complete native catalog, authenticate without Bearer, and keep only conversational generateContent models. Fail discovery if pagination repeats a token instead of returning a partial result.

Ai-assisted: true
Co-authored-by: Codex <noreply@openai.com>
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins provider/gemini Google Gemini (AI Studio, Cloud Code) labels Sep 20, 2026
teknium1 added a commit that referenced this pull request Sep 24, 2026
…ng static xfails

#120319, #120374 and #120299 are on main, so their probes and every Gap
naming them go (the module's own rule); those cells are plain tests now.

The two static strict xfails with an open fix PR (#95375 cli
resize_scrollback, fix #120321; #62259 Gemini listing, fix #62267/#116509)
turned main red the moment the fix merged (XPASS). They now go through
_pending_fixes.known_failure: a run-time xfail only while the cell fails
with that gap's own message (a turn rendered more than once; an empty live
listing), any other failure stays red, and the fix just makes it pass.
teknium1 added a commit that referenced this pull request Sep 24, 2026
…ng static xfails

#120319, #120374 and #120299 are on main, so their probes and every Gap
naming them go (the module's own rule); those cells are plain tests now.

The two static strict xfails with an open fix PR (#95375 cli
resize_scrollback, fix #120321; #62259 Gemini listing, fix #62267/#116509)
turned main red the moment the fix merged (XPASS). They now go through
_pending_fixes.known_failure: a run-time xfail only while the cell fails
with that gap's own message (a turn rendered more than once; an empty live
listing), any other failure stays red, and the fix just makes it pass.
teknium1 added a commit that referenced this pull request Sep 24, 2026
…ng static xfails

#120319, #120374 and #120299 are on main, so their probes and every Gap
naming them go (the module's own rule); those cells are plain tests now.

The two static strict xfails with an open fix PR (#95375 cli
resize_scrollback, fix #120321; #62259 Gemini listing, fix #62267/#116509)
turned main red the moment the fix merged (XPASS). They now go through
_pending_fixes.known_failure: a run-time xfail only while the cell fails
with that gap's own message (a turn rendered more than once; an empty live
listing), any other failure stays red, and the fix just makes it pass.

This branch has not been deployed

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

Labels

comp/plugins Plugin system and bundled plugins 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.

Gemini live model discovery fails — native /v1beta endpoint rejects Bearer auth (falls back to 4 static models)

3 participants