fix(gateway): make /model session-scoped by default on messaging platforms - #63095
fix(gateway): make /model session-scoped by default on messaging platforms#63095liuhao1024 wants to merge 1 commit into
Conversation
…forms Previously, /model on messaging platforms (gateway) would persist to global config.yaml by default, matching CLI behavior via the model.persist_switch_by_default config setting. This caused unintended cross-session pollution when users switched models in one chat, as the global config change affected all other sessions. On messaging platforms, sessions are typically ephemeral and per-chat, so /model now defaults to session-scoped behavior: the switch applies to the current chat only and survives gateway restart via the session DB, but does not write to config.yaml unless --global is explicitly passed. This differs from CLI behavior (where /model still persists by default) to align with user expectations for messaging platform UX. Fixes NousResearch#63083
Duplicate of #61488 (liuhao... earlier, still open) — diff-compared: both edit |
|
This PR is a duplicate of #$61488. Both PRs fix the same issue (messaging platform /model command defaulting to global config) by modifying the same code path ( PR #$61488 (created 2026-07-09) is the earlier submission with a more explicit implementation (checking Closing this PR in favor of the canonical earlier submission. |
What does this PR do?
Changes
/modelbehavior on messaging platforms (gateway) from persisting to globalconfig.yamlby default to session-scoped by default.Previously,
/modelon gateway would follow CLI behavior via themodel.persist_switch_by_defaultconfig setting, which defaults toTrue. This meant switching models in one chat would write the change to the globalconfig.yaml, affecting all other sessions — unintended cross-session pollution.Messaging platform sessions are typically ephemeral and per-chat, so this PR changes the default to session-scoped: the switch applies to the current chat only, survives gateway restart via the session DB, but does not persist to disk unless
--globalis explicitly passed.This aligns gateway
/modelbehavior with user expectations for messaging platform UX, while CLI behavior (persistence by default) remains unchanged.Related Issue
Fixes #63083
Type of Change
Changes Made
gateway/slash_commands.py: Changedpersist_globallogic to default toFalseon messaging platforms unless--globalis explicitly passed or--sessionis explicitly passed. Added comment explaining the rationale and reference to /model writes to global config.yaml without --global flag on cross-provider switch attempts #63083.tests/gateway/test_model_picker_persist.py: Updatedtest_picker_tap_persists_by_default→test_picker_tap_does_not_persist_by_defaultto reflect the new behavior (session-scoped by default). Added new testtest_picker_tap_with_global_flag_persiststo verify--globalflag works correctly.tests/gateway/test_model_command_flat_string_config.py: Updatedtest_model_no_flag_persists_by_default→test_model_no_flag_does_not_persist_by_defaultto reflect the new behavior.How to Test
/model gpt-5.5(no flags)~/.hermes/config.yaml— should still have model A/model claude-sonnet-4.6 --global~/.hermes/config.yaml— should now have claude-sonnet-4.6pytest tests/gateway/test_model_picker_persist.py tests/gateway/test_model_command_flat_string_config.py -q— all tests passChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -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