fix(auxiliary): inherit model.api_key for custom endpoint when per-task key is empty (#9318) - #55911
Closed
Tranquil-Flow wants to merge 1 commit into
Closed
Conversation
…sk key is empty (NousResearch#9318) When an auxiliary task is configured with provider=custom and an explicit base_url but an empty api_key, the custom_key fallback chain in resolve_provider_client() jumped straight to the no-key-required placeholder without consulting model.api_key from config.yaml. Users on self-hosted gateways who share the same endpoint and credentials for both the main model and auxiliary tasks got 401 auth errors. Add _read_main_api_key() following the same pattern as _read_main_model() and _read_main_provider(): checks _RUNTIME_MAIN_API_KEY (runtime override) first, then config.yaml model.api_key. Insert it into the fallback chain before no-key-required so real credentials are used when available, while local servers without auth still get the placeholder.
teknium1
added a commit
that referenced
this pull request
Jul 6, 2026
Follow-up to the #55911 salvage: inherit model.api_key only when the aux base_url resolves to the same hostname as the main model's base_url (runtime override or config). A misconfigured aux endpoint on a different host keeps the fail-safe no-key-required placeholder instead of leaking the main credential cross-host.
Contributor
|
Merged via PR #59207 — your commit was cherry-picked onto current main with your authorship preserved in git log. One hardening addition on top: the inheritance is host-gated (main key only inherited when the aux base_url points at the same host as the main model's base_url), so a misconfigured aux endpoint can't leak the main credential cross-host. Clean fix with a solid test suite — thanks! |
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
Follow-up to the NousResearch#55911 salvage: inherit model.api_key only when the aux base_url resolves to the same hostname as the main model's base_url (runtime override or config). A misconfigured aux endpoint on a different host keeps the fail-safe no-key-required placeholder instead of leaking the main credential cross-host.
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
Follow-up to the NousResearch#55911 salvage: inherit model.api_key only when the aux base_url resolves to the same hostname as the main model's base_url (runtime override or config). A misconfigured aux endpoint on a different host keeps the fail-safe no-key-required placeholder instead of leaking the main credential cross-host.
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
Follow-up to the NousResearch#55911 salvage: inherit model.api_key only when the aux base_url resolves to the same hostname as the main model's base_url (runtime override or config). A misconfigured aux endpoint on a different host keeps the fail-safe no-key-required placeholder instead of leaking the main credential cross-host.
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
Follow-up to the NousResearch#55911 salvage: inherit model.api_key only when the aux base_url resolves to the same hostname as the main model's base_url (runtime override or config). A misconfigured aux endpoint on a different host keeps the fail-safe no-key-required placeholder instead of leaking the main credential cross-host.
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.
Problem
When an auxiliary task is configured with
provider: custom, an explicitbase_url, and an emptyapi_key, theresolve_provider_client()custom provider branch falls through to the hardcoded"no-key-required"placeholder without ever consultingmodel.api_keyfrom config.yaml. This causes 401 auth errors for users on self-hosted gateways who share the same endpoint and credentials for both their main model and auxiliary tasks.Root Cause
The
custom_keyfallback chain inresolve_provider_client()(theprovider == "custom"branch withexplicit_base_url) only checks:explicit_api_key→ None (empty string stripped)os.getenv("OPENAI_API_KEY")→ often unset or wrong key"no-key-required"← wins, causing 401The main
model.api_keyfrom config.yaml is never consulted, unlike the_resolve_auto()path which already reads_RUNTIME_MAIN_API_KEY.Fix
Added
_read_main_api_key()— mirrors the existing_read_main_model()/_read_main_provider()pattern:_RUNTIME_MAIN_API_KEY(runtime override set byset_runtime_main())config.yaml→model.api_key""if neither is setInserted into the
custom_keyfallback chain before"no-key-required":This covers both the explicit
provider: custompath and (transitively) theprovider: autopath when auto-detection routes auxiliary tasks to the main custom endpoint.Tests
Added
TestCustomEndpointApiKeyInheritancewith 4 tests:test_inherits_main_api_key_when_aux_key_emptytest_runtime_override_key_is_used_RUNTIME_MAIN_API_KEYoverride takes precedence over configtest_explicit_api_key_takes_precedenceapi_keyparam wins over configtest_local_server_falls_to_no_key_required"no-key-required"for local serversRED phase verified: both RED→GREEN tests fail on
upstream/mainwithAssertionError: 'no-key-required' != 'sk-...'.Full suite: 278 passed, 0 failed in
tests/agent/test_auxiliary_client.py.Related PRs
provider: custom+ custom-gateway + empty-key scenario."custom". Does not apply whenprovider: customis explicitly set.This fix is complementary to both — it handles the case where a user intentionally uses
provider: customwith a self-hosted gateway and expects credential inheritance from the main model config.Closes #9318.
Auto-published by Moonsong via Path B automated pipeline.