Skip to content

feat: add Xiaomi MiMo Anthropic-compatible endpoint support for thinking mode - #24887

Closed
comeonzhj wants to merge 1 commit into
NousResearch:mainfrom
comeonzhj:feat/xiaomi-mimo-anthropic-thinking-support
Closed

feat: add Xiaomi MiMo Anthropic-compatible endpoint support for thinking mode#24887
comeonzhj wants to merge 1 commit into
NousResearch:mainfrom
comeonzhj:feat/xiaomi-mimo-anthropic-thinking-support

Conversation

@comeonzhj

@comeonzhj comeonzhj commented May 13, 2026

Copy link
Copy Markdown

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:

HTTP 400: Param Incorrect
The reasoning_content in the thinking mode must be passed back to the API.

Root Cause

Xiaomi's /anthropic endpoint, 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 required reasoning_content.

Solution

Following the approach used for Kimi and DeepSeek endpoints:

  1. Added _is_xiaomi_anthropic_endpoint() detection function
  2. Added Xiaomi endpoint to _preserve_unsigned_thinking condition in convert_messages_to_anthropic()

This preserves unsigned thinking blocks synthesized from reasoning_content while stripping Anthropic's signed blocks, matching the behavior for Kimi and DeepSeek endpoints.

Test plan

  • Test Xiaomi MiMo model with thinking mode enabled (reasoning_effort: medium/high)
  • Verify no HTTP 400 errors when using thinking mode
  • Verify thinking blocks are properly preserved in multi-turn conversations
  • Verify existing Kimi and DeepSeek endpoints still work correctly

Related issues

Closes #24884


Note: This PR was created by ClaudeCode powered by MiMo-2.5-Pro.

…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>
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/xiaomi Xiaomi MiLM P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels May 13, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #24465 (earliest open PR for Xiaomi MiMo reasoning_content echo-back). Also competes with #24603, #24784, #24810. Closes #24884 which is itself a duplicate of #24443.

@teknium1 teknium1 left a comment

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.

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:489 uses a raw "xiaomimimo.com" in normalized match. Please use the existing hostname-aware helper at utils.py:528-546; it rejects path and hostname-suffix collisions.
  • Commit 01e053e84454 changes only agent/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() at agent/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 /anthropic detector using base_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

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.

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.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 13, 2026
@comeonzhj comeonzhj closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have provider/xiaomi Xiaomi MiLM sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add Xiaomi MiMo Anthropic-compatible endpoint support for thinking mode

3 participants