fix(auxiliary.vision): keep named-provider credential pool with custom base_url#16389
Closed
Sanjays2402 wants to merge 1 commit into
Closed
fix(auxiliary.vision): keep named-provider credential pool with custom base_url#16389Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
Collaborator
…m base_url (closes NousResearch#16290) When auxiliary.vision was configured with provider=zai (or any named api-key provider) AND a custom base_url, resolve_vision_provider_client forced provider="custom" before calling resolve_provider_client. That silently dropped the named provider's credential pool — for zai the pool resolves ZAI_API_KEY from env / .hermes/.env / hermes auth login — and only honoured OPENAI_API_KEY. The result was 401s from open.bigmodel.cn unless the user hardcoded api_key in config.yaml. Fix: 1. resolve_vision_provider_client: when the user explicitly named a non-custom provider that has credentials in the pool, route through the named provider with explicit_base_url, instead of folding it into "custom". Falls back to "custom" if the named provider has no key in the pool, preserving prior behaviour for setups that rely on OPENAI_API_KEY. 2. resolve_provider_client (api_key branch): honour explicit_base_url and explicit_api_key overrides for named providers. Previously these parameters were only consumed by the "custom" branch. 3. New helper _named_provider_has_credentials() so the routing decision stays cheap (no client construction) and never raises out of the hot path. Tests: 4 new (tests/agent/test_vision_provider_base_url_routing.py) + existing test_vision_resolved_args + tests/agent/test_auxiliary_client* all pass: pytest tests/agent/test_vision_provider_base_url_routing.py tests/agent/test_vision_resolved_args.py tests/agent/test_auxiliary_client.py tests/agent/test_auxiliary_client_anthropic_custom.py -q -> 99 passed (95 pre-existing + 4 new).
cee96f6 to
b9d6390
Compare
19 tasks
Contributor
|
This appears to be implemented on current main by a later fix. Automated hermes-sweeper review. Evidence:
Thanks for the focused repro and tests here; the current main fix addresses the same root cause discussed in #16290 and the related PR thread. |
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.
Closes #16290.
Problem
auxiliary.visionconfigured withprovider: zaiand a custombase_url(e.g.https://open.bigmodel.cn/api/paas/v4) failed to auto-resolveZAI_API_KEYfrom the credential pool — every request hit401 - {'error': {'code': '401', 'message': '令牌已过期或验证不正确'}}. Workaround was to hardcodeapi_keyinconfig.yaml.Root cause is exactly as @hackdion identified: in
agent/auxiliary_client.py::resolve_vision_provider_client(), any non-emptyresolved_base_urlforced the call toresolve_provider_client("custom", ...). That branch only consultsOPENAI_API_KEY/explicit_api_key, so the named provider's credential pool (which knows aboutZAI_API_KEY,KIMI_API_KEY, etc.) was never asked.Fix
Three small changes:
resolve_vision_provider_client— when a named non-customprovider with credentials in the pool is requested and a custombase_urlis supplied, route through the named provider withexplicit_base_url. Falls back to the existing"custom"path if the named provider has no key, preserving prior behaviour forOPENAI_API_KEY-only setups.resolve_provider_client(api-key branch) — honourexplicit_base_url/explicit_api_keyoverrides. These were already accepted by the"custom"branch but ignored for named api-key providers._named_provider_has_credentials(provider)— small helper used by (1) so the routing decision stays cheap (no client construction) and never raises out of the hot path.The doc'd workaround (hardcoded
api_keyinconfig.yaml) still works — whenexplicit_api_keyis supplied the resolver goes straight to thecustompath, same as before.Tests
tests/agent/test_vision_provider_base_url_routing.py— 3 new focused tests:test_vision_with_named_provider_and_base_url_routes_through_named_provider— direct repro of [Bug]: auxiliary.vision with provider=zai and custom base_url fails to auto-resolve ZAI_API_KEY #16290: provider="zai" + base_url="open.bigmodel.cn" routes through"zai"(not"custom") and forwards the explicit base_url.test_vision_with_base_url_falls_back_to_custom_when_named_provider_has_no_creds— preserves prior behaviour when the credential pool is empty.test_vision_with_explicit_api_key_skips_named_provider_routing— preserves the documented hardcoded-key workaround.