fix(agent): map bare "custom" provider to named providers: key via base_url match#14718
Closed
cdanis wants to merge 1 commit into
Closed
fix(agent): map bare "custom" provider to named providers: key via base_url match#14718cdanis wants to merge 1 commit into
cdanis wants to merge 1 commit into
Conversation
…se_url match When auxiliary models (vision, web_extract) use `_read_main_provider()`, they get the literal string "custom" for `model.provider` if the user configured a custom endpoint. But `_get_named_custom_provider()` and `_resolve_vision_provider()` expect a provider key name that exists in the `providers:` dict — they look up credentials, defaults, and client adapters by that key. This mismatch caused auxiliary tasks to fail with `None` provider resolution. The fix enhances `_read_main_provider()` in `agent/auxiliary_client.py`: when the bare "custom" provider is detected, it searches the `providers:` dictionary for an entry whose `api`, `url`, or `base_url` matches the model's `base_url`. If found, it returns the actual key name instead of "custom". This bridges the gap between _config-time naming_ (what users put in `providers: my-local`) and _runtime lookup_ (what auxiliary resolution code expects). Changes: - agent/auxiliary_client.py: Added base_url matching logic in `_read_main_provider()` that iterates `providers:` entries and returns the first key whose api/url/base_url matches the model's configured base_url (with trailing-slash normalization). Falls through to bare "custom" if no match. - tests/agent/test_auxiliary_named_custom_providers.py: Added 6 test cases covering: * Bare custom with matching providers entry → returns key name * Bare custom with no match → falls through to "custom" * providers: entries using "base_url" key (not just "api") * Non-custom providers pass through unchanged * Absent providers dict uses bare "custom" as fallback * Trailing slash normalization on both sides of comparison This is a minimal, surgical fix — only the single return point in `_read_main_provider()` is modified. No refactoring of auxiliary resolution chain. Refs: NousResearch#14676 (auxiliary named provider resolution)
Contributor
|
Closing — the bare- Your base_url-matching approach in Thanks for the detailed 6-test coverage — that's the standard we want. |
19 tasks
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.
What does this PR do?
When auxiliary models (vision, web_extract) use
_read_main_provider(), they get the literal string "custom" formodel.providerif the user configured a custom endpoint. But_get_named_custom_provider()and_resolve_vision_provider()expect a provider key name that exists in theproviders:dict — they look up credentials, defaults, and client adapters by that key. This mismatch caused auxiliary tasks to fail with None provider resolution.The fix enhances
_read_main_provider()inagent/auxiliary_client.py: when the bare "custom" provider is detected, it searches theproviders:dictionary for an entry whoseapi,url, orbase_urlmatches the model base_url. If found, it returns the actual key name instead of "custom". This bridges the gap between config-time naming (what users put inproviders: my-local) and runtime lookup (what auxiliary resolution code expects).Related Issue
Fixes #14676
Type of Change
Changes Made
agent/auxiliary_client.py: Added base_url matching logic in_read_main_provider()that iteratesproviders:entries and returns the first key whose api/url/base_url matches the model configured base_url (with trailing-slash normalization). Falls through to bare "custom" if no match.tests/agent/test_auxiliary_named_custom_providers.py: Added 6 test cases covering: bare custom with matching providers entry, bare custom with no match, providers entries using "base_url" key, non-custom passthrough, absent providers dict fallback, and trailing slash normalization.How to Test
pytest tests/agent/test_auxiliary_named_custom_providers.py -o addopts= -vpytest tests/agent/test_auxiliary*.py -o addopts= -q(all 142 pass)_read_main_provider()mapping.Checklist
Code
fix(scope):)pytest tests/ -qDocumentation & Housekeeping
_read_main_provider()Screenshots / Logs
Test output: