Skip to content

fix(llm): 修复 MiniMax thinking 关闭无效#604

Merged
H-Chris233 merged 1 commit into
Open-Less:betafrom
dttxorg:fix/issue-minimax-thinking-control
Jun 6, 2026
Merged

fix(llm): 修复 MiniMax thinking 关闭无效#604
H-Chris233 merged 1 commit into
Open-Less:betafrom
dttxorg:fix/issue-minimax-thinking-control

Conversation

@dttxorg
Copy link
Copy Markdown

@dttxorg dttxorg commented Jun 6, 2026

User description

Bug 复现

在 OpenLess 设置里把「思考」关掉后,接入 MiniMax (M3) 润色时仍持续输出 <think>…</think> 块,UI 关闭形同虚设。

根因

polish.rs::openai_compatible_thinking_control 只在 5 个 provider_id 上分派 thinking 控制:

"deepseek"        => DeepSeekThinking
"openrouterFree"  => OpenRouterReasoning
"alibabaCoding"   => EnableThinking
"openai" | "codingPlanX" => ReasoningEffort
_ => None   // ← MiniMax 落这里

MiniMax 不在列表里,走到 None => {} 分支,后端根本不下发 thinking 字段。M3 默认开启 thinking,服务端继续输出 内容块。

修复

  1. 新增 ThinkingControl::MiniMaxThinking 变体 —— schema 与 DeepSeek 相同(body.thinking.type),但取值字面量与 minimaxi 官方一致:

    • 关闭 → "disabled"
    • 开启 → "adaptive" (DeepSeek 用的是 "enabled",MiniMax 文档不支持,发 "enabled" M3 会 400)
  2. openai_compatible_thinking_control 增加 "minimax" provider_id 识别

  3. 新增 openai_compatible_thinking_control_for_base_url 兜底识别 —— host 含 minimax 关键字时命中,让用户用「自定义」preset 接入 MiniMax 也能正确下发 thinking 控制参数。同样的兜底也覆盖了 deepseek / openrouter / dashscope。

  4. 前端 LLM_PRESETS 新增 minimax preset —— baseUrl https://api.minimaxi.com/v1,model 占位 MiniMax-M3

  5. 5 个 i18n 文件 (en/zh-CN/zh-TW/ja/ko) 加 minimax 文案 key

  6. 4 个 Rust 单元测试 覆盖:preset 命中、adaptive 字面量、custom base_url 兜底、host 提取对尾斜杠与路径的容错。

兼容性

  • 已有 5 个 provider (deepseek / openai / codingPlanX / alibabaCoding / openrouterFree) 行为完全不变。
  • 新增 case 仅在 provider_id 命中 minimax 或 base_url 主机名含 minimax 时启用。
  • M2.x 系列不支持关闭 thinking(后端下发 disabled 服务端仍保持开启),与 OpenLess「渠道级按官方参数声明下发」策略一致,不维护单模型白名单。

参考文档

测试

$ cargo test --lib polish::
test result: ok. 41 passed; 0 failed; 0 ignored; 0 measured; 341 filtered out

新增 4 个 case:

  • openai_chat_body_disables_minimax_thinking_by_preset — provider_id 命中,关闭下发 disabled
  • openai_chat_body_enables_minimax_thinking_with_adaptive_literal — 开启下发 adaptive(不是 enabled)
  • openai_chat_body_falls_back_to_base_url_for_custom_minimax_endpointcustom preset + https://api.minimaxi.com/v1 也能命中
  • openai_chat_body_base_url_fallback_respects_trailing_slash_and_path — host 提取对 /v1/v1/、裸域名都正确

PR Type

Bug fix


Description

  • Fix MiniMax thinking control not being applied when disabled in UI

  • Add MiniMaxThinking variant with correct "disabled"/"adaptive" values

  • Implement base_url fallback for custom endpoint

  • Add frontend preset and i18n for MiniMax


Diagram Walkthrough

flowchart LR
  A["User disables thinking in settings"] --> B{"provider_id?"}
  B -- "minimax" --> C["MiniMaxThinking return 'disabled'"]
  B -- "custom" --> D["base_url fallback detects 'minimax'"]
  D --> C
  C --> E["body.thinking.type = 'disabled'"]
  E --> F["MiniMax API stops thinking"]
Loading

File Walkthrough

Relevant files
Bug fix
1 files
polish.rs
Add MiniMax thinking control variant and base_url fallback
+136/-1 
Documentation
5 files
en.ts
Add MiniMax i18n label                                                                     
+1/-0     
ja.ts
Add MiniMax i18n label                                                                     
+1/-0     
ko.ts
Add MiniMax i18n label                                                                     
+1/-0     
zh-CN.ts
Add MiniMax i18n label                                                                     
+1/-0     
zh-TW.ts
Add MiniMax i18n label                                                                     
+1/-0     
Enhancement
1 files
ProvidersSection.tsx
Add MiniMax preset to LLM_PRESETS                                               
+12/-0   

**Bug 复现**
用户在 OpenLess 设置里把「思考」关闭后,MiniMax(M3)润色仍输出 thinking 内容块,UI 关闭形同虚设。

**根因**
polish.rs::openai_compatible_thinking_control 只在 5 个 provider_id
(deepseek / openrouterFree / alibabaCoding / openai / codingPlanX) 上分派
thinking 控制参数;MiniMax 不在列表里,走默认 _ => None 分支,后端根本
不下发 thinking 字段。M3 默认开启 thinking,所以 UI 关闭后服务端仍
输出 <think>…</think> 块。

**修复**
- 新增 ThinkingControl::MiniMaxThinking 变体:关闭下发
  `thinking.type = "disabled"`、开启下发 `thinking.type = "adaptive"`,
  与 minimaxi 官方 Chat Completions schema 完全对齐。
- openai_compatible_thinking_control 增加 "minimax" provider_id 识别。
- 同时增加 base_url 兜底识别(host 含 "minimax" 关键字即命中),让用户
  用「自定义」preset 接入 MiniMax 时也能正确下发 thinking 控制参数。
- 前端 ProvidersSection.tsx::LLM_PRESETS 新增 minimax preset
  (baseUrl=https://api.minimaxi.com/v1, model=MiniMax-M3)。
- 5 个 i18n 文件 (en/zh-CN/zh-TW/ja/ko) 加 minimax 文案。
- 加 4 个 Rust 单元测试覆盖:preset 命中、adaptive 字面量、custom
  base_url 兜底、host 提取对尾斜杠与路径的容错。

**兼容性**
- 旧 provider (deepseek/openai/codingPlanX/alibabaCoding/openrouterFree)
  行为完全不变,新增 case 仅在 provider_id 命中 minimax 或 base_url
  含 minimaxi 主机时启用。
- 行为对齐 minimaxi 官方文档:
  https://platform.minimaxi.com/docs/api-reference/text-chat-openai#thinking-控制

**测试**
cargo test --lib polish:: 41 passed, 0 failed
新增 4 个 case:
- openai_chat_body_disables_minimax_thinking_by_preset
- openai_chat_body_enables_minimax_thinking_with_adaptive_literal
- openai_chat_body_falls_back_to_base_url_for_custom_minimax_endpoint
- openai_chat_body_base_url_fallback_respects_trailing_slash_and_path
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 6, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233 H-Chris233 merged commit 85ca2ac into Open-Less:beta Jun 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants