fix(model): default --provider switches to session-only persistence - #58371
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(model): default --provider switches to session-only persistence#58371liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
When /model is called with --provider but without --global or --session, the switch now defaults to session-only instead of persisting to config.yaml. Provider switches are typically exploratory — the user is trying a different backend for this conversation, not reconfiguring the default. --global can still force persist when desired. This addresses a regression from fad4b40 where /model switched to persist-by-default, causing /model xxx --provider xxx to overwrite the global config when the user only intended a temporary switch. Fixes NousResearch#58290
2 tasks
Contributor
|
Thanks for tracing the behavior across CLI, gateway, and TUI. Problems
Suggested changes
Automated hermes-sweeper review. |
teknium1
added a commit
that referenced
this pull request
Jul 20, 2026
Flip the resolve_persist_behavior() fallback from persist-to-config to session-only. A plain /model <name> (typed or via any picker — CLI, TUI/Desktop, gateway) now affects only the current session; --global persists explicitly, and model.persist_switch_by_default: true restores the old opt-out behavior for users who want switches to stick. This is the root cause behind the recurring 'session switch applied globally' bug class (#61458, #63083, #58290, #61190): every surface funnels its no-flag default through this one function, so per-surface patches kept missing paths. Fixing the default fixes all surfaces at once: CLI typed + picker, TUI/Desktop config.set + slash, gateway typed + inline picker. Builds on liuhao1024's #58371 (--provider session scoping, cherry-picked as the previous commit) and supersedes the per-surface #61488.
13 tasks
Contributor
|
Merged via PR #67946 — your commit from #58371 was cherry-picked onto current main with your authorship preserved in git log (rebase merge). The session-only default you built for --provider switches is now the default for ALL /model switches on every surface, so this PR's gateway-specific half is covered by the same root fix. Thanks for the clean fix and the tests — they shipped with your name on them. |
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
Flip the resolve_persist_behavior() fallback from persist-to-config to session-only. A plain /model <name> (typed or via any picker — CLI, TUI/Desktop, gateway) now affects only the current session; --global persists explicitly, and model.persist_switch_by_default: true restores the old opt-out behavior for users who want switches to stick. This is the root cause behind the recurring 'session switch applied globally' bug class (NousResearch#61458, NousResearch#63083, NousResearch#58290, NousResearch#61190): every surface funnels its no-flag default through this one function, so per-surface patches kept missing paths. Fixing the default fixes all surfaces at once: CLI typed + picker, TUI/Desktop config.set + slash, gateway typed + inline picker. Builds on liuhao1024's NousResearch#58371 (--provider session scoping, cherry-picked as the previous commit) and supersedes the per-surface NousResearch#61488.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
When
/modelis called with--providerbut without--globalor--session, the switch now defaults to session-only instead of persisting toconfig.yaml.Before this change,
/model sonnet --provider anthropicwould overwritemodel.defaultandmodel.providerinconfig.yaml, which is unexpected when the user is just trying a different provider for the current conversation. The--globalflag still forces persistence when explicitly desired.Related Issue
Fixes #58290
Type of Change
Changes Made
hermes_cli/model_switch.py: Addedexplicit_providerparameter toresolve_persist_behavior(). When a provider is explicitly specified without--global/--session, returnsFalse(session-only).gateway/slash_commands.py: Passexplicit_providertoresolve_persist_behavior()in the gateway/modelhandler.tui_gateway/server.py: Passexplicit_providertoresolve_persist_behavior()in the TUI/modelhandler.cli.py: Passexplicit_providertoresolve_persist_behavior()in the CLI/modelhandler.tests/hermes_cli/test_model_switch_persist_default.py: Added 4 test cases covering--providerflag behavior with and without--global/--session.How to Test
pytest tests/hermes_cli/test_model_switch_persist_default.py -v— all 17 tests should pass./model sonnet --provider anthropic— the model should switch for this session only, andconfig.yamlshould remain unchanged./model sonnet --provider anthropic --global— this should persist toconfig.yamlas before./model sonnet(no--provider) — this should persist toconfig.yaml(existing behavior unchanged).Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/hermes_cli/test_model_switch_persist_default.py -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A