fix(gateway): default /model to session scope on messaging platforms - #61488
fix(gateway): default /model to session scope on messaging platforms#61488liuhao1024 wants to merge 3 commits into
Conversation
When users pick models via Telegram/Discord/Slack menus (which cannot send --global/--session flags), the switch now defaults to session-scoped unless --global is explicitly provided. This prevents accidental global config changes from platform picker interactions. Fixes NousResearch#61458
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM
What the PR Does
Default /model picker usage on messaging platforms (Telegram, Discord, Slack, etc.) to session scope, preventing accidental global config changes when users pick models via platform menus.
Assessment
- Correctness: The heuristic correctly identifies messaging platforms by checking
source.platform is not None and source.platform != Platform.LOCAL. The session-scoped override is applied in-memory while leavingconfig.yamluntouched. - Testing: New test
test_picker_tap_is_session_scoped_by_default_on_messaging_platformsverifies both that the session override IS set and thatconfig.yamlremains unchanged. - Security: No security concerns. This reduces accidental config changes — a safety improvement.
Note: PR was previously unreviewed.
Reviewed by Hermes Agent
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment
Overview
- Defaults /model to session scope on messaging platforms
- Small fix (+41/-13)
Looks Good
- Clean, targeted fix
- No security concerns
Reviewed by Hermes Agent
|
Thanks for the focused gateway fix. Current The PR changes the common decision before those paths, preserves explicit Automated hermes-sweeper review. |
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.
|
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. |
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.
What does this PR do?
When users pick models via Telegram/Discord/Slack picker menus, the switch now defaults to session-scoped unless
--globalis explicitly provided. This prevents accidental global config changes from platform picker interactions, which cannot send--global/--sessionflags.Previously, platform picker taps silently persisted to
config.yamlbecauseresolve_persist_behavior()fell back tomodel.persist_switch_by_default=True. This UX failure meant a user selecting a model from a Telegram menu unintentionally made a permanent global configuration change — the opposite of CLI users, who can explicitly opt into persistence with--global.Related Issue
Fixes #61458
Type of Change
Changes Made
gateway/slash_commands.py: Added context-aware default for messaging platforms. Ifsource.platform != Platform.LOCALand no explicit--global/--sessionflags are present, treat as if--sessionwas passed (session-scoped by default).tests/gateway/test_model_picker_persist.py: Updatedtest_picker_tap_persists_by_defaulttotest_picker_tap_is_session_scoped_by_default_on_messaging_platformsto reflect the new expected behavior — picker taps on messaging platforms now apply session overrides in-memory but do not persist toconfig.yaml.How to Test
/modelto open the inline keyboard picker.config.yamlis NOT modified (the default model remains unchanged)./model gpt-5.5 --session→ session-scoped (same as default on messaging platforms)./model gpt-5.5 --global→ persists toconfig.yaml(explicit opt-in).pytest tests/gateway/test_model_picker_persist.py -v— all three tests pass.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/gateway/test_model_picker_persist.py -vand 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