fix(reasoning-cache): include xiaomi-mimo in replay provider/model detection - #2198
Conversation
…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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
| /^mimo[-.]?v\d/i, | |
| /mimo[-.]?v\d/i, |
|
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. |
b23b624
into
diegosouzapw:release/v3.8.0
…tection (diegosouzapw#2198) Integrated into release/v3.8.0 after syncing the contributor branch and validating tests/unit/reasoning-cache.test.ts locally.
…tection (diegosouzapw#2198) Integrated into release/v3.8.0 after syncing the contributor branch and validating tests/unit/reasoning-cache.test.ts locally.
Summary
Xiaomi MiMo (
xiaomi-mimoprovider,mimo-v2.5-pro/mimo-v2.5/mimo-v2-omnimodels) 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/messagesbody where the assistant history hastool_useblocks 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'sreasoning_contentis missing.The reasoning replay cache (issue #1628) already captures
reasoning_contentfrom non-streaming responses withtool_calls(chatCore.ts:4080) and re-injects it on the request side (translator/index.ts:212-242). But the gaterequiresReasoningReplay(provider, model)did not include MiMo, so the captured reasoning was discarded on the next turn instead of replayed.Fix
Test plan
🤖 Generated with Claude Code