Skip to content

fix(agent): use /anthropic endpoint for MiniMax-CN auxiliary tasks - #17528

Closed
alexzhu0 wants to merge 1 commit into
NousResearch:mainfrom
alexzhu0:fix/aux-minimax-anthropic-endpoint
Closed

fix(agent): use /anthropic endpoint for MiniMax-CN auxiliary tasks#17528
alexzhu0 wants to merge 1 commit into
NousResearch:mainfrom
alexzhu0:fix/aux-minimax-anthropic-endpoint

Conversation

@alexzhu0

Copy link
Copy Markdown
Contributor

Closes #17387.

Summary

auxiliary_client._to_openai_base_url() unconditionally rewrites /anthropic/v1 so the OpenAI SDK can hit chat.completions. For most providers that's correct — MiniMax exposes both surfaces and the OpenAI-compatible one lives at /v1. But MiniMax-CN's /v1 endpoint does not support auxiliary tasks (title generation, context compression, summarization), so every aux request 404s.

MiniMax-CN only serves those endpoints via the /anthropic surface, and we already have an AnthropicAuxiliaryClient wrapper (_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 → /v1 rewrite so _maybe_wrap_anthropic can detect and route through the Anthropic Messages API instead.

-def _to_openai_base_url(base_url: str) -> str:
+def _to_openai_base_url(base_url: str, *, provider: str = "") -> str:
     url = str(base_url or "").strip().rstrip("/")
+    if provider and provider in _ANTHROPIC_COMPAT_PROVIDERS:
+        return url  # preserve /anthropic — _maybe_wrap_anthropic will handle it
     if url.endswith("/anthropic"):
         rewritten = url[: -len("/anthropic")] + "/v1"
         …

All 6 call sites in agent/auxiliary_client.py updated to pass the provider they already have in local scope. Behavior unchanged for every non-MiniMax provider; the existing rewrite still fires when provider="", "openai", "custom", etc.

Tests

Added TestToOpenaiBaseUrl in tests/agent/test_auxiliary_client.py with 7 regression cases:

  • default rewrite behavior (preserved)
  • provider-gated preservation for minimax and minimax-cn
  • empty-provider fallback (preserved)
  • trailing-slash normalization
  • unrelated provider (openai) still gets the rewrite

Local 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/messages via AnthropicAuxiliaryClient instead of /v1/chat/completions (404). Compression / title generation / summarization on minimax-cn should recover.

Files

  • agent/auxiliary_client.py: +10 / -3 (function signature + 6 call sites)
  • tests/agent/test_auxiliary_client.py: +87

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
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/minimax MiniMax (Anthropic transport) labels Apr 29, 2026
@ar-nim

ar-nim commented Apr 29, 2026

Copy link
Copy Markdown

Same issue happens with minimax global. Can you extend the fix to minimax global too?

@alexzhu0

Copy link
Copy Markdown
Contributor Author

Thanks @ar-nim — just verified: the fix already covers both. _ANTHROPIC_COMPAT_PROVIDERS = frozenset({"minimax", "minimax-cn"}) includes the global slug.

minimax is the canonical provider id for MiniMax Global (see hermes_cli/auth.py:250-283, where "minimax" and "minimax-cn" are registered as separate ProviderConfig entries). So configuring with provider: minimax in your config.yaml already benefits from the /anthropic preservation in this PR.

If you're seeing the failure despite that — could you share the provider: value in your config.yaml and a sample log line? If it's a different slug (e.g. minimax-global, minimax-m2, mm), we can add a normalization alias. Otherwise I'd expect the fix to resolve the 404s as-is.

@teknium1

Copy link
Copy Markdown
Contributor

Closing as duplicate — #17467 (merged as 4e296dc) fixes this more broadly. Your allowlist approach (_ANTHROPIC_COMPAT_PROVIDERS in _to_openai_base_url) is narrower: it only catches the two MiniMax providers in the set, while #17467's approach (split raw_base_url from rewritten base_url at the call sites) also fixes Kimi Coding, anthropic_messages custom proxies, and any future /anthropic-suffixed gateway via the shared _endpoint_speaks_anthropic_messages detector. Thanks for the diagnosis and the thorough test plan.

@teknium1 teknium1 closed this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have provider/minimax MiniMax (Anthropic transport) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: use /anthropic endpoint for MiniMax-CN auxiliary tasks

4 participants