fix(auxiliary): keep /anthropic base_url for anthropic_messages custom endpoints (salvage #64891) - #85466
Merged
Conversation
…m endpoints The custom + explicit_base_url branch of resolve_provider_client() unconditionally rewrote a trailing /anthropic to /v1 via _to_openai_base_url(), even when api_mode was anthropic_messages. The Anthropic wrapper then never saw the real /anthropic path, so auxiliary tasks (title generation, compression, vision, web_extract, session_search) hit .../v1/chat/completions on a Messages-only endpoint and failed. Guard the wrap base on api_mode: for anthropic_messages, pass the raw /anthropic base to _wrap_if_needed (which builds the Anthropic wrapper), while the plain OpenAI client keeps the /v1-rewritten base so the OpenAI-wire fallback (used when the anthropic SDK is unavailable) never lands on /anthropic/chat/completions. Refs #16254
Contributor
૮ >ﻌ< ა ci reviewran on 5ecaf92 — fix(auxiliary): keep /anthropic base_url for anthropic_messa
|
1 task
This was referenced Aug 13, 2026
Closed
Merged
teknium1
pushed a commit
that referenced
this pull request
Aug 13, 2026
Fallback activation determined api_mode from the POST-rewrite client base_url, losing the Anthropic wire signal for /anthropic endpoints routed through provider 'custom', and never honored an explicit fb.api_mode config field. Pre-compute fb_api_mode from the ORIGINAL fallback base_url hint (before _to_openai_base_url rewriting), honor the explicit api_mode config field, check provider name before the base_url gate, and pass api_mode into resolve_provider_client at the fallback call site. Salvaged from PR #79787 (chat_completion_helpers.py hunks; the auxiliary_client.py hunk is redundant with #85466's wrap_base fix).
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
Auxiliary tasks (titles, compression, vision) work again on
customproviders whose base_url ends in/anthropic(MiniMax, Zhipu, LiteLLM proxies). Salvage of #64891 by @AlexanderPrendota onto current main, authorship preserved. Fixes #16254 (dup #17086).Root cause: the explicit-base branch of
resolve_provider_client()rewrote/anthropic→/v1unconditionally before the Anthropic-wrap decision, so the Messages wrapper was built against a/v1URL and every auxiliary call 404'd.Changes
agent/auxiliary_client.py: whenapi_mode == "anthropic_messages",_wrap_if_neededgets the raw/anthropicbase; the plain-OpenAI client and SDK-unavailable fallback keep the/v1-rewritten base — same guard the named-custom-provider branch already hastests/agent/test_auxiliary_explicit_base_anthropic.py: 3 regression tests (wrapper keeps/anthropic, fallback stays/v1, non-anthropic rewrite preserved)Validation
/v1/chat/completions/v1rewriteSibling paths (#60753 vision, #61333 class-wide guard) tracked as a separate cluster decision.
Infographic