fix(aux-client): preserve /anthropic for MiniMax M-series auxiliary routes - #37183
Closed
gsurenull wants to merge 1 commit into
Closed
fix(aux-client): preserve /anthropic for MiniMax M-series auxiliary routes#37183gsurenull wants to merge 1 commit into
gsurenull wants to merge 1 commit into
Conversation
…outes (#17387) Auxiliary tasks (title generation, compression, session_search, vision analysis, flush_memories, …) for the built-in `minimax`, `minimax-oauth`, and `minimax-cn` providers were 404'ing because `_to_openai_base_url` rewrote `https://api.minimaxi.com/anthropic` → `https://api.minimaxi.com/v1` before handing the URL to the OpenAI SDK. The M-series models on `api.minimaxi.com` and `api.minimax.io` do not expose a working `/v1/chat/completions` surface — they only speak Anthropic Messages on `/anthropic/v1/messages`. The fix preserves the original `/anthropic` URL for MiniMax hosts and relies on the existing `_maybe_wrap_anthropic` chokepoint to detect the Anthropic-Messages shape via `_endpoint_speaks_anthropic_messages` and route through the Anthropic SDK. This mirrors the named-custom `api_mode=anthropic_messages` path added in #15059 but covers the built-in provider profile path that was missed by that fix. Other `/anthropic` hosts (ZAI, LiteLLM proxies, generic /anthropic URLs) are unaffected — the ZAI branch continues to rewrite to `/api/paas/v4` and the generic fallback continues to rewrite to `/v1`. Tests: - Renames the previous `_anthropic_suffix_replaced` assertions to `_anthropic_suffix_preserved` to reflect the new behaviour. - Adds regression guards for the ZAI branch and the generic /anthropic fallback so the new MiniMax exception does not accidentally swallow them. - Adds `TestEndToEndAnthropicRouting` covering the full chain: the preserved URL is still recognised by `_endpoint_speaks_anthropic_messages` so the call ends up on the Anthropic SDK wire, not the OpenAI wire. Fixes #17387
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
Fixes #17387.
Auxiliary tasks (title generation, compression, session_search, vision analysis, flush_memories, ...) for the built-in
minimax,minimax-oauth, andminimax-cnproviders were 404'ing because_to_openai_base_urlrewrotehttps://api.minimaxi.com/anthropic->https://api.minimaxi.com/v1before handing the URL to the OpenAI SDK. M-series models onapi.minimaxi.comandapi.minimax.iodo not expose a working/v1/chat/completionssurface — they only speak Anthropic Messages on/anthropic/v1/messages.Fix
Preserve the original
/anthropicURL for MiniMax hosts and rely on the existing_maybe_wrap_anthropicchokepoint to detect the Anthropic-Messages shape via_endpoint_speaks_anthropic_messagesand route through the Anthropic SDK. This mirrors the named-customapi_mode=anthropic_messagespath added in #15059 but covers the built-in provider profile path that was missed by that fix.Scope
/api/paas/v4(regression guard added)/v1(regression guard added)Tests
test_auxiliary_named_custom_providers,test_auxiliary_client) pass with no regressionsTestEndToEndAnthropicRoutingcovers the full chain: preserved URL is still recognised by_endpoint_speaks_anthropic_messagesso calls land on Anthropic SDK wire, not OpenAI wireDiff stat