fix(gateway): honour HERMES_INFERENCE_PROVIDER in _resolve_startup_runtime (#16857)#16873
Closed
Bartok9 wants to merge 1 commit into
Closed
Conversation
…ntime (NousResearch#16857) When /model switches to a model served via a custom provider (e.g. custom:xuanji) and the model name also exists in a native provider's static catalog (e.g. deepseek-v4-pro in the native deepseek catalog), /new incorrectly overrides the custom provider with the native one, causing 'no API key' errors. Root cause: _resolve_startup_runtime() passed HERMES_INFERENCE_PROVIDER as the current_provider hint to detect_static_provider_for_model(), but custom providers have no static catalog, so the function fell through to matching native catalogs by model name. Fix: check HERMES_INFERENCE_PROVIDER immediately after HERMES_TUI_PROVIDER and return early when set. This env var is written by /model and represents the user's explicit provider choice — it must not be overridden by static detection. Also removes the now-redundant HERMES_INFERENCE_PROVIDER read from the current_provider fallback chain, since it can never be reached. Tests: updated existing test and added two new tests covering: - HERMES_INFERENCE_PROVIDER is honoured (static detection skipped) - HERMES_TUI_PROVIDER still takes precedence over HERMES_INFERENCE_PROVIDER Fixes NousResearch#16857
teknium1
added a commit
that referenced
this pull request
Apr 28, 2026
#16897) `/new` after `/model <custom-provider>:<model>` silently reverted to a native provider whose static catalog happened to contain the same model name (e.g. `deepseek-v4-pro` → native `deepseek` → 401). Root cause at the `/model` writeback site: `HERMES_INFERENCE_PROVIDER` was set unconditionally but `HERMES_TUI_PROVIDER` was only mirrored when it was already set. On sessions launched without `--provider`, `HERMES_TUI_PROVIDER` stayed unset, so `_resolve_startup_runtime()` on `/new` skipped the explicit-provider early return and fell through to `detect_static_provider_for_model()`. Fix: set `HERMES_TUI_PROVIDER` unconditionally alongside `HERMES_INFERENCE_PROVIDER` when `/model` lands. Keeps #15755's invariant intact — `HERMES_TUI_PROVIDER` remains the canonical "explicit this process" carrier, `HERMES_INFERENCE_PROVIDER` remains ambient and does not short-circuit startup resolution. Bug report and diagnosis: @Bartok9 in #16857 / #16873. Fixes #16857
Contributor
|
Superseded by #16897 — merged to main. Your diagnosis in #16857 and the initial fix here were spot on. The salvage applies the fix at the Credited in the merge commit and PR body. Thanks for the report and the clean reproduction steps! |
cluricaun28
referenced
this pull request
in cluricaun28/Logos
Apr 28, 2026
…) (#16897) `/new` after `/model <custom-provider>:<model>` silently reverted to a native provider whose static catalog happened to contain the same model name (e.g. `deepseek-v4-pro` → native `deepseek` → 401). Root cause at the `/model` writeback site: `HERMES_INFERENCE_PROVIDER` was set unconditionally but `HERMES_TUI_PROVIDER` was only mirrored when it was already set. On sessions launched without `--provider`, `HERMES_TUI_PROVIDER` stayed unset, so `_resolve_startup_runtime()` on `/new` skipped the explicit-provider early return and fell through to `detect_static_provider_for_model()`. Fix: set `HERMES_TUI_PROVIDER` unconditionally alongside `HERMES_INFERENCE_PROVIDER` when `/model` lands. Keeps #15755's invariant intact — `HERMES_TUI_PROVIDER` remains the canonical "explicit this process" carrier, `HERMES_INFERENCE_PROVIDER` remains ambient and does not short-circuit startup resolution. Bug report and diagnosis: @Bartok9 in #16857 / #16873. Fixes #16857
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
…search#16857) (NousResearch#16897) `/new` after `/model <custom-provider>:<model>` silently reverted to a native provider whose static catalog happened to contain the same model name (e.g. `deepseek-v4-pro` → native `deepseek` → 401). Root cause at the `/model` writeback site: `HERMES_INFERENCE_PROVIDER` was set unconditionally but `HERMES_TUI_PROVIDER` was only mirrored when it was already set. On sessions launched without `--provider`, `HERMES_TUI_PROVIDER` stayed unset, so `_resolve_startup_runtime()` on `/new` skipped the explicit-provider early return and fell through to `detect_static_provider_for_model()`. Fix: set `HERMES_TUI_PROVIDER` unconditionally alongside `HERMES_INFERENCE_PROVIDER` when `/model` lands. Keeps NousResearch#15755's invariant intact — `HERMES_TUI_PROVIDER` remains the canonical "explicit this process" carrier, `HERMES_INFERENCE_PROVIDER` remains ambient and does not short-circuit startup resolution. Bug report and diagnosis: @Bartok9 in NousResearch#16857 / NousResearch#16873. Fixes NousResearch#16857
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…search#16857) (NousResearch#16897) `/new` after `/model <custom-provider>:<model>` silently reverted to a native provider whose static catalog happened to contain the same model name (e.g. `deepseek-v4-pro` → native `deepseek` → 401). Root cause at the `/model` writeback site: `HERMES_INFERENCE_PROVIDER` was set unconditionally but `HERMES_TUI_PROVIDER` was only mirrored when it was already set. On sessions launched without `--provider`, `HERMES_TUI_PROVIDER` stayed unset, so `_resolve_startup_runtime()` on `/new` skipped the explicit-provider early return and fell through to `detect_static_provider_for_model()`. Fix: set `HERMES_TUI_PROVIDER` unconditionally alongside `HERMES_INFERENCE_PROVIDER` when `/model` lands. Keeps NousResearch#15755's invariant intact — `HERMES_TUI_PROVIDER` remains the canonical "explicit this process" carrier, `HERMES_INFERENCE_PROVIDER` remains ambient and does not short-circuit startup resolution. Bug report and diagnosis: @Bartok9 in NousResearch#16857 / NousResearch#16873. Fixes NousResearch#16857
dannyJ848
pushed a commit
to dannyJ848/hermes-agent
that referenced
this pull request
May 17, 2026
…search#16857) (NousResearch#16897) `/new` after `/model <custom-provider>:<model>` silently reverted to a native provider whose static catalog happened to contain the same model name (e.g. `deepseek-v4-pro` → native `deepseek` → 401). Root cause at the `/model` writeback site: `HERMES_INFERENCE_PROVIDER` was set unconditionally but `HERMES_TUI_PROVIDER` was only mirrored when it was already set. On sessions launched without `--provider`, `HERMES_TUI_PROVIDER` stayed unset, so `_resolve_startup_runtime()` on `/new` skipped the explicit-provider early return and fell through to `detect_static_provider_for_model()`. Fix: set `HERMES_TUI_PROVIDER` unconditionally alongside `HERMES_INFERENCE_PROVIDER` when `/model` lands. Keeps NousResearch#15755's invariant intact — `HERMES_TUI_PROVIDER` remains the canonical "explicit this process" carrier, `HERMES_INFERENCE_PROVIDER` remains ambient and does not short-circuit startup resolution. Bug report and diagnosis: @Bartok9 in NousResearch#16857 / NousResearch#16873. Fixes NousResearch#16857
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…search#16857) (NousResearch#16897) `/new` after `/model <custom-provider>:<model>` silently reverted to a native provider whose static catalog happened to contain the same model name (e.g. `deepseek-v4-pro` → native `deepseek` → 401). Root cause at the `/model` writeback site: `HERMES_INFERENCE_PROVIDER` was set unconditionally but `HERMES_TUI_PROVIDER` was only mirrored when it was already set. On sessions launched without `--provider`, `HERMES_TUI_PROVIDER` stayed unset, so `_resolve_startup_runtime()` on `/new` skipped the explicit-provider early return and fell through to `detect_static_provider_for_model()`. Fix: set `HERMES_TUI_PROVIDER` unconditionally alongside `HERMES_INFERENCE_PROVIDER` when `/model` lands. Keeps NousResearch#15755's invariant intact — `HERMES_TUI_PROVIDER` remains the canonical "explicit this process" carrier, `HERMES_INFERENCE_PROVIDER` remains ambient and does not short-circuit startup resolution. Bug report and diagnosis: @Bartok9 in NousResearch#16857 / NousResearch#16873. Fixes NousResearch#16857
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
…search#16857) (NousResearch#16897) `/new` after `/model <custom-provider>:<model>` silently reverted to a native provider whose static catalog happened to contain the same model name (e.g. `deepseek-v4-pro` → native `deepseek` → 401). Root cause at the `/model` writeback site: `HERMES_INFERENCE_PROVIDER` was set unconditionally but `HERMES_TUI_PROVIDER` was only mirrored when it was already set. On sessions launched without `--provider`, `HERMES_TUI_PROVIDER` stayed unset, so `_resolve_startup_runtime()` on `/new` skipped the explicit-provider early return and fell through to `detect_static_provider_for_model()`. Fix: set `HERMES_TUI_PROVIDER` unconditionally alongside `HERMES_INFERENCE_PROVIDER` when `/model` lands. Keeps NousResearch#15755's invariant intact — `HERMES_TUI_PROVIDER` remains the canonical "explicit this process" carrier, `HERMES_INFERENCE_PROVIDER` remains ambient and does not short-circuit startup resolution. Bug report and diagnosis: @Bartok9 in NousResearch#16857 / NousResearch#16873. Fixes NousResearch#16857
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.
Summary
Fixes #16857 —
/newafter/modelswitch to a custom provider model fails with "no API key" when the model name also exists in a native provider catalog.Root Cause
In
_resolve_startup_runtime(),HERMES_INFERENCE_PROVIDER(set by/model) was passed as a hint todetect_static_provider_for_model(), but custom providers have no static catalog. The function fell through to matching native catalogs by model name, overriding the explicit custom provider choice with the coincidentally-matching native provider.Example:
/model deepseek-v4-proviacustom:xuanji→/new→detect_static_provider_for_modelmatches nativedeepseekcatalog → tries to useDEEPSEEK_API_KEY→ 401.Fix
Check
HERMES_INFERENCE_PROVIDERimmediately afterHERMES_TUI_PROVIDERand return early when set. This env var is written by/modeland represents the user's explicit provider choice — static catalog detection must not override it.Also removes the now-redundant
HERMES_INFERENCE_PROVIDERread from thecurrent_providerfallback chain (line 651 of the original), since the early return means it can never be reached.Changes
tui_gateway/server.py: Early-return onHERMES_INFERENCE_PROVIDERbefore static detectiontests/test_tui_gateway_server.py: Updated existing test + added 2 new testsTesting
Test coverage:
test_startup_runtime_honours_inference_provider_envtest_startup_runtime_inference_provider_does_not_override_tui_providerHERMES_TUI_PROVIDERstill takes precedenceHow to verify manually
/model <overlapping-model-name>→ should switch to custom provider/new→ should start new session with the custom provider, not the native one