Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat(ai): default MiniMax to M3.1 Flash with supported effort levels (#12885)

Octopus738a3b38f165
diff --git a/apps/desktop/src/stores/__tests__/settingsStore.spec.ts b/apps/desktop/src/stores/__tests__/settingsStore.spec.ts
index 39641d3ba6..fc6fa729dd 100644
--- a/apps/desktop/src/stores/__tests__/settingsStore.spec.ts
+++ b/apps/desktop/src/stores/__tests__/settingsStore.spec.ts
@@ -1480,6 +1480,13 @@ describe("settingsStore AI API key normalization", () => {
expect(AI_PROVIDER_PRESETS).not.toHaveProperty(CC_SWITCH_PROVIDER_ID);
});
+ it("defaults new MiniMax configurations to Flash and preserves explicit models", () => {
+ expect(normalizeAiConfig({ provider: "minimax" }).model).toBe("MiniMax-M3.1-Flash");
+ for (const model of ["MiniMax-M3", "MiniMax-M2.7", "private-model", ""]) {
+ expect(normalizeAiConfig({ provider: "minimax", model }).model).toBe(model);
+ }
+ });
+
it("preserves saved MiniMax endpoints during normalization", () => {
expect(normalizeAiConfig({ provider: "minimax", endpoint: "https://api.minimaxi.com/v1" }).endpoint).toBe("https://api.minimaxi.com/v1");
expect(normalizeAiConfig({ provider: "minimax", endpoint: "https://minimax.example.com/v1" }).endpoint).toBe("https://minimax.example.com/v1");
diff --git a/apps/desktop/src/stores/settingsStore.ts b/apps/desktop/src/stores/settingsStore.ts
index 7351b2edcd..e2fa5c52f6 100644
--- a/apps/desktop/src/stores/settingsStore.ts
+++ b/apps/desktop/src/stores/settingsStore.ts
@@ -397,7 +397,7 @@ export const AI_PROVIDER_PRESETS: Record<AiProvider, AiProviderPreset> = {
iconSlug: "minimax",
provider: "minimax",
endpoint: "https://api.minimax.io/v1",
- model: "MiniMax-M3",
+ model: "MiniMax-M3.1-Flash",
apiStyle: "completions",
authMethod: "bearer",
requiresApiKey: true,
diff --git a/crates/dbx-ai-provider/src/ai.rs b/crates/dbx-ai-provider/src/ai.rs
index 5bbd5bbfc1..d12990e08c 100644
--- a/crates/dbx-ai-provider/src/ai.rs
+++ b/crates/dbx-ai-provider/src/ai.rs
@@ -1536,7 +1536,10 @@ fn apply_chat_completion_thinking_toggle(body: &mut serde_json::Value, config: &
}
if matches!(config.provider, AiProvider::MiniMax) {
- body["thinking"] = json!({ "type": "disabled" });
+ // Flash is adaptive-only, even when a saved legacy toggle is off.
+ if !config.model.trim().eq_ignore_ascii_case("MiniMax-M3.1-Flash") {
+ body["thinking"] = json!({ "type": "disabled" });
+ }
} else if matches!(config.provider, AiProvider::Ollama) {
// Ollama's OpenAI-compatible API uses reasoning_effort instead of
// forwarding provider-specific chat template arguments.
@@ -5451,13 +5454,17 @@ mod tests {
let (name, value) = line.split_once(':')?;
name.eq_ignore_ascii_case("content-length").then(|| value.trim().parse::<usize>().unwrap())
})
- .unwrap();
+ .unwrap_or(0);
while request.len() < header_end + content_length {
let read = socket.read(&mut chunk).await.unwrap();
assert!(read > 0, "request ended before body was complete");
request.extend_from_slice(&chunk[..read]);
}
- let body = serde_json::from_slice(&request[header_end..header_end + content_length]).unwrap();
+ let body = if content_length == 0 {
+ serde_json::Value::Null
+ } else {
+ serde_json::from_slice(&request[header_end..header_end + content_length]).unwrap()
+ };
let response = format!(
"HTTP/1.1 200 OK\r\nContent-Type: {response_content_type}\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{response_body}",
response_body.len()
@@ -8205,6 +8212,63 @@ mod tests {
assert!(captured.body.get("max_tokens").is_none());
}
+ #[tokio::test]
+ async fn minimax_catalog_prefers_flash_without_changing_saved_models() {
+ let (endpoint, server) = spawn_json_capture_server(
+ "application/json",
+ r#"{"data":[
+ {"id":"MiniMax-M2.7"},{"id":"MiniMax-M3"},{"id":"MiniMax-M3.1-Flash"}
+ ]}"#,
+ )
+ .await;
+ let mut config = minimax_test_config(endpoint.trim_end_matches("/messages"));
+ config.model = "MiniMax-M2.7".to_string();
+ let models = list_models_core(&config).await.unwrap();
+ assert_eq!(
+ models.iter().map(|model| model.id.as_str()).collect::<Vec<_>>(),
+ ["MiniMax-M3.1-Flash", "MiniMax-M3"]
+ );
+ assert_eq!(config.model, "MiniMax-M2.7");
+ assert!(server.await.unwrap().headers.starts_with("GET /v1/models "));
+ }
+
+ #[tokio::test]
+ async fn minimax_flash_completion_preserves_model_and_serializes_supported_effort() {
+ for model in ["MiniMax-M3.1-Flash", "MiniMax-M3", "MiniMax-M2.7", "private-model"] {
+ for effort in [None, Some(AiEffortSelection::ProviderDefault)] {
+ let (endpoint, server) =
+ spawn_json_capture_server("application/json", r#"{"choices":[{"message":{"content":"ok"}}]}"#)
+ .await;
+ let mut request = minimax_test_request(endpoint.trim_end_matches("/messages"));
+ request.config.model = model.to_string();
+ request.config.enable_thinking = false;
+ request.config.runtime_effort = effort.clone();
+ assert_eq!(complete(&request).await.unwrap(), "ok");
+ let captured = server.await.unwrap();
+ assert_eq!(captured.body["model"], model);
+ assert_eq!(captured.body["reasoning_split"], true);
+ assert!(captured.body.get("reasoning_effort").is_none());
+ if model == "MiniMax-M3.1-Flash" || effort.is_some() {
+ assert!(captured.body.get("thinking").is_none());
+ } else {
+ assert_eq!(captured.body["thinking"]["type"], "disabled");
+ }
+ assert!(captured.body.get("service_tier").is_none());
+ }
+ }
+ for effort in ["low", "medium", "high", "xhigh", "max"] {
+ let (endpoint, server) =
+ spawn_json_capture_server("application/json", r#"{"choices":[{"message":{"content":"ok"}}]}"#).await;
+ let mut request = minimax_test_request(endpoint.trim_end_matches("/messages"));
+ request.config.model = "MiniMax-M3.1-Flash".to_string();
+ request.config.runtime_effort = Some(AiEffortSelection::Enum(effort.to_string()));
+ assert_eq!(complete(&request).await.unwrap(), "ok");
+ let captured = server.await.unwrap();
+ assert_eq!(captured.body["reasoning_effort"], effort);
+ assert!(captured.body.get("thinking").is_none());
+ }
+ }
+
#[test]
fn minimax_cumulative_text_normalizer_emits_only_new_suffixes() {
let mut normalizer = MiniMaxTextAccumulator::default();
@@ -8481,12 +8545,45 @@ mod tests {
);
let (capture_endpoint, server) = spawn_json_capture_server("text/event-stream", response).await;
let endpoint = capture_endpoint.trim_end_matches("/v1/messages").to_string();
- let request = minimax_test_request(endpoint);
+ let mut request = minimax_test_request(endpoint);
+ request.config.model = "MiniMax-M3.1-Flash".to_string();
+ request.config.enable_thinking = false;
+ request.config.runtime_effort = Some(AiEffortSelection::Enum("high".to_string()));
+ request.messages[0]
+ .images
+ .push(AiInlineImage { media_type: "image/png".to_string(), data: "aGVsbG8=".to_string() });
+ let details = serde_json::json!([{"type": "reasoning.text", "text": "Inspect tables"}]);
+ request.messages.push(AiMessage {
+ role: "assistant".to_string(),
+ content: String::new(),
+ images: vec![],
+ tool_call_id: None,
+ tool_calls: vec![ToolCallRef {
+ id: "previous_call".to_string(),
+ name: "list_tables".to_string(),
+ arguments: serde_json::json!({"schema": "public"}),
+ provider_payload: Some(serde_json::json!({MINIMAX_REASONING_DETAILS_PAYLOAD_KEY: details})),
+ }],
+ });
+ request.messages.push(AiMessage {
+ role: "tool".to_string(),
+ content: "users".to_string(),
+ images: vec![],
+ tool_call_id: Some("previous_call".to_string()),
+ tool_calls: vec![],
+ });
+ let tools = [crate::agent_events::ToolDefinition {
+ name: "list_tables".into(),
+ description: "List tables".into(),
+ parameters: serde_json::json!({"type": "object", "properties": {"schema": {"type": "string"}}}),
+ read_only: true,
+ parallel_ok: true,
+ }];
let chunks = std::sync::Arc::new(std::sync::Mutex::new(Vec::new()));
let observed = chunks.clone();
let (calls, _) =
- stream_with_tools(&request.config, &request, "minimax-tool-test", &[], &Notify::new(), move |chunk| {
+ stream_with_tools(&request.config, &request, "minimax-tool-test", &tools, &Notify::new(), move |chunk| {
observed.lock().unwrap().push(chunk)
})
.await
@@ -8516,6 +8613,15 @@ mod tests {
assert!(captured.headers.starts_with("POST /v1/chat/completions "));
assert_eq!(captured.body["reasoning_split"], true);
assert_eq!(captured.body["max_completion_tokens"], 64);
+ assert_eq!(captured.body["model"], "MiniMax-M3.1-Flash");
+ assert_eq!(captured.body["reasoning_effort"], "high");
+ assert!(captured.body.get("thinking").is_none());
+ assert_eq!(captured.body["tools"][0]["function"]["name"], "list_tables");
+ assert_eq!(captured.body["messages"][1]["content"][1]["image_url"]["url"], "data:image/png;base64,aGVsbG8=");
+ assert_eq!(captured.body["messages"][2]["reasoning_details"], details);
+ assert_eq!(captured.body["messages"][2]["tool_calls"][0]["function"]["arguments"], r#"{"schema":"public"}"#);
+ assert_eq!(captured.body["messages"][3]["tool_call_id"], "previous_call");
+ assert_eq!(captured.body["messages"][3]["content"], "users");
}
#[test]
diff --git a/crates/dbx-ai-provider/src/ai_effort.rs b/crates/dbx-ai-provider/src/ai_effort.rs
index 38497ee995..d955aa1433 100644
--- a/crates/dbx-ai-provider/src/ai_effort.rs
+++ b/crates/dbx-ai-provider/src/ai_effort.rs
@@ -79,6 +79,13 @@ pub fn static_effort_capability(config: &AiConfig, model_id: &str) -> Option<AiE
AiProvider::Kimi => kimi_capability(&model, source),
AiProvider::Qwen => qwen_capability(&model, source),
AiProvider::Zhipu | AiProvider::Ollama => ollama_capability(&model, source),
+ AiProvider::MiniMax if model == "minimax-m3.1-flash" => {
+ let mut capability = enum_capability(&["low", "medium", "high", "xhigh", "max"], source);
+ if let AiEffortCapability::Enum { default, .. } = &mut capability {
+ *default = AiEffortSelection::Enum("max".to_string());
+ }
+ Some(capability)
+ }
AiProvider::MiniMax if matches_family(&model, "minimax-m3") => Some(boolean_capability(source)),
AiProvider::MiniMax => None,
AiProvider::AnthropicCompatible | AiProvider::OpenaiCompatible | AiProvider::Custom => {
@@ -288,7 +295,7 @@ pub fn apply_runtime_effort(body: &mut Value, config: &AiConfig) {
AiProvider::Kimi => apply_kimi_effort(object, &config.model, selection),
AiProvider::Qwen => apply_qwen_effort(object, selection),
AiProvider::Zhipu | AiProvider::Ollama => apply_openai_effort(object, &config.api_style, selection),
- AiProvider::MiniMax => apply_minimax_effort(object, selection),
+ AiProvider::MiniMax => apply_minimax_effort(object, &config.model, selection),
AiProvider::Openai | AiProvider::OpenaiCompatible => apply_openai_effort(object, &config.api_style, selection),
AiProvider::Custom => {
if config.api_style == AiApiStyle::AnthropicMessages {
@@ -343,7 +350,13 @@ fn apply_kimi_effort(object: &mut Map<String, Value>, model_id: &str, selection:
}
}
-fn apply_minimax_effort(object: &mut Map<String, Value>, selection: &AiEffortSelection) {
+fn apply_minimax_effort(object: &mut Map<String, Value>, model_id: &str, selection: &AiEffortSelection) {
+ if normalized_model_id(model_id) == "minimax-m3.1-flash" {
+ if let AiEffortSelection::Enum(value) = selection {
+ object.insert("reasoning_effort".to_string(), Value::String(value.clone()));
+ }
+ return;
+ }
let thinking_type = match selection {
AiEffortSelection::Disabled | AiEffortSelection::Boolean(false) => "disabled",
AiEffortSelection::Boolean(true) => "adaptive",
@@ -514,6 +527,33 @@ mod tests {
}
}
+ #[test]
+ fn minimax_flash_exposes_only_supported_efforts() {
+ let mut config = config(AiProvider::MiniMax, "MiniMax-M3.1-Flash");
+ let AiEffortCapability::Enum { options, default, .. } =
+ static_effort_capability(&config, &config.model).unwrap()
+ else {
+ panic!("expected Flash effort levels");
+ };
+ assert_eq!(
+ options.iter().map(|option| option.id.as_str()).collect::<Vec<_>>(),
+ ["low", "medium", "high", "xhigh", "max"]
+ );
+ assert_eq!(default, AiEffortSelection::Enum("max".to_string()));
+ for option in options {
+ config.runtime_effort = Some(option.selection);
+ assert!(validate_runtime_effort(&config).is_ok());
+ }
+ for invalid in [
+ AiEffortSelection::Disabled,
+ AiEffortSelection::Boolean(false),
+ AiEffortSelection::Enum("none".to_string()),
+ ] {
+ config.runtime_effort = Some(invalid);
+ assert!(validate_runtime_effort(&config).is_err());
+ }
+ }
+
#[test]
fn minimax_m3_uses_boolean_adaptive_thinking() {
let mut config = config(AiProvider::MiniMax, "MiniMax-M3");
diff --git a/crates/dbx-ai-provider/src/ai_model_filter.rs b/crates/dbx-ai-provider/src/ai_model_filter.rs
index 60aeb2ac03..0ddebfb372 100644
--- a/crates/dbx-ai-provider/src/ai_model_filter.rs
+++ b/crates/dbx-ai-provider/src/ai_model_filter.rs
@@ -110,6 +110,11 @@ pub(crate) fn model_is_assistant_compatible(provider: &AiProvider, model_id: &st
pub(crate) fn retain_known_assistant_models(provider: &AiProvider, models: &mut Vec<AiModelInfo>) {
models.retain(|model| model_is_assistant_compatible(provider, &model.id));
+ if matches!(provider, AiProvider::MiniMax) {
+ // Only constrain discovery; saved and manually entered model IDs remain valid.
+ models.retain(|model| matches!(model.id.as_str(), "MiniMax-M3.1-Flash" | "MiniMax-M3"));
+ models.sort_by_key(|model| if model.id == "MiniMax-M3.1-Flash" { 0 } else { 1 });
+ }
}
pub(crate) fn gemini_item_is_assistant_compatible(item: &Value) -> bool {
diff --git a/packages/app-tests/settingsStore.test.ts b/packages/app-tests/settingsStore.test.ts
index 86cc9f0728..6f3181cf2a 100644
--- a/packages/app-tests/settingsStore.test.ts
+++ b/packages/app-tests/settingsStore.test.ts
@@ -1038,7 +1038,7 @@ test("AI provider presets include common hosted and local providers", () => {
assert.equal(AI_PROVIDER_PRESETS.deepseek.endpoint, "https://api.deepseek.com/v1");
assert.equal(AI_PROVIDER_PRESETS.deepseek.model, "deepseek-v4-flash");
assert.equal(AI_PROVIDER_PRESETS.minimax.endpoint, "https://api.minimax.io/v1");
- assert.equal(AI_PROVIDER_PRESETS.minimax.model, "MiniMax-M3");
+ assert.equal(AI_PROVIDER_PRESETS.minimax.model, "MiniMax-M3.1-Flash");
assert.equal(AI_PROVIDER_PRESETS.minimax.authMethod, "bearer");
assert.equal(AI_PROVIDER_PRESETS.minimax.requiresApiKey, true);
assert.equal(AI_PROVIDER_PRESETS.minimax.iconSlug, "minimax");