fix(model): clear stale endpoint credentials on provider switch - #49360
Closed
helix4u wants to merge 2 commits into
Closed
fix(model): clear stale endpoint credentials on provider switch#49360helix4u wants to merge 2 commits into
helix4u wants to merge 2 commits into
Conversation
helix4u
marked this pull request as ready for review
June 20, 2026 02:08
Collaborator
|
Related: #49362 (concurrent competing fix for the same stale-credential bug, filed ~90s later by a different author — it covers the same Both this PR and #49362 fix the |
Contributor
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?
Fixes stale inline model endpoint credentials surviving provider switches.
Root cause: several model switch paths wrote
model.provider,model.default, and sometimesmodel.base_urldirectly toconfig.yamlwithout clearing inline custom endpoint fields from the previous provider. If the previous config hadmodel.api_key, legacymodel.api, ormodel.api_mode, those stale fields could persist after switching to Nous Portal, OpenRouter, Anthropic/API-key providers, Desktop model assignment, or gateway/model --globalpersistence.This adds a shared config helper for clearing endpoint credentials and applies it across the direct write paths that bypassed or undid the existing
_update_config_for_provider()cleanup.Related/overlap:
key_envresolution from.env.Related Issue
No GitHub issue. Found from Discord support reports around stale custom provider config surviving model switches.
Type of Change
Changes Made
hermes_cli/config.py: addclear_model_endpoint_credentials()formodel.api_key, legacymodel.api, andmodel.api_modecleanup.hermes_cli/auth.py: route_update_config_for_provider()through the shared helper.hermes_cli/model_setup_flows.py: clear stale endpoint credentials in Nous, OpenRouter, Azure Foundry, Copilot, Copilot ACP, Kimi, StepFun, Bedrock/Mantle, Bedrock, generic API-key providers, and Anthropic flows.hermes_cli/web_server.py: clear stale main/auxiliary model endpoint credentials when switching providers through the web/Desktop assignment path.gateway/slash_commands.py: clear stale endpoint credentials when/model --globalpersists a non-custom provider selection.How to Test
config.yamlcontaining a custom provider undermodelwithapi_key, legacyapi, andapi_mode./model --globalpicker.Validation run locally:
git diff --check -- gateway/slash_commands.py hermes_cli/auth.py hermes_cli/config.py hermes_cli/model_setup_flows.py hermes_cli/web_server.py tests/cli/test_cli_provider_resolution.py tests/gateway/test_model_picker_persist.py tests/hermes_cli/test_update_config_clears_custom_fields.py tests/hermes_cli/test_web_server.py.venv/bin/python -m py_compile hermes_cli/config.py hermes_cli/auth.py hermes_cli/model_setup_flows.py hermes_cli/web_server.py gateway/slash_commands.py tests/cli/test_cli_provider_resolution.py tests/hermes_cli/test_update_config_clears_custom_fields.py tests/hermes_cli/test_web_server.py tests/gateway/test_model_picker_persist.py.venv/bin/pythonhelper/web assignment regression probe: passed.venv/bin/pythonOpenRouter/Anthropic flow regression probe against tempHERMES_HOME: passedI did not run the full pytest suite in this WSL checkout.
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — N/Acli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs
Direct regression checks passed for the helper/web assignment path and OpenRouter/Anthropic flow writes against temporary Hermes homes.