Skip to content

refactor: unify setup wizard provider selection with hermes model - #4200

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-bf538de7
Mar 31, 2026
Merged

refactor: unify setup wizard provider selection with hermes model#4200
teknium1 merged 1 commit into
mainfrom
hermes/hermes-bf538de7

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #4180. Eliminates the root cause of the entire class of setup wizard config overwrite bugs by unifying the provider/model selection code path.

setup_model_provider() had 800+ lines of duplicated provider handling that reimplemented the same credential prompting, OAuth flows, and model selection that hermes model already provides. Every new provider had to be added in both places, and the two implementations diverged in config persistence patterns (raw YAML writes, _set_model_provider, _update_config_for_provider depending on which provider — inconsistent and error-prone).

Fix: Extract the core of cmd_model() into select_provider_and_model() and have setup_model_provider() call it. After the call, re-sync the wizard's config dict from disk. Deletes ~800 lines of duplicated provider handling from setup.py.

Also fixes cmd_model() double-AuthError crash on fresh installs with no API keys configured.

Changes

  • hermes_cli/main.py — Extract select_provider_and_model() from cmd_model(), fix double-AuthError (+16 lines)
  • hermes_cli/setup.py — Replace 800+ lines of inline provider handling with delegation (-815 lines)
  • tests/hermes_cli/test_setup.py — Rewrite to test delegation + config sync
  • tests/hermes_cli/test_setup_model_provider.py — Rewrite to test delegation + config sync

Net: -1135 lines

Test plan

  • 5008 tests pass (2 pre-existing failures from refactor: make config.yaml the single source of truth for endpoint URLs #4165)
  • E2E: hermes setup → Model & Provider → Custom endpoint → config survives wizard's final save
  • E2E: hermes setup → Model & Provider → OpenRouter → config correct
  • E2E: hermes setup → Model & Provider → Cancel → config unchanged
  • All setup-related test files pass (27 tests across 5 files)
  • No broken imports — all symbols still exist in setup.py

)

setup_model_provider() had 800+ lines of duplicated provider handling
that reimplemented the same credential prompting, OAuth flows, and model
selection that hermes model already provides via the _model_flow_*
functions.  Every new provider had to be added in both places, and the
two implementations diverged in config persistence (setup.py did raw
YAML writes, _set_model_provider, and _update_config_for_provider
depending on the provider — main.py used its own load/save cycle).

This caused the #4172 bug: _model_flow_custom saved config to disk but
the wizard's final save_config(config) overwrote it with stale values.

Fix: extract the core of cmd_model() into select_provider_and_model()
and have setup_model_provider() call it.  After the call, re-sync the
wizard's config dict from disk.  Deletes ~800 lines of duplicated
provider handling from setup.py.

Also fixes cmd_model() double-AuthError crash on fresh installs with
no API keys configured.
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Supply Chain Risk Detected

This PR contains patterns commonly associated with supply chain attacks. This does not mean the PR is malicious — but these patterns require careful human review before merging.

⚠️ WARNING: Install hook files modified

These files can execute code during package installation or interpreter startup.

Files:

hermes_cli/setup.py
tests/hermes_cli/test_setup.py

Automated scan triggered by supply-chain-audit. If this is a false positive, a maintainer can approve after manual review.

@teknium1
teknium1 merged commit 491e79b into main Mar 31, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant