feat: support Xiaomi MiMo thinking-mode reasoning_content replay#24465
feat: support Xiaomi MiMo thinking-mode reasoning_content replay#24465Peek-A-Booo wants to merge 4 commits into
Conversation
MiMo (like Kimi and DeepSeek) requires reasoning_content to be round-tripped on assistant tool-call messages when thinking mode is enabled. Without it, multi-turn agent conversations fail with HTTP 400. Changes: - agent/anthropic_adapter.py: Add _model_name_is_xiaomi_mimo() and _is_xiaomi_mimo_anthropic_endpoint() helpers; include MiMo in the _preserve_unsigned_thinking condition alongside Kimi/DeepSeek - run_agent.py: Add _needs_xiaomi_tool_reasoning() method with provider, model prefix, and base_url domain detection; include in _needs_thinking_reasoning_pad() - tests: 26 new tests covering model name matching, endpoint detection, thinking preservation, and reasoning padding for MiMo Refs: NousResearch#13848, NousResearch#15250, NousResearch#16748, NousResearch#17057, NousResearch#17400
|
@Peek-A-Booo @alt-glitch — flagging three additions from #24603 (duplicate, will defer to this PR as the earliest) that may be worth folding in before merge. All are battle-tested with hermetic tests in #24603 and can be cherry-picked or rewritten standalone. 1. Third-party namespaced catalog form
|
|
Adding one live repro datapoint from #24726 before I close/defer it here. I hit the same 400 in a real Hermes gateway session after the primary The request dump shape was slightly different from plain OpenAI {"role":"assistant","content":[{"type":"tool_use","id":"call_...","name":"terminal","input":{...}}]}In that dump there were 29 assistant tool-use turns and 0 had
Offline verification against the failing dump after that change: I have no need to keep #24726 competing with this PR. If this live replay shape is already covered here, great. If not, it may be worth adding as a small extra regression before merge. |
- Add defence-in-depth '/mimo-' substring check for deep-namespaced model names (vendor/sub/mimo-v3) in both anthropic_adapter and run_agent detectors - Add negative regression tests: MiniMax, Mistral, Microsoft Phi-4, phi-4-mimo-style, mimowave-7b must NOT trigger MiMo enforcement - Add deep namespace tests: vendor/sub/mimo-v3, a/b/c/xiaomi-mimo-* - reasoning_content='' upgrade was already covered (test exists) Addresses review comments from NilsR0711 and akaDRJ.
… thinking blocks When strict thinking-replay providers (MiMo, Kimi, DeepSeek) replay assistant turns that are already in Anthropic content-block format with tool_use blocks but NO thinking blocks at all, inject a single-space placeholder thinking block so the upstream API does not reject with HTTP 400. This covers akaDRJ's live repro (NousResearch#24726): 29 assistant tool-use turns in Anthropic content-block form, zero with thinking/reasoning data, from a provider failover to MiMo's /anthropic endpoint. Also: address NilsR0711 review feedback: - Add defence-in-depth '/mimo-' substring check for deep-namespaced models - Add negative regression tests (MiniMax, Mistral, Phi-4, mimowave, etc.) - Add deep namespace tests (vendor/sub/mimo-v3) - Test Anthropic tool_use without thinking (new) + non-MiMo negative guard
Summary
Add Xiaomi MiMo thinking-mode support for
reasoning_contentround-trip in multi-turn agent conversations.MiMo, like Kimi and DeepSeek, requires
reasoning_contentto be passed back on replayed assistant tool-call messages when thinking mode is enabled. Without this fix, multi-turn conversations with tool calls fail with HTTP 400: "The reasoning_content in the thinking mode must be passed back to the API."Changes
agent/anthropic_adapter.py: Add_model_name_is_xiaomi_mimo()and_is_xiaomi_mimo_anthropic_endpoint()helpers; include MiMo in the_preserve_unsigned_thinkingcondition alongside Kimi/DeepSeekrun_agent.py: Add_needs_xiaomi_tool_reasoning()method with provider, model prefix, and base_url domain detection; include in_needs_thinking_reasoning_pad()Detection Logic
Matches MiMo via three signals:
xiaomi,mimo,xiaomi-mimomimo-,mimo_,xiaomi-mimo-,xiaomi_mimo_(strips namespace prefixes likeopenrouter/)xiaomimimo.com,mimo.comTest Plan
mimo-v2.5-provia CLI — no 400 errorsRelated
Refs: #13848, #15250, #16748, #17057, #17400