Personal AI, On Personal Devices
Python
feat: upgrade MiniMax default model to M3 (#468)
Octopus7a55974e814e
diff --git a/docs/getting-started/configuration.md b/docs/getting-started/configuration.mdindex e3765905..5d6f0d7d 100644--- a/docs/getting-started/configuration.md+++ b/docs/getting-started/configuration.md@@ -1087,7 +1087,7 @@ OpenJarvis respects the following environment variables:| `OPENAI_API_KEY` | API key for OpenAI cloud inference. Required for the `cloud` engine with OpenAI models. || `ANTHROPIC_API_KEY` | API key for Anthropic cloud inference. Required for the `cloud` engine with Claude models. || `GOOGLE_API_KEY` | API key for Google Gemini inference. Required for the `google` engine. |-| `MINIMAX_API_KEY` | API key for MiniMax cloud inference. Required for the `cloud` engine with MiniMax models (MiniMax-M2.7, MiniMax-M2.7-highspeed, MiniMax-M2.5, MiniMax-M2.5-highspeed). |+| `MINIMAX_API_KEY` | API key for MiniMax cloud inference. Required for the `cloud` engine with MiniMax models (MiniMax-M3, MiniMax-M2.7, MiniMax-M2.7-highspeed, MiniMax-M2.5, MiniMax-M2.5-highspeed). || `TAVILY_API_KEY` | API key for the Tavily web search tool. Required for the `web_search` tool. |## Next Stepsdiff --git a/src/openjarvis/engine/cloud.py b/src/openjarvis/engine/cloud.pyindex a55e0058..89e9102d 100644--- a/src/openjarvis/engine/cloud.py+++ b/src/openjarvis/engine/cloud.py@@ -48,6 +48,7 @@ PRICING: Dict[str, tuple[float, float]] = {"gemini-3.1-flash-lite-preview": (0.30, 2.50),"gemini-3-flash-preview": (0.50, 3.00),"claude-haiku-4-5-20251001": (1.00, 5.00),+ "MiniMax-M3": (0.30, 1.20),"MiniMax-M2.7": (0.30, 1.20),"MiniMax-M2.7-highspeed": (0.60, 2.40),"MiniMax-M2.5": (0.30, 1.20),@@ -56,6 +57,9 @@ PRICING: Dict[str, tuple[float, float]] = {"deepseek-v4-pro": (0.55, 2.19),}+_MINIMAX_M3_LONG_CONTEXT_THRESHOLD = 512_000+_MINIMAX_M3_LONG_CONTEXT_PRICING = (0.60, 2.40)+# Well-known model IDs per provider_OPENAI_MODELS = ["gpt-4o",@@ -84,6 +88,7 @@ _GOOGLE_MODELS = ["gemini-3-flash-preview",]_MINIMAX_MODELS = [+ "MiniMax-M3","MiniMax-M2.7","MiniMax-M2.7-highspeed","MiniMax-M2.5",@@ -209,6 +214,11 @@ def estimate_cost(model: str, prompt_tokens: int, completion_tokens: int) -> flobreakif prices is None:return 0.0+ if (+ model.startswith("MiniMax-M3")+ and prompt_tokens > _MINIMAX_M3_LONG_CONTEXT_THRESHOLD+ ):+ prices = _MINIMAX_M3_LONG_CONTEXT_PRICINGinput_cost = (prompt_tokens / 1_000_000) * prices[0]output_cost = (completion_tokens / 1_000_000) * prices[1]return input_cost + output_costdiff --git a/src/openjarvis/intelligence/model_catalog.py b/src/openjarvis/intelligence/model_catalog.pyindex 29bf3667..52b3b49d 100644--- a/src/openjarvis/intelligence/model_catalog.py+++ b/src/openjarvis/intelligence/model_catalog.py@@ -874,11 +874,29 @@ BUILTIN_MODELS: List[ModelSpec] = [# -----------------------------------------------------------------------# Cloud models — MiniMax# -----------------------------------------------------------------------+ ModelSpec(+ model_id="MiniMax-M3",+ name="MiniMax M3",+ parameter_count_b=0.0,+ context_length=1_000_000,+ supported_engines=("cloud",),+ provider="minimax",+ requires_api_key=True,+ metadata={+ "architecture": "proprietary",+ "pricing_input": 0.30,+ "pricing_output": 1.20,+ "pricing_long_context_input": 0.60,+ "pricing_long_context_output": 2.40,+ "pricing_long_context_threshold": 512_000,+ "url": "https://platform.minimax.io/docs/api-reference/api-overview",+ },+ ),ModelSpec(model_id="MiniMax-M2.7",name="MiniMax M2.7",parameter_count_b=0.0,- context_length=204800,+ context_length=204_800,supported_engines=("cloud",),provider="minimax",requires_api_key=True,@@ -886,14 +904,14 @@ BUILTIN_MODELS: List[ModelSpec] = ["architecture": "proprietary","pricing_input": 0.30,"pricing_output": 1.20,- "url": "https://www.minimax.io",+ "url": "https://platform.minimax.io/docs/api-reference/api-overview",},),ModelSpec(model_id="MiniMax-M2.7-highspeed",name="MiniMax M2.7 Highspeed",parameter_count_b=0.0,- context_length=204800,+ context_length=204_800,supported_engines=("cloud",),provider="minimax",requires_api_key=True,@@ -901,14 +919,14 @@ BUILTIN_MODELS: List[ModelSpec] = ["architecture": "proprietary","pricing_input": 0.60,"pricing_output": 2.40,- "url": "https://www.minimax.io",+ "url": "https://platform.minimax.io/docs/api-reference/api-overview",},),ModelSpec(model_id="MiniMax-M2.5",name="MiniMax M2.5",parameter_count_b=0.0,- context_length=204800,+ context_length=204_800,supported_engines=("cloud",),provider="minimax",requires_api_key=True,@@ -916,14 +934,14 @@ BUILTIN_MODELS: List[ModelSpec] = ["architecture": "proprietary","pricing_input": 0.30,"pricing_output": 1.20,- "url": "https://www.minimax.io",+ "url": "https://platform.minimax.io/docs/api-reference/api-overview",},),ModelSpec(model_id="MiniMax-M2.5-highspeed",name="MiniMax M2.5 Highspeed",parameter_count_b=0.0,- context_length=204800,+ context_length=204_800,supported_engines=("cloud",),provider="minimax",requires_api_key=True,@@ -931,7 +949,7 @@ BUILTIN_MODELS: List[ModelSpec] = ["architecture": "proprietary","pricing_input": 0.60,"pricing_output": 2.40,- "url": "https://www.minimax.io",+ "url": "https://platform.minimax.io/docs/api-reference/api-overview",},),# -----------------------------------------------------------------------diff --git a/tests/engine/test_cloud_minimax.py b/tests/engine/test_cloud_minimax.pyindex a58dc354..44aecb4c 100644--- a/tests/engine/test_cloud_minimax.py+++ b/tests/engine/test_cloud_minimax.py@@ -17,6 +17,7 @@ from openjarvis.engine.cloud import (_is_minimax_model,estimate_cost,)+from openjarvis.intelligence.model_catalog import BUILTIN_MODELSdef _make_cloud_engine(monkeypatch: pytest.MonkeyPatch) -> CloudEngine:@@ -34,7 +35,7 @@ def _make_cloud_engine(monkeypatch: pytest.MonkeyPatch) -> CloudEngine:def _fake_minimax_response(content: str = "Hello from MiniMax!",- model: str = "MiniMax-M2.5",+ model: str = "MiniMax-M3",prompt_tokens: int = 10,completion_tokens: int = 5,tool_calls: list | None = None,@@ -56,24 +57,26 @@ def _fake_minimax_response(class TestMiniMaxRouting:def test_is_minimax_model(self) -> None:+ assert _is_minimax_model("MiniMax-M3") is Trueassert _is_minimax_model("MiniMax-M2.7") is Trueassert _is_minimax_model("MiniMax-M2.7-highspeed") is Trueassert _is_minimax_model("MiniMax-M2.5") is Trueassert _is_minimax_model("MiniMax-M2.5-highspeed") is True- assert _is_minimax_model("minimax-m2.7") is True+ assert _is_minimax_model("minimax-m3") is Trueassert _is_minimax_model("gpt-4o") is Falseassert _is_minimax_model("claude-opus-4-6") is Falseassert _is_minimax_model("gemini-3-pro") is Falsedef test_minimax_models_list(self) -> None:+ assert "MiniMax-M3" in _MINIMAX_MODELSassert "MiniMax-M2.7" in _MINIMAX_MODELSassert "MiniMax-M2.7-highspeed" in _MINIMAX_MODELSassert "MiniMax-M2.5" in _MINIMAX_MODELSassert "MiniMax-M2.5-highspeed" in _MINIMAX_MODELS- def test_m27_is_first_in_list(self) -> None:- assert _MINIMAX_MODELS[0] == "MiniMax-M2.7"- assert _MINIMAX_MODELS[1] == "MiniMax-M2.7-highspeed"+ def test_m3_is_first_in_list(self) -> None:+ assert _MINIMAX_MODELS[0] == "MiniMax-M3"+ assert _MINIMAX_MODELS[1] == "MiniMax-M2.7"# ---------------------------------------------------------------------------@@ -113,6 +116,22 @@ class TestMiniMaxInit:class TestMiniMaxGenerate:+ def test_m3_generate(self, monkeypatch: pytest.MonkeyPatch) -> None:+ engine = _make_cloud_engine(monkeypatch)+ fake_client = mock.MagicMock()+ fake_client.chat.completions.create.return_value = _fake_minimax_response(+ content="I am MiniMax M3", model="MiniMax-M3"+ )+ engine._minimax_client = fake_client++ result = engine.generate(+ [Message(role=Role.USER, content="Hi")], model="MiniMax-M3"+ )+ assert result["content"] == "I am MiniMax M3"+ assert result["model"] == "MiniMax-M3"+ assert result["usage"]["prompt_tokens"] == 10+ assert result["usage"]["completion_tokens"] == 5+def test_m27_generate(self, monkeypatch: pytest.MonkeyPatch) -> None:engine = _make_cloud_engine(monkeypatch)fake_client = mock.MagicMock()@@ -143,35 +162,21 @@ class TestMiniMaxGenerate:assert result["content"] == "I am MiniMax M2.7 Highspeed"assert result["model"] == "MiniMax-M2.7-highspeed"- def test_m25_generate(self, monkeypatch: pytest.MonkeyPatch) -> None:+ @pytest.mark.parametrize("model", ["MiniMax-M2.5", "MiniMax-M2.5-highspeed"])+ def test_m25_models_remain_routable(+ self, monkeypatch: pytest.MonkeyPatch, model: str+ ) -> None:engine = _make_cloud_engine(monkeypatch)fake_client = mock.MagicMock()fake_client.chat.completions.create.return_value = _fake_minimax_response(- content="I am MiniMax M2.5", model="MiniMax-M2.5"+ content="I am MiniMax M2.5", model=model)engine._minimax_client = fake_client- result = engine.generate(- [Message(role=Role.USER, content="Hi")], model="MiniMax-M2.5"- )- assert result["content"] == "I am MiniMax M2.5"- assert result["model"] == "MiniMax-M2.5"- assert result["usage"]["prompt_tokens"] == 10- assert result["usage"]["completion_tokens"] == 5-- def test_m25_highspeed_generate(self, monkeypatch: pytest.MonkeyPatch) -> None:- engine = _make_cloud_engine(monkeypatch)- fake_client = mock.MagicMock()- fake_client.chat.completions.create.return_value = _fake_minimax_response(- content="I am MiniMax M2.5 Highspeed", model="MiniMax-M2.5-highspeed"- )- engine._minimax_client = fake_client+ result = engine.generate([Message(role=Role.USER, content="Hi")], model=model)- result = engine.generate(- [Message(role=Role.USER, content="Hi")], model="MiniMax-M2.5-highspeed"- )- assert result["content"] == "I am MiniMax M2.5 Highspeed"- assert result["model"] == "MiniMax-M2.5-highspeed"+ assert result["content"] == "I am MiniMax M2.5"+ assert result["model"] == modeldef test_temperature_clamped_above_zero(self, monkeypatch: pytest.MonkeyPatch@@ -184,7 +189,7 @@ class TestMiniMaxGenerate:engine.generate([Message(role=Role.USER, content="Hi")],- model="MiniMax-M2.5",+ model="MiniMax-M3",temperature=0.0,)call_kwargs = fake_client.chat.completions.create.call_args@@ -202,7 +207,7 @@ class TestMiniMaxGenerate:engine.generate([Message(role=Role.USER, content="Hi")],- model="MiniMax-M2.5",+ model="MiniMax-M3",temperature=2.0,)call_kwargs = fake_client.chat.completions.create.call_args@@ -218,7 +223,7 @@ class TestMiniMaxGenerate:type="function",function=SimpleNamespace(name="search", arguments='{"q":"test"}'),)- fake_resp = _fake_minimax_response(content="", model="MiniMax-M2.5")+ fake_resp = _fake_minimax_response(content="", model="MiniMax-M3")fake_resp.choices[0].message.tool_calls = [fake_tool_call]fake_client = mock.MagicMock()@@ -226,7 +231,7 @@ class TestMiniMaxGenerate:engine._minimax_client = fake_clientresult = engine.generate(- [Message(role=Role.USER, content="Search")], model="MiniMax-M2.5"+ [Message(role=Role.USER, content="Search")], model="MiniMax-M3")assert "tool_calls" in resultassert len(result["tool_calls"]) == 1@@ -243,7 +248,7 @@ class TestMiniMaxGenerate:engine._minimax_client = fake_clientresult = engine.generate(- [Message(role=Role.USER, content="Hi")], model="MiniMax-M2.5"+ [Message(role=Role.USER, content="Hi")], model="MiniMax-M3")assert "tool_calls" not in result@@ -252,9 +257,7 @@ class TestMiniMaxGenerate:assert engine._minimax_client is Nonewith pytest.raises(EngineConnectionError, match="MiniMax client not available"):- engine.generate(- [Message(role=Role.USER, content="Hi")], model="MiniMax-M2.5"- )+ engine.generate([Message(role=Role.USER, content="Hi")], model="MiniMax-M3")# ---------------------------------------------------------------------------@@ -286,11 +289,22 @@ class TestMiniMaxModelDiscovery:class TestMiniMaxPricing:def test_minimax_models_in_pricing(self) -> None:+ assert "MiniMax-M3" in PRICINGassert "MiniMax-M2.7" in PRICINGassert "MiniMax-M2.7-highspeed" in PRICINGassert "MiniMax-M2.5" in PRICINGassert "MiniMax-M2.5-highspeed" in PRICING+ def test_minimax_m3_standard_cost_estimate(self) -> None:+ # Official permanent-discount tier for requests at or below 512k input.+ cost = estimate_cost("MiniMax-M3", 500_000, 1_000_000)+ assert cost == pytest.approx(1.35)++ def test_minimax_m3_long_context_cost_estimate(self) -> None:+ # Above 512k input, both input and output use the long-context tier.+ cost = estimate_cost("MiniMax-M3", 600_000, 1_000_000)+ assert cost == pytest.approx(2.76)+def test_minimax_m27_cost_estimate(self) -> None:# MiniMax-M2.7: $0.30/M in, $1.20/M outcost = estimate_cost("MiniMax-M2.7", 1_000_000, 1_000_000)@@ -301,13 +315,28 @@ class TestMiniMaxPricing:cost = estimate_cost("MiniMax-M2.7-highspeed", 1_000_000, 1_000_000)assert cost == pytest.approx(3.00)- def test_minimax_m25_cost_estimate(self) -> None:- # MiniMax-M2.5: $0.30/M in, $1.20/M out- cost = estimate_cost("MiniMax-M2.5", 1_000_000, 1_000_000)- assert cost == pytest.approx(1.50)+ @pytest.mark.parametrize(+ ("model", "expected"),+ [("MiniMax-M2.5", 1.50), ("MiniMax-M2.5-highspeed", 3.00)],+ )+ def test_minimax_m25_cost_estimates(self, model: str, expected: float) -> None:+ assert estimate_cost(model, 1_000_000, 1_000_000) == pytest.approx(expected)def test_zero_tokens_zero_cost(self) -> None:- assert estimate_cost("MiniMax-M2.7", 0, 0) == 0.0+ assert estimate_cost("MiniMax-M3", 0, 0) == 0.0++ def test_catalog_matches_official_context_windows(self) -> None:+ specs = {+ spec.model_id: spec for spec in BUILTIN_MODELS if spec.provider == "minimax"+ }+ assert specs["MiniMax-M3"].context_length == 1_000_000+ for model_id in (+ "MiniMax-M2.7",+ "MiniMax-M2.7-highspeed",+ "MiniMax-M2.5",+ "MiniMax-M2.5-highspeed",+ ):+ assert specs[model_id].context_length == 204_800# ---------------------------------------------------------------------------diff --git a/tests/integration/test_minimax_cloud.py b/tests/integration/test_minimax_cloud.pyindex 1cf0cec7..04ec9165 100644--- a/tests/integration/test_minimax_cloud.py+++ b/tests/integration/test_minimax_cloud.py@@ -37,11 +37,11 @@ class TestMiniMaxCloudIntegration:EngineRegistry.register_value("cloud", CloudEngine)return CloudEngine()- def test_m27_highspeed_basic_chat(self, engine: CloudEngine) -> None:- """Send a simple message via M2.7-highspeed and verify non-empty response."""+ def test_m3_basic_chat(self, engine: CloudEngine) -> None:+ """Send a simple message via M3 and verify non-empty response."""result = engine.generate([Message(role=Role.USER, content="Reply with exactly: hello world")],- model="MiniMax-M2.7-highspeed",+ model="MiniMax-M3",temperature=0.01,max_tokens=32,)@@ -50,13 +50,14 @@ class TestMiniMaxCloudIntegration:assert result["usage"]["completion_tokens"] > 0assert result["finish_reason"] in ("stop", "length")- def test_m27_highspeed_health(self, engine: CloudEngine) -> None:+ def test_minimax_health(self, engine: CloudEngine) -> None:"""Engine health should be True when MINIMAX_API_KEY is set."""assert engine.health() is True- def test_m27_highspeed_list_models(self, engine: CloudEngine) -> None:+ def test_minimax_list_models(self, engine: CloudEngine) -> None:"""MiniMax models should appear in list_models."""models = engine.list_models()+ assert "MiniMax-M3" in modelsassert "MiniMax-M2.7" in modelsassert "MiniMax-M2.7-highspeed" in modelsassert "MiniMax-M2.5" in models