fix: propagate custom_providers key_env into ProviderDef (salvage #14353) - #54767
Merged
Merged
Conversation
resolve_custom_provider() previously returned api_key_env_vars=() for every custom provider entry, silently dropping the configured key_env field. This caused 401 errors for any custom provider that required an API key via environment variable (e.g. Xiaomi MiMo Token Plan, self-hosted OpenAI-compatible servers). The key_env field is already documented in _VALID_CUSTOM_PROVIDER_FIELDS and normalized by normalize_custom_provider_entry(), so this was just an oversight in the ProviderDef construction. Also adds a regression test that verifies key_env is properly propagated into the resolved ProviderDef.
Contributor
🔎 Lint report:
|
This was referenced Aug 3, 2026
Open
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
resolve_custom_provider()now propagates a custom provider's configuredkey_envintoProviderDef.api_key_env_varsinstead of hardcoding(), so config-driven readiness checks see the env var.Root cause: the
custom_providers:-list path droppedkey_envwhile the parallelproviders:-dict path (resolve_user_provider) read it correctly — an asymmetry. The dropped value madehermes doctor,hermes setupstatus, and the dashboard config view falsely report the key as missing. (Live runtime auth is resolved separately inruntime_provider.py, so this is a readiness/display bug, not a fresh 401 on every request.)Salvage of #14353 by @telos-oc. The function moved from
model_switch.pytohermes_cli/providers.pysince the PR was opened; the fix translates directly.Changes
hermes_cli/providers.py: readkey_envand passtuple(env_vars)toProviderDefat the named-match return (@telos-oc's original fix) and at the bare-"custom"self-heal return (sibling site widened in this salvage —first_validnow stashes the env tuple).tests/:test_resolve_custom_provider_passes_key_env(named) +test_resolve_custom_provider_bare_custom_self_heal_passes_key_env(self-heal regression).scripts/release.py: AUTHOR_MAP entry for @telos-oc.Validation
custom:token-plan)()("XIAOMI_MIMO_API_KEY",)customself-heal()("XIAOMI_MIMO_API_KEY",)resolve_provider_full(doctor/setup)()("XIAOMI_MIMO_API_KEY",)key_envconfigured()()28/28 in
tests/hermes_cli/test_model_switch_custom_providers.pypass; E2E verified with real imports across all three resolution paths.Infographic
Nous Research