fix(agent): resolve credential pool key ambiguity for shared base_url#19682
fix(agent): resolve credential pool key ambiguity for shared base_url#19682Cyrene963 wants to merge 1 commit into
Conversation
When multiple custom_providers share the same base_url, get_custom_provider_pool_key() previously returned the first match, causing the wrong credential pool to be loaded. Changes: - Add optional provider_name parameter to get_custom_provider_pool_key() for name-based disambiguation - Update _try_resolve_from_custom_pool() to pass provider_name through - Fix _seed_custom_pool() to compare base_url against the specific pool_key's config instead of calling get_custom_provider_pool_key() Fixes NousResearch#19083
|
Likely duplicate of #19122 |
|
Closing as duplicate of #19122 (Bartok9) — same fix for credential pool key disambiguation. Their PR was submitted earlier. Local patch remains active in Cyrene963/hermes-patches until upstream resolves #19083. |
|
Re-evaluating closure status for #19682 I closed this as a duplicate earlier, but I rechecked the referenced upstream PR(s) and none of them are merged yet:
Because the underlying fix does not appear to have landed upstream, closing this solely as a duplicate may have been premature. I am reopening this PR so it can remain trackable unless maintainers prefer a different canonical PR. |
|
This looks implemented on current Evidence:
Thanks for keeping this trackable after the earlier duplicate PRs were closed unmerged. |
Summary
Fixes #19083
When multiple
custom_providersshare the samebase_urlbut have differentapi_keyvalues,get_custom_provider_pool_key()previously returned the pool key for the first match in iteration order. This caused the wrong credential pool to be loaded, resulting in 401 Unauthorized errors.Root Cause
get_custom_provider_pool_key(base_url)only matched bybase_url, ignoring which provider name was actually requested. Two providers with the samebase_urlalways resolved to the first one's pool key.Fix
Three targeted changes:
agent/credential_pool.py—get_custom_provider_pool_key(): Added optionalprovider_nameparameter. When provided (and not bare"custom"), matches by provider name first for disambiguation. Falls back tobase_urlmatching when name is not available.hermes_cli/runtime_provider.py—_try_resolve_from_custom_pool(): Passesprovider_namethrough toget_custom_provider_pool_key()so named provider lookups are unambiguous.agent/credential_pool.py—_seed_custom_pool(): Replaced indirectget_custom_provider_pool_key(model_base_url)call with direct comparison against the current pool_key's own config entry, eliminating first-match ambiguity entirely for this path.Testing
test_credential_pool.pytests passtest_runtime_provider_resolution.pytests passCloses #19083