Skip to content

fix: propagate custom_providers key_env into ProviderDef (salvage #14353) - #54767

Merged
teknium1 merged 2 commits into
mainfrom
fix/custom-provider-key-env-salvage
Jun 29, 2026
Merged

teknium1 merged 2 commits into
mainfrom
fix/custom-provider-key-env-salvage

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

Summary

resolve_custom_provider() now propagates a custom provider's configured key_env into ProviderDef.api_key_env_vars instead of hardcoding (), so config-driven readiness checks see the env var.

Root cause: the custom_providers:-list path dropped key_env while the parallel providers:-dict path (resolve_user_provider) read it correctly — an asymmetry. The dropped value made hermes doctor, hermes setup status, and the dashboard config view falsely report the key as missing. (Live runtime auth is resolved separately in runtime_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.py to hermes_cli/providers.py since the PR was opened; the fix translates directly.

Changes

  • hermes_cli/providers.py: read key_env and pass tuple(env_vars) to ProviderDef at the named-match return (@telos-oc's original fix) and at the bare-"custom" self-heal return (sibling site widened in this salvage — first_valid now 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

Path Before After
named match (custom:token-plan) () ("XIAOMI_MIMO_API_KEY",)
bare-custom self-heal () ("XIAOMI_MIMO_API_KEY",)
resolve_provider_full (doctor/setup) () ("XIAOMI_MIMO_API_KEY",)
no key_env configured () ()

28/28 in tests/hermes_cli/test_model_switch_custom_providers.py pass; E2E verified with real imports across all three resolution paths.

Infographic

key_env propagation fixed


Nous Research

telos-oc and others added 2 commits June 29, 2026 02:13
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.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix/custom-provider-key-env-salvage vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 11716 on HEAD, 11716 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 6160 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1
teknium1 merged commit 2f5950a into main Jun 29, 2026
30 checks passed
@teknium1
teknium1 deleted the fix/custom-provider-key-env-salvage branch June 29, 2026 09:25
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard area/auth Authentication, OAuth, credential pools area/config Config system, migrations, profiles labels Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants