Skip to content

fix: disable thinking chain for Xiaomi MiMo models#143

Merged
AmintaCCCP merged 1 commit into
mainfrom
fix/mimo-thinking-chain
May 13, 2026
Merged

fix: disable thinking chain for Xiaomi MiMo models#143
AmintaCCCP merged 1 commit into
mainfrom
fix/mimo-thinking-chain

Conversation

@AmintaCCCP
Copy link
Copy Markdown
Owner

@AmintaCCCP AmintaCCCP commented May 13, 2026

问题描述

Fixes #127

小米 MiMo 模型支持思维链(Thinking Mode)功能,当启用时,API 响应会返回 reasoning_content 字段(包含推理过程)和 content 字段(最终结果)。

当前代码在解析响应时,如果 content 为空,会返回 reasoning_content,导致用户看到的是模型的推理过程而不是最终分析结果。

修复方案

在请求小米 MiMo API 时,明确传 thinking: { type: 'disabled' } 禁用思维链功能。

改动内容

  1. 添加 isMiMoModel() 方法:检测模型名称是否包含 'mimo'
  2. 修改请求体构建逻辑:如果是小米 MiMo 模型,添加 thinking: { type: 'disabled' } 参数

影响范围

  • 小米 MiMo 模型:禁用思维链,返回标准格式响应
  • 其他模型:不受影响(DeepSeek、OpenAI、Claude、Gemini 等)
  • 现有功能:仓库分析、连接测试等功能保持不变

测试建议

  1. 使用小米 MiMo 模型进行仓库分析,确认不再显示思维链内容
  2. 使用其他模型(如 GPT-4、Claude)确认功能正常
  3. 测试连接功能是否正常

相关文档

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility with MiMo model variants by adjusting API request configuration.

Review Change Stack

- 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)
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

📝 Walkthrough

Walkthrough

The PR adds MiMo-model detection logic to the OpenAI request construction flow in src/services/aiService.ts. A new helper function identifies models containing "mimo" (case-insensitive), and when detected, the OpenAI-style request payload is conditionally updated to include thinking: { type: 'disabled' } alongside existing DeepSeek and reasoning-related conditions.

Changes

MiMo Model Detection

Layer / File(s) Summary
MiMo detection and OpenAI payload alteration
src/services/aiService.ts
New isMiMoModel() helper detects models with "mimo" in the name and is called during OpenAI request construction to conditionally add thinking: { type: 'disabled' } to the request body.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • AmintaCCCP/GithubStarsManager#75: Both PRs modify src/services/aiService.ts by adding model-name detection helpers and conditionally changing the OpenAI-style request payload fields based on the selected model (MiMo vs deepseek-reasoner).

Poem

🐰 A model named MiMo, so clever and keen,
Now thinks just a little—or not in between!
The thinking disabled, the payload takes flight,
Through OpenAI's channels, a MiMo delight! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: disabling thinking chain functionality for Xiaomi MiMo models, which is the primary objective of this pull request.
Linked Issues check ✅ Passed The PR adds MiMo model detection and disables thinking chain by including thinking: { type: 'disabled' } in requests, directly addressing the issue #127 requirement to prevent reasoning_content from being displayed to users.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to MiMo model detection and thinking chain disabling; no unrelated modifications to other features, models, or functionality are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mimo-thinking-chain

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06a8cd81-7a84-4f48-ba13-d49b307afa96

📥 Commits

Reviewing files that changed from the base of the PR and between c292c11 and 82e4697.

📒 Files selected for processing (1)
  • src/services/aiService.ts

Comment thread src/services/aiService.ts
temperature: options.temperature,
max_output_tokens: options.maxTokens,
...(reasoning ? { reasoning } : {}),
...(isMiMoModel ? { thinking: { type: 'disabled' } } : {}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 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:


🏁 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 -C2

Repository: 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.

Comment thread src/services/aiService.ts
temperature: options.temperature,
max_output_tokens: options.maxTokens,
...(reasoning ? { reasoning } : {}),
...(isMiMoModel ? { thinking: { type: 'disabled' } } : {}),
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢审计,但这个结论是错误的。

官方文档明确支持 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: 默认 disabled
    • mimo-v2.5-pro, mimo-v2.5 等: 默认 enabled

为什么需要显式禁用?

对于默认 enabled 的模型(如 mimo-v2.5-pro),如果不显式传 thinking: { type: "disabled" },模型会返回 reasoning_content 字段,这正是 issue #127 报告的问题。

结论

当前代码是正确的,不需要修改。CodeRabbit 搜索的文档不完整,没有找到 disabled 选项的说明。

@AmintaCCCP AmintaCCCP merged commit 3a94c11 into main May 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

仓库分析功能异常

1 participant