fix(gateway): preserve multiplex profile in model picker - #63447
fix(gateway): preserve multiplex profile in model picker#63447cresslank wants to merge 1 commit into
Conversation
97714d4 to
60dcc1d
Compare
|
Rebased onto current Validation after rebase:
All GitHub checks now pass (23 successful, 7 expected skips, 1 neutral OSV check), and the PR reports |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused multiplex picker fix. The current-main premise is real: gateway/slash_commands.py:1506 selects from the default adapter map, while secondary adapters live in the profile registry.
Problems
- Blocking: the initial picker setup remains outside the routed profile scope. Production dispatch calls
_handle_model_command()directly atgateway/run.py:9930;_load_gateway_config()uses the default home unless an override scope is active (gateway/run.py:2335-2355). The new scope only wraps the deferred callback, so a named profile can still build its picker from default-profile config/providers.
Suggested changes
- Scope the initial config/provider-list work with the captured profile home as well as the callback.
- Update
tests/gateway/test_model_picker_persist.pyto invoke production dispatch without manually entering_profile_runtime_scope; the current test does so at PR line 310 and masks this gap.
Automated hermes-sweeper review.
| from hermes_cli.providers import get_label | ||
|
|
||
| raw_args = event.get_command_args().strip() | ||
| source = event.source |
There was a problem hiding this comment.
Capturing the routed home is not sufficient for the initial picker setup: production dispatch reaches this handler without _profile_runtime_scope (gateway/run.py:9930), so the subsequent _load_gateway_config() still reads the default home. Please scope the initial config/provider-list work with this captured home too; the deferred callback scope only fixes the later selection phase.
|
Merged via PR #65700 — your commit was cherry-picked onto current main with your authorship preserved in git log (rebase merge). All three gaps you found were confirmed live: the picker's default-adapter-map straggler, the unscoped selection callback, and |
What does this PR do?
Preserves one exact multiplex profile identity across the gateway
/modelpicker: adapter selection, deferred callback credential resolution, and global config read/write.On current
main, the picker readsself.adaptersdirectly, so a named-profile event can present through the default profile's adapter. The storedon_model_selectedcallback also runs after the routed profile scope has exited, and--globalcan seed a named-profile write from the default profile's config.This resolves the adapter with
_adapter_for_source(source), captures the routed profile home once, and re-enters that scope when the deferred callback runs. The same captured home selects the config file used for persistence.Related Issue
Follow-up to #58587. Complements #61488 and #48187; it does not duplicate their session-default or context-length policy changes.
Type of Change
Changes Made
gateway/slash_commands.py: route the picker through the profile-aware adapter registry.gateway/slash_commands.py: capture the routed profile home for deferred callback execution and profile-local config persistence.tests/gateway/test_model_picker_persist.py: exercise the production handler, profile secret scope, routed adapter registry, and profile-local config write.How to Test
Use a temporary
HERMES_HOMEwithplugins.enabled: []so a user plugin cannot mask core behavior.On unpatched current
main, run the two new multiplex picker tests: both fail because the default adapter captures the picker.On this branch, run:
Result:
23 passed.Additional validation:
All clean.
Not in Scope
/modelsession-default policy; fix(gateway): default /model to session scope on messaging platforms #61488 covers that.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — N/A; behavior is covered by code comments and testscli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs