fix(cli): accept api_key_env alias in providers entries - #44868
Open
Code-suphub wants to merge 1 commit into
Open
Code-suphub wants to merge 1 commit into
Code-suphub wants to merge 1 commit into
Conversation
…#44666) The documented api_key_env field was silently ignored in providers: entries because _get_named_custom_provider() and related helpers only checked key_env. This caused 401 errors for users following the docs. Add api_key_env as a fallback alongside key_env in all provider resolution paths: runtime_provider.py (3 locations), model_switch.py, and config.py — matching the pattern already used in auxiliary_client.py and agent_init.py for fallback_providers. Fixes NousResearch#44666
Code-suphub
force-pushed
the
fix/44666-api-key-env-alias
branch
from
June 12, 2026 11:42
d25f0a1 to
ecd9b62
Compare
tonydwb
approved these changes
Jun 12, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Clean backward-compat fix. Accepts api_key_env as alias for key_env in provider config entries, updated in 3 locations (config.py, model_switch.py, runtime_provider.py). Allows users with older configs using api_key_env to continue working. No issues found.
Contributor
Collaborator
|
Thanks for tracing the raw Problems
Suggested changes
Automated hermes-sweeper review. |
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
When defining a named custom provider under
providers:in config.yaml using the documentedapi_key_envfield, the key resolution silently ignores it because onlykey_envis checked. This causes 401 errors —"no-key-required"is sent as the bearer token.Fixes #44666
Root Cause
_get_named_custom_provider()inruntime_provider.py(lines 542, 629) only checksentry.get("key_env"). The same gap exists inmodel_switch.pyline 1783 andconfig.pyline 3852.Other code paths already handle both aliases correctly:
agent/auxiliary_client.py:3652—custom_entry.get("key_env") or custom_entry.get("api_key_env")agent/agent_init.py:833—_fb.get("key_env") or _fb.get("api_key_env")hermes_cli/config.py:3786— normalizesapi_key_env→key_envfor camelCase keysChanges
hermes_cli/runtime_provider.pyapi_key_envfallback in 3 locationshermes_cli/model_switch.pyapi_key_envfallback in provider resolutionhermes_cli/config.pyapi_key_envfallback in entry normalizationTesting
The same class of bug was fixed for
fallback_providers:in #25091 (commit6ddc48b0).Type of Change
Checklist
Code
fix(scope): description)Documentation
cli-config.yaml.exampleif I added/changed config keys or marked as N/A