fix: disable thinking chain for Xiaomi MiMo models#143
Conversation
- Add isMiMoModel() method to detect Xiaomi MiMo models
- Add thinking: { type: 'disabled' } to request body for MiMo models
- Fixes issue #127 where reasoning_content was displayed instead of final result
- Does not affect other models (DeepSeek, OpenAI, Claude, Gemini)
📝 WalkthroughWalkthroughThe PR adds MiMo-model detection logic to the OpenAI request construction flow in ChangesMiMo Model Detection
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/services/aiService.ts`:
- Line 113: The code currently injects thinking: { type: 'disabled' } for MiMo
models (see isMiMoModel usage in src/services/aiService.ts), which is not
supported; remove the disabled branch so the thinking field is omitted by
default and instead only set thinking: { type: 'enabled' } when you explicitly
want reasoning on. Concretely, update the object construction around the
isMiMoModel conditional (the spread currently producing thinking: { type:
'disabled' }) to either remove that spread entirely or change the logic to add
thinking: { type: 'enabled' } only when a separate "enableThinking" flag is
true.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| temperature: options.temperature, | ||
| max_output_tokens: options.maxTokens, | ||
| ...(reasoning ? { reasoning } : {}), | ||
| ...(isMiMoModel ? { thinking: { type: 'disabled' } } : {}), |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Xiaomi MiMo API thinking parameter format and valid values
💡 Result:
The Xiaomi MiMo API (OpenAI-compatible /v1/chat/completions endpoint) supports a "thinking" parameter to enable the model's reasoning mode, which outputs reasoning_content in responses alongside content or tool_calls [1][2]. Parameter formats and valid values from sources: 1. Object format (Xiaomi API docs): thinking: { type: "enabled" } [1] 2. Boolean flag in chat_template_kwargs (local/self-hosted MiMo-V2-Flash): "chat_template_kwargs": { "enable_thinking": true } [2] 3. Boolean in extra_body (API wrappers): extra_body={"enable_thinking": True} [3] When enabled, responses include reasoning_content (persist it in messages for multi-turn consistency, especially with tools) [2]. Different providers (e.g., api.xiaomimimo.com, self-hosted, OpenRouter) vary slightly in param location but use true/enabled to activate [1][2][4][3]. No explicit "disabled" values documented beyond omitting the param.
Citations:
- 1: http://mimo-v2.org/
- 2: https://github.com/XiaomiMiMo/MiMo-V2-Flash/blob/main/README.md
- 3: http://mimo-v2-flash.org/
- 4: https://openrouter.ai/xiaomi/mimo-v2-flash-20251210/api
🏁 Script executed:
#!/bin/bash
# Description: Search for MiMo-related configuration and API type usage
echo "=== Checking API type configurations ==="
rg -n "apiType.*openai" --type=ts --type=json -C3
echo -e "\n=== Checking for MiMo-related comments or documentation ==="
rg -n -i "mimo|xiaomi" --type=ts --type=md -C2Repository: AmintaCCCP/GithubStarsManager
Length of output: 15219
Remove the undocumented thinking: { type: 'disabled' } parameter — it's not supported by Xiaomi MiMo API.
The official Xiaomi MiMo API documentation only documents thinking: { type: "enabled" } to activate reasoning mode. The "disabled" value is not part of the API specification. The correct approach to disable thinking is to omit the parameter entirely, which the code already does when isMiMoModel is false.
Either remove lines 113 and 121 or conditionally add thinking: { type: "enabled" } only when thinking should be enabled.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/services/aiService.ts` at line 113, The code currently injects thinking:
{ type: 'disabled' } for MiMo models (see isMiMoModel usage in
src/services/aiService.ts), which is not supported; remove the disabled branch
so the thinking field is omitted by default and instead only set thinking: {
type: 'enabled' } when you explicitly want reasoning on. Concretely, update the
object construction around the isMiMoModel conditional (the spread currently
producing thinking: { type: 'disabled' }) to either remove that spread entirely
or change the logic to add thinking: { type: 'enabled' } only when a separate
"enableThinking" flag is true.
| temperature: options.temperature, | ||
| max_output_tokens: options.maxTokens, | ||
| ...(reasoning ? { reasoning } : {}), | ||
| ...(isMiMoModel ? { thinking: { type: 'disabled' } } : {}), |
There was a problem hiding this comment.
感谢审计,但这个结论是错误的。
官方文档明确支持 thinking: { type: "disabled" }
根据小米 MiMo API 官方文档(https://platform.xiaomimimo.com/static/docs/api/chat/openai-api.md),`thinking` 参数的 type 字段支持两个值:
"type": "string",
"description": "Whether to enable the chain of thought.
- mimo-v2-flash: default disabled
- mimo-v2.5-pro, mimo-v2.5, mimo-v2-pro, mimo-v2-omni: default enabled
Available options: enabled, disabled"
关键点:
- ✅
thinking: { type: "disabled" }是官方支持的参数值 - ✅
thinking: { type: "enabled" }也是官方支持的参数值 ⚠️ 不同模型默认值不同:mimo-v2-flash: 默认 disabledmimo-v2.5-pro,mimo-v2.5等: 默认 enabled
为什么需要显式禁用?
对于默认 enabled 的模型(如 mimo-v2.5-pro),如果不显式传 thinking: { type: "disabled" },模型会返回 reasoning_content 字段,这正是 issue #127 报告的问题。
结论
当前代码是正确的,不需要修改。CodeRabbit 搜索的文档不完整,没有找到 disabled 选项的说明。
问题描述
Fixes #127
小米 MiMo 模型支持思维链(Thinking Mode)功能,当启用时,API 响应会返回
reasoning_content字段(包含推理过程)和content字段(最终结果)。当前代码在解析响应时,如果
content为空,会返回reasoning_content,导致用户看到的是模型的推理过程而不是最终分析结果。修复方案
在请求小米 MiMo API 时,明确传
thinking: { type: 'disabled' }禁用思维链功能。改动内容
isMiMoModel()方法:检测模型名称是否包含 'mimo'thinking: { type: 'disabled' }参数影响范围
测试建议
相关文档
Summary by CodeRabbit