fix(auxiliary): honor /anthropic-suffixed gateway base_url in _try_anthropic (salvage #62061) - #85533
Merged
Conversation
…allback calls `_try_anthropic()` applies the configured `model.base_url` only when `_is_anthropic_compatible_host()` trusts it, but that check accepted only the literal `api.anthropic.com` host. Anthropic-compatible gateways that expose the native Messages protocol under a `/anthropic` path suffix (MiniMax, Zhipu GLM, LiteLLM-style relays, self-hosted proxies) were rejected, so every auxiliary call (title generation, memory extraction, vision, reflection) and the `provider: anthropic` fallback chain discarded the configured base_url and fell back to `https://api.anthropic.com`. That diverges from the primary path, which already trusts the `/anthropic` suffix via `runtime_provider._detect_api_mode_for_url`, and fails outright when the gateway (not Anthropic) holds the credentials. Accept `/anthropic` and `/anthropic/v1` suffixed URLs in `_is_anthropic_compatible_host()`, matching the primary-path convention and `_wrap_if_needed`. A bare non-Anthropic base_url (e.g. `openrouter.ai/api/v1` left on `provider: anthropic`) still returns False, preserving the #52608 guard.
Contributor
૮ >ﻌ< ა ci reviewran on 2be18b5 — fix(auxiliary): honor /anthropic-suffixed gateway base_url o
|
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
_try_anthropicnow honors configured gateway base URLs whose path ends/anthropicor/anthropic/v1instead of discarding them and forcingapi.anthropic.com. Salvage of #62061 by @iso2kx onto current main, authorship preserved._is_anthropic_compatible_host()was host-allowlist-only, so auxiliary/fallback Anthropic calls threw away a perfectly valid path-suffixed gateway base_url — the primary path already trusts these URLs via_detect_api_mode_for_url. The #52608 bare-non-Anthropic-host rejection is preserved.Changes
agent/auxiliary_client.py:_is_anthropic_compatible_hosttrusts/anthropicand/anthropic/v1path suffixes alongside the host allowlisttests/agent/test_auxiliary_client_base_url_host_validation_52608.py: +4 tests extending the auxiliary_client: _try_anthropic() misroutes side-channel calls when main config has provider=anthropic with a non-Anthropic base_url #52608 suite (suffix trust both shapes, bare-host rejection kept)Validation
…/anthropicon aux_try_anthropicInfographic