Upstream/feature/add xiaomi mimo#81
Conversation
- New MimoHandler with reasoning_content passthrough for multi-turn tool calling - Custom message conversion preserving MiMo's interleaved thinking chain - Strip OpenAI-specific extensions (strict, additionalProperties) from tool schemas - Models: mimo-v2.5-pro, mimo-v2.5, mimo-v2-flash with official pricing - UI settings with 4 base URL options (3 Token Plan regions + Pay-as-you-go) - Full wiring: types, schema, model picker, i18n, provider config
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR integrates Xiaomi MiMo as a new LLM provider by adding model metadata, extending provider schemas, implementing an OpenAI-compatible handler that adapts MiMo's requirements, and providing frontend settings UI. The change includes wiring message conversion to be model-aware and updating existing OpenAI-compatible providers to pass model context. ChangesXiaomi MiMo Provider Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
dev/null/post-merge (1)
1-4:⚠️ Potential issue | 🟠 Major | ⚡ Quick winConfusing directory name:
dev/null/resembles the Unix special file.The path
dev/null/is easily confused with the Unix special file/dev/null. Consider renaming the directory to something clearer likegit-hooks/,hooks-template/, orscripts/git-lfs-hooks/.🤖 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 `@dev/null/post-merge` around lines 1 - 4, The repository includes a hook script named post-merge stored under a confusing directory named dev/null; rename that directory to a clear name like git-hooks or hooks-template and move the post-merge script there, then update any configuration or references that point to dev/null (e.g., custom core.hookspath settings, CI config, or documentation) so they point to the new directory; ensure the script file retains executable permissions and that the script content (the post-merge hook invoking git lfs) remains unchanged and continues to work under the new location.dev/null/post-commit (1)
1-4:⚠️ Potential issue | 🟠 Major | ⚡ Quick winConfusing directory name:
dev/null/resembles the Unix special file.The path
dev/null/is easily confused with the Unix special file/dev/null. Consider renaming the directory to something clearer likegit-hooks/,hooks-template/, orscripts/git-lfs-hooks/.🤖 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 `@dev/null/post-commit` around lines 1 - 4, The directory name "dev/null" is confusing because it resembles the Unix special file; rename the directory to a clearer name (e.g., "git-hooks", "hooks-template", or "scripts/git-lfs-hooks"), move the "post-commit" hook into that new directory, update any references to "dev/null/post-commit" (search the repo, CI configs, and documentation) and ensure the file keeps its executable bit and the repository's core.hookspath (if set) points to the new directory so git-lfs post-commit continues to run.dev/null/post-checkout (1)
1-4:⚠️ Potential issue | 🟠 Major | ⚡ Quick winConfusing directory name:
dev/null/resembles the Unix special file.The path
dev/null/is easily confused with the Unix special file/dev/null. If these are hook templates or source files to be installed elsewhere, consider renaming the directory to something clearer likegit-hooks/,hooks-template/, orscripts/git-lfs-hooks/.🤖 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 `@dev/null/post-checkout` around lines 1 - 4, The directory name "dev/null" is confusing and should be renamed; move or rename the hook file "post-checkout" out of the misleading dev/null folder to a clearer directory such as "git-hooks" or "hooks-template" and update any references/installation scripts that point to "dev/null/post-checkout" so they point to the new location, ensuring the shebang and the "git lfs post-checkout \"$@\"" invocation remain unchanged in the moved "post-checkout" file.dev/null/pre-push (1)
1-4:⚠️ Potential issue | 🟠 Major | ⚡ Quick winConfusing directory name:
dev/null/resembles the Unix special file.The path
dev/null/is easily confused with the Unix special file/dev/null. Consider renaming the directory to something clearer likegit-hooks/,hooks-template/, orscripts/git-lfs-hooks/.🤖 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 `@dev/null/pre-push` around lines 1 - 4, The directory name "dev/null/" is confusing; rename the directory containing the pre-push hook (currently shown as dev/null/pre-push) to a clear, descriptive name such as git-hooks, hooks-template, or scripts/git-lfs-hooks, update any references to that path (e.g., where you set core.hookspath or any scripts/installers that copy or reference the pre-push file), keep the pre-push file contents and executable bit unchanged, and verify hooks still run (or update core.hookspath) after the rename.
🧹 Nitpick comments (4)
dev/null/post-merge (1)
2-2: 💤 Low valueVery long line impairs readability.
Line 2 exceeds 280 characters. Consider breaking the error message and logic into multiple lines for maintainability.
♻️ Suggested refactor
-command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-merge' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; } +if ! command -v git-lfs >/dev/null 2>&1; then + printf >&2 "\n%s\n\n" \ + "This repository is configured for Git LFS but 'git-lfs' was not found on your path. " \ + "If you no longer wish to use Git LFS, remove this hook by deleting the 'post-merge' " \ + "file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')." + exit 2 +fi🤖 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 `@dev/null/post-merge` at line 2, The single long printf in the post-merge hook makes the line >280 chars hard to read; refactor by extracting the multi-line error text into a readable variable (e.g., MESSAGE) or by splitting the printf into multiple shorter printf/echo calls and then call exit 2; locate the hook logic around the "command -v git-lfs" check in the post-merge script and replace the single huge printf string with a multi-line message variable or multiple print statements for readability and maintainability.dev/null/pre-push (1)
2-2: 💤 Low valueVery long line impairs readability.
Line 2 exceeds 280 characters. Consider breaking the error message and logic into multiple lines for maintainability.
♻️ Suggested refactor
-command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; } +if ! command -v git-lfs >/dev/null 2>&1; then + printf >&2 "\n%s\n\n" \ + "This repository is configured for Git LFS but 'git-lfs' was not found on your path. " \ + "If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' " \ + "file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')." + exit 2 +fi🤖 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 `@dev/null/pre-push` at line 2, The pre-push hook has a single very long printf call that exceeds 280 chars and hurts readability; refactor the command -v git-lfs ... || { printf >&2 "..."; exit 2; } by splitting the error message into multiple concatenated printf calls or using a multi-line here-doc so the message text is wrapped across lines, keep the same stderr redirection (printf >&2) and the exit 2 behavior, and preserve the existing check invocation (command -v git-lfs) so the logic in the pre-push hook remains identical but more maintainable.dev/null/post-checkout (1)
2-2: 💤 Low valueVery long line impairs readability.
Line 2 exceeds 280 characters. Consider breaking the error message and logic into multiple lines for maintainability.
♻️ Suggested refactor
-command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-checkout' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; } +if ! command -v git-lfs >/dev/null 2>&1; then + printf >&2 "\n%s\n\n" \ + "This repository is configured for Git LFS but 'git-lfs' was not found on your path. " \ + "If you no longer wish to use Git LFS, remove this hook by deleting the 'post-checkout' " \ + "file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')." + exit 2 +fi🤖 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 `@dev/null/post-checkout` at line 2, The single long command in the post-checkout hook reduces readability; refactor the check and message by converting the one-liner into a clear if-statement that uses either multiple printf/echo lines or a here-document for the multi-line error message (replace the inline use of "command -v git-lfs >/dev/null 2>&1 || { ... }" with a multi-line if ! command -v git-lfs >/dev/null 2>&1; then ... fi), and move the long message currently passed to printf into separate lines to keep line length under 280 characters while preserving the exact wording and the exit 2 behaviour.dev/null/post-commit (1)
2-2: 💤 Low valueVery long line impairs readability.
Line 2 exceeds 280 characters. Consider breaking the error message and logic into multiple lines for maintainability.
♻️ Suggested refactor
-command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; } +if ! command -v git-lfs >/dev/null 2>&1; then + printf >&2 "\n%s\n\n" \ + "This repository is configured for Git LFS but 'git-lfs' was not found on your path. " \ + "If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' " \ + "file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')." + exit 2 +fi🤖 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 `@dev/null/post-commit` at line 2, The long single-line hook check using "command -v git-lfs >/dev/null 2>&1 || { printf >&2 \"...\"; exit 2; }" should be split for readability: perform the check with "if ! command -v git-lfs >/dev/null 2>&1; then" then emit a multi-line error via a heredoc or multiple printf >&2 lines (preserving the original message text), and finish with "exit 2; fi"; update the block around "command -v git-lfs", "printf >&2" and "exit 2" accordingly so the same behavior remains but the message and logic are on separate lines.
🤖 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/api/providers/mimo.ts`:
- Around line 109-193: The loop over anthropicMessages currently only handles
assistant messages when msg.content is an array, so assistant turns with a
string content are dropped; update the branch around "if (msg.role ===
'assistant' && Array.isArray(msg.content))" to also handle "msg.role ===
'assistant' && typeof msg.content === 'string'" by creating an assistantMsg
object (same shape used later) with role: "assistant", content: msg.content, and
ensure we still set reasoning_content and tool_calls when present (or leave them
absent/empty), then push that assistantMsg into converted; reference the
existing loop, assistantMsg variable and converted array to locate where to add
the string-content handling.
In `@src/api/transform/openai-format.ts`:
- Around line 318-320: The MiMo model guard that prevents setting
reasoning_details for MiMo-bound requests is only applied in the assistant
message branch that treats content as a string; update the assistant
array-content branch (the code that sets (baseMessage as any).reasoning_details
when content is an array) to use the same guard: check options?.modelId against
/mimo/i and only assign reasoning_details when not MiMo (i.e., wrap the existing
assignment of (baseMessage as any).reasoning_details = mapped with the same
condition used earlier: mapped && !(options?.modelId &&
/mimo/i.test(options.modelId || "")). This ensures both assistant paths (string
and array content) respect the MiMo exclusion.
In `@webview-ui/src/components/settings/providers/Mimo.tsx`:
- Around line 36-52: Replace the incorrect Europe endpoint value in the Mimo.tsx
provider options: locate the VSCodeOption currently using
"https://token-plan-fra.xiaomimimo.com/v1" (inside the VSCodeDropdown bound to
apiConfiguration.mimoBaseUrl) and change its value to the official AMS region
"https://token-plan-ams.xiaomimimo.com/v1"; optionally update the visible label
(e.g., "Token Plan - Europe" → "Token Plan - Europe (AMS)") to reflect the
region.
---
Outside diff comments:
In `@dev/null/post-checkout`:
- Around line 1-4: The directory name "dev/null" is confusing and should be
renamed; move or rename the hook file "post-checkout" out of the misleading
dev/null folder to a clearer directory such as "git-hooks" or "hooks-template"
and update any references/installation scripts that point to
"dev/null/post-checkout" so they point to the new location, ensuring the shebang
and the "git lfs post-checkout \"$@\"" invocation remain unchanged in the moved
"post-checkout" file.
In `@dev/null/post-commit`:
- Around line 1-4: The directory name "dev/null" is confusing because it
resembles the Unix special file; rename the directory to a clearer name (e.g.,
"git-hooks", "hooks-template", or "scripts/git-lfs-hooks"), move the
"post-commit" hook into that new directory, update any references to
"dev/null/post-commit" (search the repo, CI configs, and documentation) and
ensure the file keeps its executable bit and the repository's core.hookspath (if
set) points to the new directory so git-lfs post-commit continues to run.
In `@dev/null/post-merge`:
- Around line 1-4: The repository includes a hook script named post-merge stored
under a confusing directory named dev/null; rename that directory to a clear
name like git-hooks or hooks-template and move the post-merge script there, then
update any configuration or references that point to dev/null (e.g., custom
core.hookspath settings, CI config, or documentation) so they point to the new
directory; ensure the script file retains executable permissions and that the
script content (the post-merge hook invoking git lfs) remains unchanged and
continues to work under the new location.
In `@dev/null/pre-push`:
- Around line 1-4: The directory name "dev/null/" is confusing; rename the
directory containing the pre-push hook (currently shown as dev/null/pre-push) to
a clear, descriptive name such as git-hooks, hooks-template, or
scripts/git-lfs-hooks, update any references to that path (e.g., where you set
core.hookspath or any scripts/installers that copy or reference the pre-push
file), keep the pre-push file contents and executable bit unchanged, and verify
hooks still run (or update core.hookspath) after the rename.
---
Nitpick comments:
In `@dev/null/post-checkout`:
- Line 2: The single long command in the post-checkout hook reduces readability;
refactor the check and message by converting the one-liner into a clear
if-statement that uses either multiple printf/echo lines or a here-document for
the multi-line error message (replace the inline use of "command -v git-lfs
>/dev/null 2>&1 || { ... }" with a multi-line if ! command -v git-lfs >/dev/null
2>&1; then ... fi), and move the long message currently passed to printf into
separate lines to keep line length under 280 characters while preserving the
exact wording and the exit 2 behaviour.
In `@dev/null/post-commit`:
- Line 2: The long single-line hook check using "command -v git-lfs >/dev/null
2>&1 || { printf >&2 \"...\"; exit 2; }" should be split for readability:
perform the check with "if ! command -v git-lfs >/dev/null 2>&1; then" then emit
a multi-line error via a heredoc or multiple printf >&2 lines (preserving the
original message text), and finish with "exit 2; fi"; update the block around
"command -v git-lfs", "printf >&2" and "exit 2" accordingly so the same behavior
remains but the message and logic are on separate lines.
In `@dev/null/post-merge`:
- Line 2: The single long printf in the post-merge hook makes the line >280
chars hard to read; refactor by extracting the multi-line error text into a
readable variable (e.g., MESSAGE) or by splitting the printf into multiple
shorter printf/echo calls and then call exit 2; locate the hook logic around the
"command -v git-lfs" check in the post-merge script and replace the single huge
printf string with a multi-line message variable or multiple print statements
for readability and maintainability.
In `@dev/null/pre-push`:
- Line 2: The pre-push hook has a single very long printf call that exceeds 280
chars and hurts readability; refactor the command -v git-lfs ... || { printf >&2
"..."; exit 2; } by splitting the error message into multiple concatenated
printf calls or using a multi-line here-doc so the message text is wrapped
across lines, keep the same stderr redirection (printf >&2) and the exit 2
behavior, and preserve the existing check invocation (command -v git-lfs) so the
logic in the pre-push hook remains identical but more maintainable.
🪄 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 Plus
Run ID: 28fc3ca6-fd78-47f5-aedc-3adc9597e1d8
📒 Files selected for processing (26)
dev/null/post-checkoutdev/null/post-commitdev/null/post-mergedev/null/pre-pushpackages/types/src/provider-settings.tspackages/types/src/providers/index.tspackages/types/src/providers/mimo.tssrc/api/index.tssrc/api/providers/base-openai-compatible-provider.tssrc/api/providers/index.tssrc/api/providers/lite-llm.tssrc/api/providers/lm-studio.tssrc/api/providers/mimo.tssrc/api/providers/openai.tssrc/api/providers/openrouter.tssrc/api/providers/qwen-code.tssrc/api/providers/requesty.tssrc/api/providers/roo.tssrc/api/transform/openai-format.tswebview-ui/src/components/settings/ApiOptions.tsxwebview-ui/src/components/settings/constants.tswebview-ui/src/components/settings/providers/Mimo.tsxwebview-ui/src/components/settings/providers/index.tswebview-ui/src/components/settings/utils/providerModelConfig.tswebview-ui/src/components/ui/hooks/useSelectedModel.tswebview-ui/src/i18n/locales/en/settings.json
Update Mimo provider config and UI to use the token-plan-ams endpoint instead of the old FRA host. Allow Mimo assistant messages with string content to include and preserve a reasoning_content field when present. Also avoid attaching mapped reasoning_details when converting messages for Mimo models (skip mapping if modelId matches /mimo/i) to preserve the provider's original shape. Types, API handler, transform logic, and the settings UI were updated to keep Mimo-specific reasoning data intact and align the endpoint selection.
Related GitHub Issue
Closes: #80
Description
Add Xiaomi MiMo as a first-class API provider with full multi-turn tool calling support.
MiMo's API requires
reasoning_contentto be echoed back in assistant messages during tool calling conversations. Without this, the API returns 400 "Param Incorrect". The existing message conversion (convertToOpenAiMessages) was dropping reasoning content blocks entirely, and the base tool schema conversion was adding OpenAI-specific extensions (strict: true,additionalProperties: false) that MiMo's proxy rejects.Key implementation details:
src/api/providers/mimo.ts): ExtendsOpenAiHandlerwith customconvertMessagesForMiMo()that extractstype: "reasoning"content blocks from Anthropic format and maps them toreasoning_contentin OpenAI assistant messages. OverridesconvertToolsForOpenAI()to stripstrictandadditionalPropertiesfrom tool schemas. Sendsthinking: { type: "enabled" }viaextra_body.packages/types/src/providers/mimo.ts): mimo-v2.5-pro, mimo-v2.5, mimo-v2-flash with official pricing, correct context windows (1M/1M/256K), and max output tokens (131K/131K/65K).webview-ui/src/components/settings/providers/Mimo.tsx): Base URL dropdown with 4 options (3 Token Plan regions + Pay-as-you-go), API key input.openrouter.tswhereconvertToOpenAiMessageswas called with 3 arguments instead of 2.Previously this provider could be used via the "OpenAI Compatible" option with the base URL
https://token-plan-sgp.xiaomimimo.com/v1, but it broke because MiMo's proxy rejects OpenAI-specific extensions that Roo Code sends by default. This PR adds MiMo as a dedicated provider that handles all these compatibility issues.Test Procedure
pnpm build(web-evals failure is pre-existing and unrelated)tsc --noEmitfor types, src, and webview-ui packages with zero new errorsPre-Submission Checklist
Screenshots / Videos
N/A - Provider settings UI follows existing patterns (Moonshot, MiniMax). The MiMo settings tab shows a base URL dropdown with 4 regions and an API key input field.
Documentation Updates
Additional Notes
This provider is critical for users in regions where access to Western AI providers is limited. MiMo V2.5 Pro offers competitive performance with 1M context window at $1.00/M input pricing, making it a cost-effective alternative.
Get in Touch
gabrielsosa_
Summary by CodeRabbit
New Features
Refactor