Skip to content

fix: clear stale api_key when switching custom providers#8571

Open
yiminglin-ai wants to merge 1 commit into
NousResearch:mainfrom
yiminglin-ai:fix/clear-stale-custom-provider-api-key
Open

fix: clear stale api_key when switching custom providers#8571
yiminglin-ai wants to merge 1 commit into
NousResearch:mainfrom
yiminglin-ai:fix/clear-stale-custom-provider-api-key

Conversation

@yiminglin-ai

Copy link
Copy Markdown

Summary

  • clear model.api_key when switching to a saved custom provider that does not define an API key
  • keep the existing api_mode behavior intact
  • extend the named custom-provider regression test to cover stale auth cleanup

Problem

_model_flow_named_custom() already clears stale api_mode when the selected custom_providers entry does not specify one, but it leaves a stale model.api_key behind.

That means switching from an authenticated custom endpoint to a no-key local endpoint can preserve the old key in config.yaml, which is incorrect state and can affect subsequent requests.

Testing

  • /Users/yiminglin/.hermes/hermes-agent/venv/bin/pytest -q tests/hermes_cli/test_custom_provider_model_switch.py
  • manual temp-HERMES_HOME reproducer showing model.api_key is removed when selecting a no-key provider

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles labels Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants