Skip to content

fix(reasoning-cache): include xiaomi-mimo in replay provider/model detection - #2198

Merged
diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.0from
NomenAK:upstream/reasoning-replay-mimo
May 12, 2026
Merged

diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.0from
NomenAK:upstream/reasoning-replay-mimo

Conversation

@NomenAK

@NomenAK NomenAK commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Xiaomi MiMo (xiaomi-mimo provider, mimo-v2.5-pro / mimo-v2.5 / mimo-v2-omni models) enforces the same "echo reasoning_content on subsequent turns" contract as DeepSeek and Kimi-thinking. Without replay, the upstream returns 400:

```
data:{"error":{"code":"400","message":"Param Incorrect","param":"The reasoning_content in the thinking mode must be passed back to the API.","type":""}}
```

Repro: client sends a multi-turn /v1/messages body where the assistant history has tool_use blocks but no thinking blocks (Capy and most Anthropic-SDK BYOK clients strip thinking on the wire). MiMo refuses the call because the previous assistant turn's reasoning_content is missing.

The reasoning replay cache (issue #1628) already captures reasoning_content from non-streaming responses with tool_calls (chatCore.ts:4080) and re-injects it on the request side (translator/index.ts:212-242). But the gate requiresReasoningReplay(provider, model) did not include MiMo, so the captured reasoning was discarded on the next turn instead of replayed.

Fix

  • Add `"xiaomi-mimo"` to `REASONING_REPLAY_PROVIDERS`
  • Add `/^mimo[-.]?v\d/i` to `REASONING_REPLAY_MODEL_PATTERNS` (defensive match if a wildcard route assigns a non-`xiaomi-mimo` provider ID to a `mimo-*` model alias)

Test plan

  • 4 new test cases in `reasoning-cache.test.ts` covering both provider-id and model-pattern detection paths, including `XIAOMI-MIMO` uppercase normalization (40/40 green)
  • Smoke-validated against live MiMo via OmniRoute multi-turn call — 400 disappears, MiMo accepts the replayed reasoning_content

🤖 Generated with Claude Code

…tection

MiMo (Xiaomi) enforces the same "echo reasoning_content on subsequent
turns" contract as DeepSeek and Kimi-thinking. Without replay, the
upstream returns 400:

  data:{"error":{"code":"400","message":"Param Incorrect",
   "param":"The reasoning_content in the thinking mode must be passed back to the API.","type":""}}

Repro: client sends a multi-turn /v1/messages body where the assistant
history has tool_use blocks but no thinking blocks (Capy and most BYOK
clients strip thinking on the wire). MiMo refuses without the
reasoning_content from the previous assistant turn.

The reasoning replay cache (issue diegosouzapw#1628) already captures
reasoning_content from non-streaming responses with tool_calls and
re-injects it on the request side. But the gate
`requiresReasoningReplay(provider, model)` did not include MiMo:

  REASONING_REPLAY_PROVIDERS missed "xiaomi-mimo"
  REASONING_REPLAY_MODEL_PATTERNS had no /mimo/ entry

So the captured reasoning was discarded on the next turn instead of
replayed.

Fix:
  - Add "xiaomi-mimo" to REASONING_REPLAY_PROVIDERS
  - Add /^mimo[-.]?v\d/i to REASONING_REPLAY_MODEL_PATTERNS (defensive
    match if a wildcard route assigns a non-xiaomi-mimo provider ID to
    a mimo-* model alias)

Tests: 4 new cases (40/40 green) covering both provider-id and model-
pattern detection paths, including XIAOMI-MIMO uppercase normalization.
@NomenAK
NomenAK requested a review from diegosouzapw as a code owner May 12, 2026 14:59

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds support for Xiaomi MiMo reasoning models by updating the reasoning cache service to include the xiaomi-mimo provider and a regex pattern for MiMo models. It also includes unit tests to verify the detection logic. A review comment suggests removing the start-of-string anchor from the new regex pattern to maintain consistency with existing patterns and ensure robustness against prefixed model IDs.

/glm.*think/i,
// MiMo (Xiaomi) thinking models — defensive match if a wildcard route
// assigns a non-`xiaomi-mimo` provider ID to a mimo-* model alias.
/^mimo[-.]?v\d/i,

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.

medium

The regex for mimo models uses a start-of-string anchor (^), which is inconsistent with the other patterns in REASONING_REPLAY_MODEL_PATTERNS (such as deepseek-r1, qwq, or qwen.*think). If a model ID is prefixed (e.g., provider/mimo-v2.5), this pattern will fail to match. Removing the ^ anchor would maintain consistency with the existing patterns and improve robustness against prefixed model names.

Suggested change
/^mimo[-.]?v\d/i,
/mimo[-.]?v\d/i,

@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks @NomenAK for the Xiaomi MiMo reasoning replay fix. I synced the PR branch with release/v3.8.0, validated tests/unit/reasoning-cache.test.ts locally, and will include this in the upcoming release.

@diegosouzapw
diegosouzapw merged commit b23b624 into diegosouzapw:release/v3.8.0 May 12, 2026
1 of 2 checks passed
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
…tection (diegosouzapw#2198)

Integrated into release/v3.8.0 after syncing the contributor branch and validating tests/unit/reasoning-cache.test.ts locally.
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
…tection (diegosouzapw#2198)

Integrated into release/v3.8.0 after syncing the contributor branch and validating tests/unit/reasoning-cache.test.ts locally.
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.

2 participants