fix(cli): resolve --model <alias> through model_aliases in interactive chat (#62491) - #62534
LavyaTandel wants to merge 2 commits into
Conversation
|
Ping for review. Root-cause fix for #62491 (CLI --model ignored, 400s on OpenRouter). Reuses model_switch.DIRECT_ALIASES at the HermesCLI init choke point. 24/24 provider-resolution tests pass. CI gated by first-time-contributor approval. |
e817843 to
7b4402e
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing this to the interactive HermesCLI path. Current main still forwards the raw model from hermes_cli/main.py:2409 and assigns it directly in cli.py:3804, so the underlying bug remains.
Problems
cli.py:3857makes an aliasbase_urloverride a caller-suppliedbase_url.cli.mainforwards that argument atcli.py:15908, and the initializer states CLI arguments take precedence atcli.py:3796. This would change explicit endpoint selection whenever an alias includesbase_url.
Suggested changes
- Preserve an explicit
base_urlahead of the alias URL, and add a regression test for that precedence alongside the alias-routing test.
Automated hermes-sweeper review.
| @@ -3835,11 +3855,16 @@ def __init__( | |||
| ) | |||
|
|
|||
| self._explicit_api_key = api_key | |||
There was a problem hiding this comment.
Please preserve an explicitly supplied base_url ahead of the alias URL. cli.main forwards base_url into this constructor (cli.py:15908), and the initializer's documented precedence is CLI args before config (cli.py:3796); this branch currently replaces that explicit endpoint whenever an alias declares one.
|
Fixed #62534: |
|
Re-ping for merge. All review notes from the keep_open verdict are addressed in-branch:
The only blocker is CI not running on this fork branch (first-time-contributor approval gating). Could a maintainer approve the run so mergeability can be computed? Happy to rebase on current main if anything drifted. |
|
Ping for review — resolves --model through model_aliases in interactive chat (#62491). Rebased onto latest main; CI gated by first-time-contributor action_required. |
|
Friendly ping — rebased onto current main, tests green, only blocker is first-time-contributor CI approval. Ready when you have time. |
c1517f0 to
e763a5d
Compare
|
Independent verification (dedup campaign worker, current main @ 037825c): Premise confirmed. Regression test is real. Applied this PR's cli.py diff to a fresh clone of current main, ran the added tests:
The single-choke-point approach (resolve once in the constructor, explicit |
|
Hi @b Mentioning for visibility. All checks are red due to the first-time-contributor Could you please approve a workflow run so the checks can execute? Local verification results:
All PRs rebased onto latest |
Summary
Fixes #62491 —
hermes chat --model <alias>ignoresmodel_aliases, sending the alias verbatim to the configured default provider (OpenRouter) → HTTP 400. The GUI picker reads these aliases; the CLI chat path did not.Root cause (
cli.py,HermesCLI.__init__)self.model = model or _config_modelandself.requested_providerwere set from the raw--model/--providerargs with no consultation ofmodel_aliases. The alias-resolution logic existed only inhermes_cli/oneshot.py(thehermes -zpath) — not in the interactive-chat path, which flows throughHermesCLI.__init__→_ensure_runtime_credentials. So an alias withprovider: custom+base_url: http://localhost:...was turned intoopenrouter+ model=gemma, and--provider customalongside it was also bypassed.Fix (single choke point, root cause not symptom)
In
HermesCLI.__init__, resolve the--modelarg againstmodel_switch.DIRECT_ALIASES(the same loaded aliases the GUI/oneshot use — no re-parsing, no new abstraction) before the default provider is attached:self.model← alias target modelself.requested_provider← alias provider (only when--providernot explicitly given)self._explicit_base_url/self.base_url← aliasbase_url(when present)Explicit
--provider customstill wins; a non-alias model is untouched (falls through to configured defaults as before). Both reporter cases now route correctly.Test plan
tests/cli/test_cli_provider_resolution.py(addedtest_cli_model_alias_resolves_to_target_provider_and_base_url, full file 24 passed):hermes chat --model gemma→model=gemma-4-31B-it-qat-bf16,requested_provider=custom,base_url=http://localhost:1234/v1--model gemma --provider custom→ still resolves to the alias target (no break)anthropic/claude-3.5) → unchanged,requested_provider=openrouterVerification
Risk
cli.pyonly; adds one alias lookup at the existing model-init site, reusingmodel_switch.DIRECT_ALIASES. No change to oneshot behavior or the GUI picker. repowiserisk: 2nd percentile (low).