Skip to content

[BUG] Manual model selection with "Remember model" enabled fails to persist on restart #19864

Description

@LyalinDotCom

What happened?

When using the /model command to manually select a specific model (e.g., gemini-3.1-pro-preview) and toggling "Remember model for future sessions" to true via the Tab key, the setting is not honored. Upon restarting the Gemini CLI, the model routing defaults back to Auto (Gemini 3) instead of the manually selected model.

Image

What did you expect to happen?

If "Remember model for future sessions" is set to true, the CLI should persist the manual model selection in the local configuration and automatically load that specific model on the next startup, rather than reverting to the default Auto routing.

Client information

│ About Gemini CLI │
│ │
│ CLI Version 0.29.5 │
│ Git Commit 2ef872e │
│ Model Auto (Gemini 3) │
│ Sandbox no sandbox │
│ OS darwin │
│ Auth Method Logged in with Google │
│ Tier Gemini Code Assist in Google One AI Ultra

Login information

No response

Anything else we need to know?

No response

Activity

  1. added theissue type on Feb 22, 2026
  2. added
    status/need-triageIssues that need to be triaged by the triage automation.
    area/coreIssues related to User Interface, OS Support, Core Functionality
    on Feb 22, 2026
  3. vanshaj2023 commented on Feb 22, 2026

    @vanshaj2023

    Hi @LyalinDotCom

    I'm new to open source but I've been reading through the codebase to understand how model selection works, and I'd like to work on this. Could you assign this to me?

    I traced the flow from ModelDialog.tsx → config.setModel() → onModelChange → saveModelChange() and the persist toggle logic looks correct on paper. I believe the issue is that saveModelChange() calls loadedSettings.setValue() which updates in-memory settings but doesn't actually flush to the user's settings.json on disk unlike saveSettings() which explicitly calls updateSettingsFilePreservingFormat. Another possibility is the persisted model.name getting overridden by the default auto-gemini-3 fallback on startup.

    Is this the right direction or am I missing something?

  4. edwrios commented on Feb 22, 2026

    @edwrios

    @vanshaj2023 Dude lol that was funny for some reason. In general, in every large open source project, there are specifications on how to make PRs. There is a process you must follow to contribute. I suggest you read the documentation (or relevant topics), there is a section for contributing (main README.md). I'll leave the link here just in case: [https://github.com/google-gemini/gemini-cli/blob/main/CONTRIBUTING.md]

  5. Turbo-the-tech-dev commented on Feb 22, 2026

    @Turbo-the-tech-dev

    ✅ WRITING-PLANS ACTIVATED – Gemini CLI Model Persistence Bug #19864 Leveraged
    (Turbo Fleet Command – Feb 21, 2026 – 1 hour after issue opened)

    Project Spec (exact from #19864):
    [BUG] Manual model selection with "Remember model" enabled fails to persist on restart

    Reproduction (verbatim):

    1. Run /model
    2. Select e.g. gemini-3.1-pro-preview
    3. Toggle "Remember model for future sessions" to true (Tab key)
    4. Restart Gemini CLI
      Actual: Reverts to Auto (Gemini 3)
      Expected: Loads the manually chosen model

    Client info: Gemini CLI v0.29.5 • darwin • Tier: Gemini Code Assist in Google One AI Ultra

    No comments yet. Labels: area/core, status/need-triage, Bug

    Goal for our fleet:
    Make nec-fleet-gemini and the Central Documentation Hub bulletproof against this core bug today.
    Force reliable high-intelligence model persistence (ideal for NEC 2026 code accuracy, takeoffs, SRS quiz generation, DEATHSTAR orchestration) while the upstream fix lands.
    Turn the bug into a fleet superpower: one-command model lock + auto-health dashboard.


    MULTI-PHASE EXECUTION PLAN (Before Any Code Touch)

    Phase 0: Lock & Monitoring (Current – 5 min)

    • Lock this spec
    • Auto-watch the issue + linked PRs (via github extension)
    • Confirm preferred model for nec-fleet (gemini-3.1-pro-preview for reasoning depth)
    • Output: Signed-off plan + live issue tracker link

    Success Metric: Commander replies LOCKED

    Phase 1: Immediate Workaround Tool in nec-fleet-gemini (Est. 35 min)

    • New MCP tool: nec_model_lock(modelName, remember=true)
      • Reads/writes ~/.config/gemini-cli/config.json directly
      • Forces exact model + remember flag
      • Graceful fallback if config missing
    • Add slash command /nec:model (new commands/nec/model.toml)
    • Update GEMINI.md persona to auto-recommend it on every startup
    • Output: v1.2 extension with model enforcer

    Phase 2: Central Docs Hub – Dedicated Troubleshooting Page (Est. 45 min)

    • New Starlight page: /docs/troubleshooting/model-persistence.md
      • Step-by-step workaround (our tool + manual config edit)
      • Before/after screenshots
      • "Why this happens" (config serialization bug)
      • One-click copy-paste config snippet
      • Link to upstream issue with "Fixed in vX" placeholder
    • Update homepage + sidebar + nec-fleet section
    • Output: 2 new pages + auto-sync to all repos

    Phase 3: Fleet-Wide Hardening & Footer Integration (Est. 30 min)

    • Add nec_status() tool that shows Current Model • Persisted? • Uptime
    • Tie into the new /footer feature (from PR feat: add custom footer configuration via /footer #19001) – auto-suggest items:
      🔌 NEC 2026 • Model: gemini-3.1-pro-preview (LOCKED) • INDEX: healthy
    • todo-ext reminder + conductor daily model-check task
    • Test on your darwin setup
    • Output: Full dashboard + 100% bug-resilient workflow

    Phase 4: Release, Upstream Contribution & Announcement (Est. 25 min)


    Total Estimated Time: ~2 hours 20 min (can run parallel with maestro)
    Risks & Mitigations:

    • Config path changes → auto-detect + fallback
    • Permission issues on darwin → clear sudo-free instructions
    • Model deprecation → tool auto-suggests next-best (via context7)

    Success Criteria:

    • /nec:model gemini-3.1-pro-preview survives 10 restarts
    • Central Hub page solves the bug for 100% of fleet users
    • Footer shows locked model at all times
    • Zero model drift in nec-fleet sessions

    Fleet Command ready.

    Reply:
    LOCKED → I immediately drop:

    1. Full nec_model_lock tool code
    2. Updated gemini-extension.json + new model.toml
    3. Complete /docs/troubleshooting/model-persistence.md
    4. One-liner test commands for your terminal

    AMEND → tweak anything (preferred model, add voice alert, etc.)
    SKIP TO WORKAROUND → only Phase 1 right now

    This bug hit at the perfect time — we turn it into a fleet advantage before anyone else. ⚡🔌

    Your move, Commander.

  6. Nixxx19 commented on Feb 22, 2026

    @Nixxx19
    Contributor

    looks interesting, would love to crack this

  7. added a commit that references this issue on Feb 22, 2026
    2cd0462
  8. Nixxx19 commented on Feb 22, 2026

    @Nixxx19
    Contributor

    Hi @LyalinDotCom, thanks for raising this. I reproduced it on my machine.

    Issue: With "Remember model" on and a manual preview model (e.g. gemini-3.1-pro-preview), the CLI reverted to Auto on restart. Cause: when quota wasn't fetched, hasAccessToPreviewModel stayed false and the reset logic wrongly cleared the saved model.

    Fix: hasAccessToPreviewModel is now boolean | null (null = unknown). We only reset when it's explicitly false; when null or true we keep the saved model. Same for all auth types. Fix is in PR #19891 and I've validated the fix with your repro steps.

  9. yoganand560 commented on Feb 22, 2026

    @yoganand560

    /assign

  10. gemini-cli commented on Feb 22, 2026

    @gemini-cli
    Contributor

    👋 @yoganand560, you've been assigned to this issue! Thank you for taking the time to contribute. Make sure to check out our contributing guidelines.

  11. 6 remaining items

  12. added
    help wantedWe will accept PRs from all issues marked as "help wanted". Thanks for your support!
    priority/p1Important and should be addressed in the near term.
    and removed
    status/need-triageIssues that need to be triaged by the triage automation.
    on Feb 26, 2026
  13. self-assigned this
    on Mar 4, 2026
  14. sripasg commented on Mar 4, 2026

    @sripasg
    Contributor

    I think from the original bug description - the issue occurs when a user temporarily selects a model, then attempts to select the identical model with persistence (--persist flag or Remember checked). Currently, config.ts checks if the model has changed, and if not, completely bypasses the onModelChange callback that saves the setting to disk.
    Will send a PR for this here shortly.

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

Metadata

Metadata

Assignees

Labels

area/coreIssues related to User Interface, OS Support, Core Functionalityhelp wantedWe will accept PRs from all issues marked as "help wanted". Thanks for your support!priority/p1Important and should be addressed in the near term.type/bug

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions