feat: add Xiaomi MiMo Anthropic-compatible endpoint support for thinking mode - #24887
Closed
comeonzhj wants to merge 1 commit into
Closed
feat: add Xiaomi MiMo Anthropic-compatible endpoint support for thinking mode#24887comeonzhj wants to merge 1 commit into
comeonzhj wants to merge 1 commit into
Conversation
…ing mode
Add support for Xiaomi MiMo's /anthropic endpoint which, like Kimi and
DeepSeek, requires unsigned thinking blocks to be preserved when thinking
mode is enabled. Without this fix, the API returns HTTP 400:
The reasoning_content in the thinking mode must be passed back
to the API.
Changes:
- Add _is_xiaomi_anthropic_endpoint() detection function
- Add Xiaomi endpoint to _preserve_unsigned_thinking condition
- Update comment to reference Xiaomi alongside Kimi and DeepSeek
Closes NousResearch#24884
Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
This was referenced May 14, 2026
teknium1
reviewed
Jul 13, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for identifying the Xiaomi replay contract. The underlying issue is still present on current main: agent/anthropic_adapter.py:2275-2278 preserves unsigned replay thinking only for Kimi and DeepSeek, while the third-party branch at agent/anthropic_adapter.py:2302-2309 strips Xiaomi's blocks.
Problems
agent/anthropic_adapter.py:489uses a raw"xiaomimimo.com" in normalizedmatch. Please use the existing hostname-aware helper atutils.py:528-546; it rejects path and hostname-suffix collisions.- Commit
01e053e84454changes onlyagent/anthropic_adapter.py; add a Xiaomi regression test covering unsigned preservation, signed-block stripping, and a non-Xiaomi negative URL. - Current main moved this logic into
_manage_thinking_signatures()atagent/anthropic_adapter.py:2250-2309, so the patch needs to be ported there rather than applied to the old conversion block.
Suggested changes
- Add a fail-closed Xiaomi
/anthropicdetector usingbase_url_host_matches()and include it in the current preservation predicate. - Add the focused regression coverage above.
Automated hermes-sweeper review.
| if not normalized: | ||
| return False | ||
| normalized = normalized.rstrip("/").lower() | ||
| return "xiaomimimo.com" in normalized and "/anthropic" in normalized |
Contributor
There was a problem hiding this comment.
Use base_url_host_matches(base_url or "", "xiaomimimo.com") before the /anthropic path check. The current raw substring match also accepts URL paths and host suffixes containing this string; utils.py:528-546 provides the repository-standard fail-closed matcher.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for Xiaomi MiMo's Anthropic-compatible endpoint (
/anthropic) for thinking mode. This fix resolves HTTP 400 errors when using Xiaomi MiMo models with thinking/reasoning enabled.Problem
When using Xiaomi MiMo model (
mimo-v2.5-pro) via Anthropic-compatible endpoint (https://token-plan-cn.xiaomimimo.com/anthropic), enabling thinking mode causes HTTP 400 error:Root Cause
Xiaomi's
/anthropicendpoint, like Kimi and DeepSeek, uses the Anthropic Messages protocol but requires unsigned thinking blocks to be preserved when thinking mode is enabled. The current code strips all thinking blocks for third-party endpoints, causing Xiaomi's API to not receive the requiredreasoning_content.Solution
Following the approach used for Kimi and DeepSeek endpoints:
_is_xiaomi_anthropic_endpoint()detection function_preserve_unsigned_thinkingcondition inconvert_messages_to_anthropic()This preserves unsigned thinking blocks synthesized from
reasoning_contentwhile stripping Anthropic's signed blocks, matching the behavior for Kimi and DeepSeek endpoints.Test plan
reasoning_effort: medium/high)Related issues
Closes #24884
Note: This PR was created by ClaudeCode powered by MiMo-2.5-Pro.