fix(agent): propagate api_mode to vision provider resolution#9001
Merged
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 #8857 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
13 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.
Summary
Salvage of #8871 by @luyao618 — cherry-picked onto current main.
Fixes two bugs in the vision auxiliary client path that cause crashes when the provider uses a non-default
api_mode(e.g.,anthropic_messagesfor a corporate Anthropic proxy):api_modenot propagated:resolve_vision_provider_client()resolvesresolved_api_modefrom config but never passes it to any of its three downstream calls (resolve_provider_client()and_get_cached_client()). The non-vision path incall_llm()correctly passesapi_mode=resolved_api_mode— this was a copy-paste oversight.Named custom provider stripped for vision:
_normalize_aux_provider(for_vision=True)returned"custom"instead of the named suffix, losing provider identity.custom:corp-anthropicbecame"custom"for vision but correctly became"corp-anthropic"for every other task.Dead code cleanup: Removed the now-unused
for_visionparameter.Fixes #8857
Changes
agent/auxiliary_client.py: Passapi_mode=resolved_api_modeto all 3 downstream calls in the vision path; removefor_visionspecial case from_normalize_aux_provider()tests/agent/test_auxiliary_named_custom_providers.py: 2 new tests (named custom provider preservation + api_mode forwarding verification)Test Results
test_auxiliary_named_custom_providers.py