Skip to content

fix(cli): honor user-defined providers via chat --provider and -m <alias> (#16767)#16924

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-5bbee8dc
Apr 28, 2026
Merged

fix(cli): honor user-defined providers via chat --provider and -m <alias> (#16767)#16924
teknium1 merged 3 commits into
mainfrom
hermes/hermes-5bbee8dc

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvages #16811 by @westers onto current main.

Closes #16767.

User-defined providers configured in ~/.hermes/config.yaml (providers: dict + model_aliases:) were silently dropped by two CLI paths, so requests routed to the wrong endpoint.

Changes (cherry-picked from #16811, +66/-39)

  • hermes_cli/main.py: drop hardcoded choices= on chat subparser --provider — top-level --provider already had none.
  • hermes_cli/oneshot.py: consult DIRECT_ALIASES before detect_provider_for_model; thread alias base_url to resolve_runtime_provider(explicit_base_url=...).
  • hermes_cli/runtime_provider.py: _resolve_named_custom_runtime honors provider="custom" + explicit_base_url so alias-propagated base_urls build a runtime directly.
  • hermes_cli/model_switch.py: _ensure_direct_aliases uses .update() instead of rebinding (defensive).
  • scripts/release.py: AUTHOR_MAP entry for westers.

Validation

  • tests/hermes_cli/test_regression_16767.py (3/3) — includes regressions that catch each of the three target bugs.
  • 263 related hermes_cli tests pass.
  • E2E with user's exact reproduction config: -m my-31b now resolves to base_url=http://localhost:11435/v1 via source=direct-alias (was http://localhost:8080/v1 from stale model.base_url fallback). chat --provider host-b accepted by argparse.

Credit: @westers — commits preserved via rebase-merge.

westers and others added 3 commits April 28, 2026 01:42
…ias>

Three related issues prevented user-defined providers in `providers:` and
`model_aliases:` from being reachable through standard CLI flags. Requests
silently routed to the configured `model.base_url` instead of the user-
intended endpoint.

* hermes_cli/model_switch.py — root cause of the silent misrouting:
  `_ensure_direct_aliases()` rebound `DIRECT_ALIASES` to a freshly-loaded
  dict, leaving every `from hermes_cli.model_switch import DIRECT_ALIASES`
  caller stuck on the stale empty original. Switched to `.update()` so
  module attribute references stay valid.

* hermes_cli/main.py — chat subcommand `--provider` had `choices=[...]`
  hardcoded to built-in providers, rejecting valid keys from user
  `providers:` config. Dropped the choices list; runtime resolution
  validates correctly downstream.

* hermes_cli/oneshot.py — `-m <alias>` only resolved the model name; the
  alias's base_url was never propagated. Now consults `DIRECT_ALIASES`
  before falling through to `detect_provider_for_model`, and threads the
  alias's base_url to `resolve_runtime_provider(explicit_base_url=...)`.

* hermes_cli/runtime_provider.py — `_resolve_named_custom_runtime` now
  honors `(provider="custom", explicit_base_url=...)` so a base_url
  propagated from a direct-alias resolution actually builds a runtime
  instead of falling through to provider-registry handlers that don't
  know about ad-hoc local endpoints.

Verified: `hermes chat --provider <user-key> -m <model> -q "..."` and
`hermes -m <user-alias> -z "..."` both route to the user-intended
endpoint, observable via the target server's request log.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@teknium1 teknium1 merged commit 20b49b7 into main Apr 28, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-5bbee8dc branch April 28, 2026 08:47
@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 labels Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

CLI doesn't honor user-defined providers via chat --provider or -m <alias>

3 participants