fix(agent): use /anthropic endpoint for MiniMax-CN auxiliary tasks - #17528
fix(agent): use /anthropic endpoint for MiniMax-CN auxiliary tasks#17528alexzhu0 wants to merge 1 commit into
Conversation
Fixes #17387. auxiliary_client._to_openai_base_url() unconditionally rewrites /anthropic -> /v1 so the OpenAI SDK can talk chat.completions. For most providers that is correct: MiniMax, etc. expose both surfaces and the OpenAI-compatible one lives at /v1. For MiniMax-CN specifically the /v1 endpoint does NOT support the auxiliary-task surface (title generation, context compression, summarization), so those requests all 404. MiniMax-CN only serves those endpoints via the /anthropic surface, which we already have an AnthropicAuxiliaryClient wrapper for (_maybe_wrap_anthropic). This PR threads a `provider=` kwarg into _to_openai_base_url; when the provider is in _ANTHROPIC_COMPAT_PROVIDERS the /anthropic URL is preserved so _maybe_wrap_anthropic can detect and use the Anthropic transport instead of being forced through /v1. All 6 call sites in agent/auxiliary_client.py were updated to pass the provider they already have in scope. Behavior unchanged for every non-MiniMax provider; existing /anthropic -> /v1 rewrite still fires when provider is empty, 'openai', 'custom', etc. Adds 7 regression tests under TestToOpenaiBaseUrl: - default rewrite behavior (preserved) - provider-gated preservation for minimax / minimax-cn - empty-provider fallback (preserved) - trailing-slash normalization
|
Same issue happens with minimax global. Can you extend the fix to minimax global too? |
|
Thanks @ar-nim — just verified: the fix already covers both.
If you're seeing the failure despite that — could you share the |
|
Closing as duplicate — #17467 (merged as 4e296dc) fixes this more broadly. Your allowlist approach ( |
Closes #17387.
Summary
auxiliary_client._to_openai_base_url()unconditionally rewrites/anthropic→/v1so the OpenAI SDK can hitchat.completions. For most providers that's correct — MiniMax exposes both surfaces and the OpenAI-compatible one lives at/v1. But MiniMax-CN's/v1endpoint does not support auxiliary tasks (title generation, context compression, summarization), so every aux request 404s.MiniMax-CN only serves those endpoints via the
/anthropicsurface, and we already have anAnthropicAuxiliaryClientwrapper (_maybe_wrap_anthropic) ready to consume that shape.Fix
Thread a
provider=kwarg into_to_openai_base_url. When the provider is in_ANTHROPIC_COMPAT_PROVIDERS(currently{"minimax", "minimax-cn"}), skip the/anthropic → /v1rewrite so_maybe_wrap_anthropiccan detect and route through the Anthropic Messages API instead.All 6 call sites in
agent/auxiliary_client.pyupdated to pass the provider they already have in local scope. Behavior unchanged for every non-MiniMax provider; the existing rewrite still fires whenprovider="","openai","custom", etc.Tests
Added
TestToOpenaiBaseUrlintests/agent/test_auxiliary_client.pywith 7 regression cases:minimaxandminimax-cnopenai) still gets the rewriteLocal inline verification of the logic: 6/6 pass. (Full pytest run requires Python 3.10+; my local env is 3.9 so CI will cover the test suite.)
Verification path
With this PR, an aux request on MiniMax-CN ends up on
/anthropic/messagesviaAnthropicAuxiliaryClientinstead of/v1/chat/completions(404). Compression / title generation / summarization onminimax-cnshould recover.Files
agent/auxiliary_client.py: +10 / -3 (function signature + 6 call sites)tests/agent/test_auxiliary_client.py: +87