fix: route minimax m3 reasoning controls through profile

Follow up PR #46609's api.minimax.io reasoning report by moving the behavior out of the broad run_agent host gate and into the MiniMax provider profile. Only MiniMax-M3 on the documented OpenAI-compatible /v1 route gets reasoning_split/thinking/reasoning_effort; Anthropic-format MiniMax and non-M3 models keep their existing wire shapes.

Co-authored-by: goku94123 <gooku94123@gmail.com>
This commit is contained in:
Teknium 2026-06-15 05:37:28 -07:00
parent ba3883cd18
commit 49e743985a
5 changed files with 171 additions and 14 deletions

View file

@ -1,13 +1,65 @@
"""MiniMax provider profiles (international + China).
Both use anthropic_messages api_mode their inference_base_url
ends with /anthropic which triggers auto-detection to anthropic_messages.
The default API-key routes use anthropic_messages because their base URLs end
with /anthropic. Users can opt MiniMax-M3 into the OpenAI-compatible endpoint
with base_url=https://api.minimax.io/v1; that route needs MiniMax-specific
reasoning controls in extra_body.
"""
from typing import Any
from urllib.parse import urlparse
from providers import register_provider
from providers.base import ProviderProfile
minimax = ProviderProfile(
def _is_minimax_global_openai_base_url(base_url: str | None) -> bool:
parsed = urlparse(str(base_url or "").strip())
if (parsed.hostname or "").lower() != "api.minimax.io":
return False
path = parsed.path.rstrip("/").lower()
return path == "/v1"
def _is_minimax_m3(model: str | None) -> bool:
normalized = str(model or "").strip().lower()
return normalized in {"minimax-m3", "minimax/minimax-m3"}
class MiniMaxProfile(ProviderProfile):
"""MiniMax — M3 OpenAI-compatible reasoning controls."""
def build_api_kwargs_extras(
self,
*,
reasoning_config: dict | None = None,
model: str | None = None,
base_url: str | None = None,
**context: Any,
) -> tuple[dict[str, Any], dict[str, Any]]:
"""Emit M3 reasoning controls for api.minimax.io/v1.
MiniMax-M3's OpenAI-compatible endpoint keeps thinking inline unless
``reasoning_split`` is sent, so always request the split format on that
route. ``thinking`` controls the M3 mode; Hermes' effort levels are not
a MiniMax depth knob here, so they only select adaptive vs disabled.
"""
if not _is_minimax_global_openai_base_url(base_url) or not _is_minimax_m3(model):
return {}, {}
extra_body: dict[str, Any] = {"reasoning_split": True}
if isinstance(reasoning_config, dict) and reasoning_config.get("enabled") is False:
extra_body["thinking"] = {"type": "disabled"}
return extra_body, {}
if reasoning_config is not None:
extra_body["thinking"] = {"type": "adaptive"}
return extra_body, {}
minimax = MiniMaxProfile(
name="minimax",
aliases=("mini-max",),
api_mode="anthropic_messages",
@ -17,7 +69,7 @@ minimax = ProviderProfile(
default_aux_model="MiniMax-M3",
)
minimax_cn = ProviderProfile(
minimax_cn = MiniMaxProfile(
name="minimax-cn",
aliases=("minimax-china", "minimax_cn"),
api_mode="anthropic_messages",
@ -27,7 +79,7 @@ minimax_cn = ProviderProfile(
default_aux_model="MiniMax-M3",
)
minimax_oauth = ProviderProfile(
minimax_oauth = MiniMaxProfile(
name="minimax-oauth",
aliases=("minimax_oauth", "minimax-oauth-io"),
api_mode="anthropic_messages",