Gemini CLI model discovery fails with v0.38.x (bundled architecture)
Bug Description
Gemini CLI model discovery returns 0 models when using Gemini CLI v0.38.x+, causing the model selector to fall back to only 3 hardcoded models (gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.5-pro). Newer models like gemini-3-flash-preview, gemini-3.1-flash-lite-preview are not available in the selector.
Root Cause
Starting from v0.38.x, the Gemini CLI package moved to a bundled architecture:
/home/david/.npm-global/lib/node_modules/@google/gemini-cli/bundle/gemini.js
The model discovery in ductor_bot/cli/gemini_utils.py looks for gemini-cli-core/dist/src/config/models.js at these paths:
<npm_global_root>/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/config/models.js<cli_path_package_root>/node_modules/@google/gemini-cli-core/dist/src/config/models.js- Various NVM / npm flat layout paths
None of these paths exist in the bundled layout. The gemini-cli-core is no longer a separate package under node_modules/ — it's inlined into bundle/gemini.js.
Steps to Reproduce
- Install Gemini CLI v0.38.x+:
npm install -g @google/gemini-cli - Install ductor:
pipx install ductor - Configure ductor with
provider: gemini - Start ductor and send
/model - Observe that only 3 fallback models appear instead of the full model list
Expected Behavior
All available Gemini models (including preview models like gemini-3-flash-preview) should be discoverable and shown in the /model selector.
Actual Behavior
Discovery returns 0 models, falls back to hardcoded 3 models. Log output:
Gemini cache refresh forced
Discovered 0 Gemini models
Using hardcoded Gemini fallback models (not persisted)
Gemini cache loaded: 3 models
Environment
- ductor: 0.15.0
- Gemini CLI: 0.38.2
- Python: 3.12.3
- OS: Ubuntu 22.04 (Linux)
- Install method: pipx
Additional Notes
I verified the Gemini CLI bundled path:
$ readlink -f /home/david/.npm-global/bin/gemini
/home/david/.npm-global/lib/node_modules/@google/gemini-cli/bundle/gemini.js
No gemini-cli-core directory exists:
$ ls /home/david/.npm-global/lib/node_modules/@google/gemini-cli/node_modules/@google/
(none — no separate packages)
Suggested Fix
The discover_gemini_models() function in gemini_utils.py should be updated to also support the bundled layout:
- Try to import/export
VALID_GEMINI_MODELSfrombundle/gemini.js - Or parse model identifiers from the bundled JS file directly
- Alternatively, use
gemini --output-format jsonor similar CLI command to query available models - The
_discover_models_via_node()fallback regex extraction already works as a last resort, but only if the models.js path is found
Additional: Default model should be gemini-2.5-flash, not gemini-2.5-pro
As a side effect of the issue above, the default model in the example config and initial setup is gemini-2.5-pro, which has very limited free-tier capacity.
In my case, ductor consumed the entire Gemini Pro quota (100%) in the background before I even sent my first message — through init processes like trusted workspace setup, skill sync, and model cache refresh. The user never explicitly requested Pro.
Additionally, /new resets the provider session but preserves the model field in sessions.json, which overrides the config default. So even after changing the config default to gemini-2.5-flash, the bot kept using gemini-2.5-pro until sessions.json was manually edited.
Suggestions
- Change the default model to
gemini-2.5-flash— More generous free-tier limits, faster responses, and sufficient for most coding tasks. - Make
/newrespect the config default model — Currentlysessions.jsonmodel persists across/newresets, which is confusing. - Consider adding a
--modelflag or env var to the background init/setup processes so they don't burn through Pro quota silently.
Update: Still present in ductor 0.15.0 + Gemini CLI 0.38.2
Confirmed the issue persists. Additional observations:
Performance Impact
The discovery failure causes a significant side effect: every session loads 24K+ input tokens even for simple messages. This is because:
--include-directories .gets passed to the Gemini CLI (fromcli_parameters.geminiconfig), causing the entire workspace to be included in every request- Without proper model discovery, the session management cannot optimize context size
A partial workaround is manually updating ~/.ductor/config/gemini_models.json with the correct model list extracted from the bundle:
{
"last_updated": "2026-04-21T09:30:00.000000+00:00",
"models": [
"gemini-2.5-flash",
"gemini-2.5-flash-lite",
"gemini-2.5-pro",
"gemini-3-flash-preview",
"gemini-3-pro-preview",
"gemini-3.1-flash-lite-preview",
"gemini-3.1-pro-preview"
]
}
The models can be extracted from the bundle:
grep -oh gemini-[a-z0-9._-]* \
/path/to/gemini-cli/bundle/chunk-*.js | sort -u
Suggested Bundle-Aware Discovery
The _gemini_models_js_candidates() function should add bundle paths:
# In _gemini_models_js_candidates():
bundle_dir = gemini_cli_root / "bundle"
if bundle_dir.is_dir():
for js_file in bundle_dir.glob("chunk-*.js"):
candidates.append(js_file)
And _discover_models_from_models_js() should handle the regex extraction for these chunk files (which already works via _extract_models_from_text()).
Fixed via PR #105 (@attid) in v0.16.0. The new bundled-chunks discovery path handles Gemini CLI v0.38.x correctly. Regression-tested. Thanks @attid for tracing this to the exact bundled chunk path — made the fix straightforward.
Fixed — landed via PR #105 (@attid) in v0.16.0.
Thanks @attid for the PR and for the detailed write-up. The new bundled-chunks discovery path handles v0.38.x correctly and is version-robust going forward. Regression-tested.