fix(agent): propagate api_mode to vision provider resolution#8871
Closed
luyao618 wants to merge 1 commit into
Closed
fix(agent): propagate api_mode to vision provider resolution#8871luyao618 wants to merge 1 commit into
luyao618 wants to merge 1 commit into
Conversation
resolve_vision_provider_client() computed resolved_api_mode from config but never passed it to downstream resolve_provider_client() or _get_cached_client() calls, causing custom providers with api_mode: anthropic_messages to crash when used for vision tasks. Also remove the for_vision special case in _normalize_aux_provider() that incorrectly discarded named custom provider identifiers. Fixes NousResearch#8857 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
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?
resolve_vision_provider_client()inagent/auxiliary_client.pyresolvesapi_modefrom config via_resolve_task_provider_model("vision", ...)but never passes it downstream toresolve_provider_client()or_get_cached_client(). This causesvision_analyzeandbrowser_visionto crash when the provider uses a non-default API mode (e.g.,api_mode: anthropic_messagesfor a custom corporate Anthropic proxy).Additionally,
_normalize_aux_provider()had afor_visionbranch that incorrectly stripped named custom provider identity (e.g.,custom:corp-anthropic→custom) for vision tasks only.Related Issue
Fixes #8857
Type of Change
Changes Made
Two independent bugs combine:
api_modenot propagated: The variableresolved_api_modeis computed at line 1696 but never passed to any of the three downstream call sites. Compare with the non-vision path incall_llm()which correctly passesapi_mode=resolved_api_mode. Fixed by addingapi_mode=resolved_api_modeto all three downstream calls.Named custom provider lost for vision:
_normalize_aux_provider(for_vision=True)returned"custom"instead of the named suffix, losing provider identity needed for config lookup. Fixed by removing thefor_visionspecial case — named custom providers are now preserved for all tasks.Dead code cleanup: Removed the now-unused
for_visionparameter from_normalize_aux_provider().Tests: Added 2 targeted tests — named custom provider preservation + api_mode forwarding verification.
How to Test
api_mode: anthropic_messages:vision_analyzeshould work without crashingpytest tests/agent/test_auxiliary_named_custom_providers.py -v— all 19 tests passpytest tests/ -q --ignore=tests/integration --ignore=tests/e2e— passesChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A