Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

feat: recommend MiniMax Flash and map current reasoning controls

octo-patch53d19a39f0d3
diff --git a/deeptutor/runtime/agentic/client.py b/deeptutor/runtime/agentic/client.py
index dd0c1ae7f..19b33d250 100644
--- a/deeptutor/runtime/agentic/client.py
+++ b/deeptutor/runtime/agentic/client.py
@@ -308,6 +308,7 @@ def _build_anthropic_adapter(config: LLMClientConfig, spec: Any) -> Any:
default_model=config.model or "claude-sonnet-4-20250514",
extra_headers=config.extra_headers,
supports_prompt_caching=spec.supports_prompt_caching,
+ binding=spec.name,
)
return _ProviderOpenAIAdapter(anthropic_provider)
@@ -417,6 +418,18 @@ class _ProviderOpenAIAdapter:
if max_tokens is None:
max_tokens = kwargs.pop("max_tokens", 4096)
reasoning_effort = kwargs.pop("reasoning_effort", None)
+ if getattr(self._provider, "_binding", "") in {"minimax", "minimax_anthropic"} and (
+ model or self._provider.default_model
+ ).lower() in {"minimax-m3.1-flash", "minimax-m3"}:
+ # Convert the facade's OpenAI-only controls back to intent before
+ # the native Anthropic provider builds its protocol-specific body.
+ extra_body = dict(kwargs.pop("extra_body", None) or {})
+ thinking = extra_body.pop("thinking", None)
+ extra_body.pop("reasoning_split", None)
+ if thinking and reasoning_effort is None:
+ reasoning_effort = "none" if thinking.get("type") == "disabled" else "adaptive"
+ if extra_body:
+ kwargs["extra_body"] = extra_body
kwargs.pop("stream_options", None)
if stream:
diff --git a/deeptutor/services/llm/cloud_provider.py b/deeptutor/services/llm/cloud_provider.py
index 0a3cc7e55..68bd43026 100644
--- a/deeptutor/services/llm/cloud_provider.py
+++ b/deeptutor/services/llm/cloud_provider.py
@@ -18,6 +18,7 @@ import aiohttp
from deeptutor.services.config import load_system_settings
from deeptutor.services.provider_registry import effective_backend, find_by_name
+from .minimax_models import active_model_names
from .utils import build_auth_headers, collect_model_names
logger = logging.getLogger(__name__)
@@ -102,9 +103,13 @@ async def fetch_models(
mapping = cast(Mapping[str, object], payload)
items = mapping.get("data")
if isinstance(items, list):
- return collect_model_names(cast(list[object], items))
+ return active_model_names(
+ collect_model_names(cast(list[object], items)), binding
+ )
elif isinstance(payload, list):
- return collect_model_names(cast(list[object], payload))
+ return active_model_names(
+ collect_model_names(cast(list[object], payload)), binding
+ )
return []
except Exception as e:
logger.error("Error fetching models from %s: %s", base_url, e)
diff --git a/deeptutor/services/llm/context_window.py b/deeptutor/services/llm/context_window.py
index f72cc6a59..4e207e22e 100644
--- a/deeptutor/services/llm/context_window.py
+++ b/deeptutor/services/llm/context_window.py
@@ -128,6 +128,11 @@ KNOWN_CONTEXT_WINDOWS: dict[str, int] = {
"minimax-m2.7": 204800,
"minimax-m2.7-highspeed": 204800,
"minimax-m3": 1000000,
+ # https://platform.minimax.io/docs/api-reference/text-openai-api (2026-10-20)
+ "minimax-m3.1-flash": 1000000,
+ # OpenRouter /api/v1/models (2026-10-20), not direct API capacities.
+ "minimax/minimax-m3.1-flash:free": 1000000,
+ "minimax/minimax-m3": 1048576,
"o1": 200000,
"o1-pro": 200000,
"o3": 200000,
diff --git a/deeptutor/services/llm/minimax_models.py b/deeptutor/services/llm/minimax_models.py
new file mode 100644
index 000000000..c6eadff5d
--- /dev/null
+++ b/deeptutor/services/llm/minimax_models.py
@@ -0,0 +1,31 @@
+"""Current MiniMax text choices in live discovery; saved model IDs remain untouched."""
+
+from __future__ import annotations
+
+
+def active_model_names(names: list[str], binding: str) -> list[str]:
+ """Prefer Flash, retain M3, and preserve unrelated/custom discovery entries.
+
+ Only filter known MiniMax text IDs for MiniMax and OpenRouter. Do not invent
+ account access by adding models missing from the endpoint's response.
+ """
+ if binding not in {"minimax", "minimax_anthropic", "openrouter"}:
+ return names
+ prefix = "minimax/" if binding == "openrouter" else ""
+ flash = prefix + "minimax-m3.1-flash" + (":free" if prefix else "")
+ active = [flash, prefix + "minimax-m3"]
+
+ def keep(name: str) -> bool:
+ lowered = name.lower()
+ if prefix and not lowered.startswith(prefix):
+ return True
+ model = lowered.removeprefix(prefix)
+ known_text = model == "minimax-01" or model.startswith(
+ ("minimax-m", "minimax-text", "minimax-vl", "abab")
+ )
+ return not known_text or lowered in active
+
+ filtered = [name for name in names if keep(name)]
+ return sorted(
+ filtered, key=lambda name: active.index(name.lower()) if name.lower() in active else 2
+ )
diff --git a/deeptutor/services/llm/provider_core/anthropic_provider.py b/deeptutor/services/llm/provider_core/anthropic_provider.py
index 47bd029e5..a6bcb8c7c 100644
--- a/deeptutor/services/llm/provider_core/anthropic_provider.py
+++ b/deeptutor/services/llm/provider_core/anthropic_provider.py
@@ -16,6 +16,7 @@ from typing import Any
import json_repair
from deeptutor.services.llm.provider_core.base import LLMProvider, LLMResponse, ToolCallRequest
+from deeptutor.services.llm.reasoning_params import minimax_reasoning_kwargs
from deeptutor.services.provider_registry import ANTHROPIC_EFFORT_BASED_FAMILIES
from deeptutor.services.session.provider_response_state import (
normalize_provider_response_state,
@@ -44,11 +45,13 @@ class AnthropicProvider(LLMProvider):
default_model: str = "claude-sonnet-4-20250514",
extra_headers: dict[str, str] | None = None,
supports_prompt_caching: bool = True,
+ binding: str = "anthropic",
):
super().__init__(api_key, api_base)
self.default_model = default_model
self.extra_headers = extra_headers or {}
self._supports_prompt_caching = supports_prompt_caching
+ self._binding = binding
from anthropic import AsyncAnthropic
@@ -412,7 +415,15 @@ class AnthropicProvider(LLMProvider):
if system:
kwargs["system"] = system
- if thinking_enabled and effort_based:
+ minimax = (
+ minimax_reasoning_kwargs(model_name, effort, anthropic=True)
+ if getattr(self, "_binding", "anthropic") in {"minimax", "minimax_anthropic"}
+ else None
+ )
+ if minimax is not None:
+ kwargs.update(minimax)
+ thinking_enabled = minimax["thinking"]["type"] != "disabled"
+ elif thinking_enabled and effort_based:
# These families reject enabled+budget_tokens with a 400 —
# adaptive is their only on-mode, so any real effort level maps
# to adaptive (no budget headroom needed). Off-sentinels omit
diff --git a/deeptutor/services/llm/provider_factory.py b/deeptutor/services/llm/provider_factory.py
index 77d0fdf25..715313ee5 100644
--- a/deeptutor/services/llm/provider_factory.py
+++ b/deeptutor/services/llm/provider_factory.py
@@ -112,6 +112,7 @@ def _build_runtime_provider(
default_model=llm_config.model,
extra_headers=llm_config.extra_headers or None,
supports_prompt_caching=bool(spec and spec.supports_prompt_caching),
+ binding=spec.name if spec else llm_config.binding,
)
else:
from deeptutor.services.llm.provider_core.openai_compat_provider import OpenAICompatProvider
diff --git a/deeptutor/services/llm/reasoning_params.py b/deeptutor/services/llm/reasoning_params.py
index 9d0106524..25d432975 100644
--- a/deeptutor/services/llm/reasoning_params.py
+++ b/deeptutor/services/llm/reasoning_params.py
@@ -68,6 +68,41 @@ _THINKING_DISABLED_BY_DEFAULT_MODELS: tuple[str, ...] = ()
_THINKING_DISABLED_BY_DEFAULT: tuple[tuple[str, str], ...] = ()
+def minimax_reasoning_kwargs(
+ model: str, effort: str, *, anthropic: bool = False
+) -> dict[str, Any] | None:
+ """Map current MiniMax models without changing saved legacy/custom requests.
+
+ See https://platform.minimax.io/docs/api-reference/text-openai-api and
+ https://platform.minimax.io/docs/api-reference/text-anthropic-api.
+ """
+ name = model.lower()
+ if name not in {"minimax-m3.1-flash", "minimax-m3"}:
+ return None
+ if name == "minimax-m3":
+ if not effort and not anthropic:
+ # Omission retains each protocol's own default, including when an
+ # agentic OpenAI facade forwards this request to Anthropic Messages.
+ return {}
+ enabled = effort not in {"none", "minimal", "minimum"} if effort else not anthropic
+ thinking = {"type": "adaptive" if enabled else "disabled"}
+ return {"thinking": thinking} if anthropic else {"extra_body": {"thinking": thinking}}
+ # Flash always uses adaptive reasoning. Saved off/binary values fall back
+ # to the vendor default effort rather than sending an unsupported mode.
+ thinking = {"type": "adaptive"}
+ result: dict[str, Any] = (
+ {"thinking": thinking}
+ if anthropic
+ else {"extra_body": {"thinking": thinking, "reasoning_split": True}}
+ )
+ if effort in {"low", "medium", "high", "xhigh", "max"}:
+ if anthropic:
+ result["output_config"] = {"effort": effort}
+ else:
+ result["reasoning_effort"] = effort
+ return result
+
+
def _spec_name(spec: Any, binding: str | None) -> str:
return str(getattr(spec, "name", None) or binding or "").strip().lower()
@@ -149,11 +184,20 @@ def build_openai_compatible_reasoning_kwargs(
``custom`` bindings need model-family inference because their endpoint is
user supplied and therefore cannot be identified by provider name alone.
"""
- if reasoning_effort == "":
- return {}
-
provider_name = _spec_name(spec, binding)
model_name = model or ""
+ if provider_name == "minimax":
+ minimax = minimax_reasoning_kwargs(model_name, (reasoning_effort or "").strip().lower())
+ if minimax is not None:
+ return minimax
+ if (
+ provider_name == "openrouter"
+ and model_name.lower() == "minimax/minimax-m3.1-flash:free"
+ and reasoning_effort in {"none", "minimal", "minimum"}
+ ):
+ return {}
+ if reasoning_effort == "":
+ return {}
thinking_style = str(getattr(spec, "thinking_style", "") or "")
patterns = tuple(getattr(spec, "reasoning_model_patterns", ()) or ())
diff --git a/deeptutor/services/model_selection/reasoning.py b/deeptutor/services/model_selection/reasoning.py
index b450090db..797c2f8c4 100644
--- a/deeptutor/services/model_selection/reasoning.py
+++ b/deeptutor/services/model_selection/reasoning.py
@@ -31,6 +31,11 @@ def supported_reasoning_efforts(
"anthropic_compatible": "custom_anthropic",
}.get(provider, provider)
spec = find_by_name(provider)
+ if spec and spec.name in {"minimax", "minimax_anthropic"}:
+ if model.lower() == "minimax-m3.1-flash":
+ return ["low", "medium", "high", "xhigh", "max"]
+ if model.lower() == "minimax-m3":
+ return ["none", "adaptive"]
binary_choices = None
if spec is None or spec.backend in {"openai_compat", "azure_openai"}:
# Use the actual wire mapper, including custom model-family inference.
diff --git a/deeptutor/services/settings/provider_probe.py b/deeptutor/services/settings/provider_probe.py
index 86c6465b9..c581f018d 100644
--- a/deeptutor/services/settings/provider_probe.py
+++ b/deeptutor/services/settings/provider_probe.py
@@ -10,6 +10,7 @@ import aiohttp
import requests
from deeptutor.services.llm.cloud_provider import _auth_binding, _get_aiohttp_connector
+from deeptutor.services.llm.minimax_models import active_model_names
from deeptutor.services.llm.utils import build_auth_headers, collect_model_names
@@ -336,7 +337,10 @@ async def probe_provider(
if kinds:
entry["services"] = kinds
models[name] = entry
- result = {"status": "connected", "models": list(models.values())}
+ result = {
+ "status": "connected",
+ "models": [models[name] for name in active_model_names(list(models), binding)],
+ }
capabilities = detect_capabilities(all_items)
if capabilities:
result["capabilities"] = capabilities
diff --git a/tests/services/llm/test_cloud_provider.py b/tests/services/llm/test_cloud_provider.py
index 2d6e5a63a..340960d44 100644
--- a/tests/services/llm/test_cloud_provider.py
+++ b/tests/services/llm/test_cloud_provider.py
@@ -98,6 +98,17 @@ async def test_cloud_fetch_models_non_200_returns_empty(monkeypatch: MonkeyPatch
assert await cloud_provider.fetch_models("https://api.openai.com/v1", "bad") == []
+async def test_minimax_discovery_recommends_current_text_models(monkeypatch: MonkeyPatch) -> None:
+ names = ["MiniMax-M2.7", "MiniMax-M3", "speech-2.8-hd", "MiniMax-M3.1-Flash"]
+ _install_session(monkeypatch, _FakeResponse(200, {"data": [{"id": name} for name in names]}))
+ assert await cloud_provider.fetch_models("https://api.minimax.io/v1", "fixture", "minimax") == [
+ "MiniMax-M3.1-Flash",
+ "MiniMax-M3",
+ "speech-2.8-hd",
+ ]
+
+
def test_ssl_connector(monkeypatch: MonkeyPatch) -> None:
"""The aiohttp connector only appears when TLS verification is disabled."""
monkeypatch.delenv("DISABLE_SSL_VERIFY", raising=False)
diff --git a/tests/services/llm/test_minimax_current_models.py b/tests/services/llm/test_minimax_current_models.py
new file mode 100644
index 000000000..b3320e75a
--- /dev/null
+++ b/tests/services/llm/test_minimax_current_models.py
@@ -0,0 +1,371 @@
+"""Exercise current MiniMax discovery and real SDK request serialization offline."""
+
+from __future__ import annotations
+
+import importlib
+import json
+
+import httpx
+import pytest
+
+from deeptutor.runtime.agentic.client import (
+ LLMClientConfig,
+ _build_openai_client,
+ build_completion_kwargs,
+)
+from deeptutor.services.llm.config import LLMConfig
+from deeptutor.services.llm.context_window import known_context_window
+from deeptutor.services.llm.minimax_models import active_model_names
+from deeptutor.services.llm.provider_factory import _build_runtime_provider
+from deeptutor.services.model_selection.reasoning import supported_reasoning_efforts
+
+
+def mocked_sdk(sdk, handle):
+ # Both supported SDK ranges include releases using httpx and httpx2.
+ base = importlib.import_module(type(sdk).__module__.split(".")[0] + "._base_client")
+ transport = getattr(base, "httpx2", None) or base.httpx
+
+ def adapt(request):
+ response = handle(request)
+ return transport.Response(
+ response.status_code, headers=response.headers, content=response.content
+ )
+
+ return sdk.with_options(
+ http_client=transport.AsyncClient(transport=transport.MockTransport(adapt))
+ )
+
+
+FLASH = "MiniMax-M3.1-Flash"
+TOOLS = [
+ {
+ "type": "function",
+ "function": {
+ "name": "lookup",
+ "description": "Look up a fact",
+ "parameters": {"type": "object", "properties": {}},
+ },
+ }
+]
+
+
+ "binding,prefix,suffix",
+ [("minimax", "", ""), ("minimax_anthropic", "", ""), ("openrouter", "minimax/", ":free")],
+)
+def test_active_discovery_preserves_unrelated_models(binding, prefix, suffix):
+ flash = prefix + FLASH + suffix
+ m3 = prefix + "MiniMax-M3"
+ saved = [prefix + "MiniMax-M2.7", "custom-deployment", "speech-2.8-hd", m3, flash]
+ assert active_model_names(saved, binding) == [flash, m3, "custom-deployment", "speech-2.8-hd"]
+ assert saved[0] == prefix + "MiniMax-M2.7"
+ assert active_model_names(saved, "custom") == saved
+ assert active_model_names([m3], binding) == [m3]
+ assert active_model_names([], binding) == []
+
+
+def test_context_windows_keep_gateway_provenance():
+ assert known_context_window(FLASH) == 1000000
+ assert known_context_window("MiniMax-M3") == 1000000
+ assert known_context_window("minimax/minimax-m3.1-flash:free") == 1000000
+ assert known_context_window("minimax/minimax-m3") == 1048576
+ assert known_context_window("MiniMax-M2.7") == 204800
+
+
[email protected]("binding", ["minimax", "minimax_anthropic"])
+def test_reasoning_choices_follow_model_contract(binding):
+ assert supported_reasoning_efforts(binding, FLASH) == ["low", "medium", "high", "xhigh", "max"]
+ assert supported_reasoning_efforts(binding, "MiniMax-M3") == ["none", "adaptive"]
+
+
[email protected]("api_format", ["openai_chat", "anthropic"])
[email protected]("model", [FLASH, "MiniMax-M3"])
[email protected]("effort", [None, "none", "low", "xhigh", "max"])
+async def test_agentic_real_sdk_payload(api_format, model, effort):
+ anthropic = api_format == "anthropic"
+ client = _build_openai_client(
+ LLMClientConfig(
+ binding="minimax",
+ model=model,
+ api_key="fixture-key",
+ base_url=None,
+ api_format=api_format,
+ ),
+ disable_ssl_verify=False,
+ )
+ requests = []
+
+ def handle(request):
+ requests.append(request)
+ return httpx.Response(200, json=response_payload(anthropic))
+
+ sdk = client._provider._client if anthropic else client
+ patched = mocked_sdk(sdk, handle)
+ await sdk.close()
+ if anthropic:
+ client._provider._client = patched
+ else:
+ client = patched
+ try:
+ result = await client.chat.completions.create(
+ model=model,
+ messages=[{"role": "user", "content": "Hello"}],
+ tools=TOOLS,
+ **build_completion_kwargs(
+ binding="minimax",
+ model=model,
+ temperature=0.7,
+ max_tokens=4096,
+ reasoning_effort=effort,
+ ),
+ )
+ assert result.choices[0].message.content == "OK"
+ body = json.loads(requests[0].content)
+ assert body["model"] == model
+ if model == FLASH:
+ assert body["thinking"] == {"type": "adaptive"}
+ if anthropic:
+ assert "reasoning_split" not in body
+ assert body.get("output_config", {}).get("effort") == (
+ effort if effort in {"low", "xhigh", "max"} else None
+ )
+ elif effort:
+ assert body["thinking"] == {"type": "disabled" if effort == "none" else "adaptive"}
+ assert "reasoning_effort" not in body
+ elif anthropic:
+ assert body["thinking"] == {"type": "disabled"}
+ else:
+ assert "thinking" not in body
+ finally:
+ await client.close()
+
+
[email protected]("model", ["minimax/minimax-m3.1-flash:free", "minimax/minimax-m3"])
+async def test_openrouter_sdk_keeps_verified_route(model):
+ provider = _build_runtime_provider(
+ LLMConfig(
+ provider_name="openrouter",
+ binding="openrouter",
+ model=model,
+ api_key="fixture-key",
+ base_url="https://openrouter.ai/api/v1",
+ ),
+ configure_env=False,
+ )
+ requests = []
+
+ def handle(request):
+ requests.append(request)
+ return httpx.Response(200, json=response_payload(False))
+
+ old_client = provider._client
+ provider._client = mocked_sdk(old_client, handle)
+ await old_client.close()
+ try:
+ result = await provider.chat(messages=[{"role": "user", "content": "Hello"}])
+ assert result.content == "OK", result
+ body = json.loads(requests[0].content)
+ assert body["model"] == model
+ assert str(requests[0].url) == "https://openrouter.ai/api/v1/chat/completions"
+ assert "thinking" not in body
+ assert "reasoning_split" not in body
+ finally:
+ await provider._client.close()
+
+
+def response_payload(anthropic):
+ if anthropic:
+ return {
+ "id": "msg_test",
+ "type": "message",
+ "role": "assistant",
+ "model": FLASH,
+ "content": [{"type": "text", "text": "OK"}],
+ "stop_reason": "end_turn",
+ "usage": {"input_tokens": 1, "output_tokens": 1},
+ }
+ return {
+ "id": "chat_test",
+ "object": "chat.completion",
+ "created": 1,
+ "model": FLASH,
+ "choices": [
+ {"index": 0, "message": {"role": "assistant", "content": "OK"}, "finish_reason": "stop"}
+ ],
+ "usage": {"prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2},
+ }
+
+
+def stream_payload(anthropic):
+ if anthropic:
+ message = response_payload(True)
+ message["content"] = []
+ message["stop_reason"] = None
+ events = [
+ ("message_start", {"message": message}),
+ ("content_block_start", {"index": 0, "content_block": {"type": "text", "text": ""}}),
+ ("content_block_delta", {"index": 0, "delta": {"type": "text_delta", "text": "OK"}}),
+ ("content_block_stop", {"index": 0}),
+ (
+ "message_delta",
+ {
+ "delta": {"stop_reason": "end_turn", "stop_sequence": None},
+ "usage": {"output_tokens": 1},
+ },
+ ),
+ ("message_stop", {}),
+ ]
+ return "".join(
+ f"event: {kind}\ndata: {json.dumps({'type': kind, **data})}\n\n"
+ for kind, data in events
+ )
+ return 'data: {"id":"chat_test","object":"chat.completion.chunk","created":1,"model":"MiniMax-M3.1-Flash","choices":[{"index":0,"delta":{"content":"OK"},"finish_reason":null}]}\n\ndata: {"id":"chat_test","object":"chat.completion.chunk","created":1,"model":"MiniMax-M3.1-Flash","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}\n\ndata: [DONE]\n\n'
+
+
[email protected]("api_format", ["openai_chat", "anthropic"])
[email protected]("host", ["api.minimax.io", "api.minimaxi.com"])
+ "effort", [None, "", "low", "medium", "high", "xhigh", "max", "none", "minimal"]
+)
+async def test_flash_real_sdk_payload(api_format, host, effort):
+ anthropic = api_format == "anthropic"
+ base = f"https://{host}/" + ("anthropic" if anthropic else "v1")
+ provider = _build_runtime_provider(
+ LLMConfig(
+ provider_name="minimax",
+ binding="minimax",
+ model=FLASH,
+ api_key="fixture-key",
+ base_url=base,
+ api_format=api_format,
+ ),
+ configure_env=False,
+ )
+ requests = []
+
+ def handle(request):
+ requests.append(request)
+ return httpx.Response(200, json=response_payload(anthropic))
+
+ old_client = provider._client
+ provider._client = mocked_sdk(old_client, handle)
+ await old_client.close()
+ try:
+ response = await provider.chat(
+ messages=[{"role": "user", "content": "Hello"}], tools=TOOLS, reasoning_effort=effort
+ )
+ assert response.content == "OK", response
+ assert len(requests) == 1
+ request = requests[0]
+ body = json.loads(request.content)
+ assert str(request.url) == base + ("/v1/messages" if anthropic else "/chat/completions")
+ assert body["model"] == FLASH
+ assert body["thinking"] == {"type": "adaptive"}
+ assert "service_tier" not in body
+ assert body.get("reasoning_split") is not False
+ if anthropic:
+ assert request.headers["x-api-key"] == "fixture-key"
+ assert body.get("output_config", {}).get("effort") == (
+ effort if effort in {"low", "medium", "high", "xhigh", "max"} else None
+ )
+ assert "reasoning_effort" not in body
+ else:
+ assert request.headers["authorization"] == "Bearer fixture-key"
+ assert body.get("reasoning_effort") == (
+ effort if effort in {"low", "medium", "high", "xhigh", "max"} else None
+ )
+ assert body["tools"]
+ image_url = "https://example.test/diagram.png"
+ replay = [
+ {
+ "role": "user",
+ "content": [
+ {"type": "text", "text": "Read this"},
+ {"type": "image_url", "image_url": {"url": image_url}},
+ ],
+ },
+ {
+ "role": "assistant",
+ "content": "",
+ "reasoning_content": "Need lookup",
+ "tool_calls": [
+ {
+ "id": "call_lookup",
+ "type": "function",
+ "function": {"name": "lookup", "arguments": "{}"},
+ }
+ ],
+ },
+ {"role": "tool", "tool_call_id": "call_lookup", "content": "Found it"},
+ ]
+ if anthropic:
+ replay[1]["_provider_response_state"] = {
+ "thinking_blocks": [
+ {
+ "type": "thinking",
+ "thinking": "Need lookup",
+ "signature": "fixture-signature",
+ }
+ ]
+ }
+ response = await provider.chat(messages=replay, tools=TOOLS, reasoning_effort=effort)
+ assert response.content == "OK", response
+ replay_body = json.loads(requests[1].content)
+ assert replay_body["thinking"] == {"type": "adaptive"}
+ assert image_url in json.dumps(replay_body)
+ if anthropic:
+ assert "call_lookup" in json.dumps(replay_body)
+ assert "fixture-signature" in json.dumps(replay_body)
+ else:
+ assistant = replay_body["messages"][1]
+ assert assistant["tool_calls"][0]["function"]["name"] == "lookup"
+ assert assistant["tool_calls"][0]["id"] == replay_body["messages"][2]["tool_call_id"]
+ assert assistant["reasoning_content"] == "Need lookup"
+ finally:
+ await provider._client.close()
+
+
[email protected]("api_format", ["openai_chat", "anthropic"])
[email protected]("model", [FLASH, "MiniMax-M3", "MiniMax-M2.7", "saved-custom-deployment"])
+async def test_saved_models_and_streaming_keep_ids(api_format, model):
+ anthropic = api_format == "anthropic"
+ provider = _build_runtime_provider(
+ LLMConfig(
+ provider_name="minimax",
+ binding="minimax",
+ model=model,
+ api_key="fixture-key",
+ base_url="https://gateway.example/anthropic"
+ if anthropic
+ else "https://gateway.example/v1",
+ api_format=api_format,
+ ),
+ configure_env=False,
+ )
+ bodies = []
+
+ def handle(request):
+ bodies.append(json.loads(request.content))
+ return httpx.Response(
+ 200, headers={"content-type": "text/event-stream"}, text=stream_payload(anthropic)
+ )
+
+ old_client = provider._client
+ provider._client = mocked_sdk(old_client, handle)
+ await old_client.close()
+ try:
+ response = await provider.chat_stream(messages=[{"role": "user", "content": "Hello"}])
+ assert response.content == "OK", response
+ assert bodies[0]["model"] == model
+ assert bodies[0]["stream"] is True
+ if model == FLASH:
+ assert bodies[0]["thinking"] == {"type": "adaptive"}
+ elif model == "MiniMax-M3":
+ assert bodies[0].get("thinking") == ({"type": "disabled"} if anthropic else None)
+ assert "reasoning_effort" not in bodies[0]
+ finally:
+ await provider._client.close()
diff --git a/web/components/settings/ServiceConfigEditor.tsx b/web/components/settings/ServiceConfigEditor.tsx
index b16b60f9c..20dc28eb7 100644
--- a/web/components/settings/ServiceConfigEditor.tsx
+++ b/web/components/settings/ServiceConfigEditor.tsx
@@ -430,6 +430,18 @@ export function ServiceConfigEditor({
model: item.id,
};
});
+ if (
+ service === "llm" &&
+ ["minimax", "minimax_anthropic", "openrouter"].includes(binding)
+ ) {
+ // Discovery recommendations must not erase saved legacy/custom models.
+ const discovered = new Set(fetched.map((item) => item.id));
+ profile.models.push(
+ ...Array.from(existing.values()).filter(
+ (model) => !discovered.has(model.model),
+ ),
+ );
+ }
if (
target.active_profile_id === profile.id &&
!profile.models.some(
diff --git a/web/lib/reasoning-effort.ts b/web/lib/reasoning-effort.ts
index af6e73978..21e9f6115 100644
--- a/web/lib/reasoning-effort.ts
+++ b/web/lib/reasoning-effort.ts
@@ -104,6 +104,15 @@ function tableReasoningEffortOptions(
const provider = PROVIDER_ALIASES[canonical] ?? canonical;
const modelName = (model ?? "").trim().toLowerCase();
+ if (["minimax", "minimax_anthropic"].includes(provider)) {
+ if (modelName === "minimax-m3.1-flash") {
+ return options(["low", "medium", "high", "xhigh", "max"], current);
+ }
+ if (modelName === "minimax-m3") {
+ return options(["none", "adaptive"], current);
+ }
+ }
+
if (provider === "gemini" || modelName.includes("gemini")) {
if (
modelName.includes("gemini-3") ||
diff --git a/web/tests/reasoning-effort.test.ts b/web/tests/reasoning-effort.test.ts
index 7fa44a5e7..d76b676fe 100644
--- a/web/tests/reasoning-effort.test.ts
+++ b/web/tests/reasoning-effort.test.ts
@@ -10,6 +10,16 @@ import {
const values = (binding: string, model: string, current = ""): string[] =>
reasoningEffortOptions(binding, model, current).map((option) => option.value);
+test("MiniMax Flash exposes adaptive effort levels and preserves saved values", () => {
+ for (const binding of ["minimax", "minimax_anthropic"]) {
+ assert.deepEqual(values(binding, "MiniMax-M3.1-Flash"), [
+ "", "low", "medium", "high", "xhigh", "max",
+ ]);
+ assert.deepEqual(values(binding, "MiniMax-M3"), ["", "none", "adaptive"]);
+ assert.equal(values(binding, "MiniMax-M3.1-Flash", "none").includes("none"), true);
+ }
+});
+
test("Gemini 3 and 2.5 Pro do not list the invalid none effort", () => {
assert.deepEqual(values("gemini", "gemini-3.6-flash"), [
"",