fix(run_agent): enroll Xiaomi MiMo in reasoning_content echo-back enforcement#24605
Closed
wesleysimplicio wants to merge 1 commit into
Closed
Conversation
…orcement MiMo's thinking mode requires reasoning_content to be echoed on every assistant message in multi-turn conversations, identical to DeepSeek (NousResearch#15250) and Kimi (NousResearch#17400). Without enrollment, Hermes drops the field from persisted history and the next request fails with HTTP 400 ("The reasoning_content in the thinking mode must be passed back to the API"). Add _needs_mimo_tool_reasoning() detecting three signals: provider="xiaomi", base_url host matching xiaomimimo.com, or model prefix "xiaomi/" / "mimo-". OR it into _needs_thinking_reasoning_pad() so all downstream branches (_build_assistant_message pad, stale "" → " " upgrade, cross-provider leak guard) activate for MiMo automatically. No existing provider behaviour changes. Closes NousResearch#24443 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes multi-turn failures when using Xiaomi MiMo “thinking/reasoning” models by ensuring reasoning_content is always echoed back on assistant turns during conversation continuation (matching the existing enforcement behavior for DeepSeek and Kimi/Moonshot).
Changes:
- Add MiMo detection (
_needs_mimo_tool_reasoning) and include it in_needs_thinking_reasoning_pad()gating. - Extend the existing reasoning-content replay padding behavior to apply for MiMo automatically via the shared gate.
- Add a new regression test suite covering MiMo detection, padding, and assistant message construction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| run_agent.py | Adds MiMo provider/model/base_url detection and enrolls it into the existing thinking-mode reasoning_content echo-back enforcement gate. |
| tests/run_agent/test_mimo_reasoning_content_echo.py | Adds regression tests validating MiMo detection and ensuring replay-safe reasoning_content behavior across tool-call and non-tool turns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+10099
to
+10100
| thinking all reject replays of assistant tool-call messages that omit | ||
| ``reasoning_content`` (refs #15250, #17400, #24443). |
|
|
||
|
|
||
| class TestCopyReasoningContentForApiMimo: | ||
| """_copy_reasoning_content_for_api applies all four tiers for MiMo.""" |
Collaborator
4 tasks
This was referenced May 13, 2026
Contributor
Author
|
Closing as duplicate/superseded by #24662 to keep one canonical PR per fix topic and avoid review split. |
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.
Problem
MiMo reasoning/thinking models fail in multi-turn Hermes conversations with HTTP 400:
MiMo's OpenAI-compatible API requires
reasoning_contentto be echoed on every assistant message when continuing a conversation in thinking mode. Hermes already implements this for DeepSeek (#15250) and Kimi (#17400) but MiMo was not enrolled in the enforcement set.Root cause
_needs_thinking_reasoning_pad()gates all three enforcement branches:_build_assistant_message— pinsreasoning_contentat creation time for tool-call turns_copy_reasoning_content_for_apitier 1 — upgrades stale""→" "on replay_copy_reasoning_content_for_apitier 4 — unconditional" "pad for all assistant turnsThe method only OR'd in
_needs_deepseek_tool_reasoning()and_needs_kimi_tool_reasoning(). MiMo was missing, so all three branches were skipped forprovider="xiaomi"/xiaomimimo.com/mimo-*sessions.Fix
Add
_needs_mimo_tool_reasoning()detecting three signals (mirrors the pattern for Kimi):provider == "xiaomi"(case-insensitive)base_urlhost matchesxiaomimimo.com"xiaomi/"or"mimo-"(covers catalog and bare forms)OR it into
_needs_thinking_reasoning_pad(). All existing downstream branches activate for MiMo automatically — no other provider behaviour changes.Tests
tests/run_agent/test_mimo_reasoning_content_echo.py— 30 hermetic tests, modelled on the existing DeepSeek suite:TestNeedsMimoToolReasoning— all three detection signals, case-insensitive, negative/substring casesTestNeedsThinkingReasoningPadIncludesMimo— MiMo activates pad; DeepSeek/Kimi still active; unrelated provider offTestCopyReasoningContentForApiMimo— poisoned history →" ", real content preserved verbatim, stale""upgraded, cross-provider leak guard, base URL match, non-MiMo untouchedTestBuildAssistantMessageMimo— parametrized over all three detection signals; streamed reasoning promoted over pad; real reasoning_content preservedAll 30 new tests pass. Existing
test_deepseek_reasoning_content_echo.py(36 tests) unaffected.Visual
flowchart TD A["_needs_thinking_reasoning_pad()"] --> B["_needs_deepseek_tool_reasoning()"] A --> C["_needs_kimi_tool_reasoning()"] A --> D["_needs_mimo_tool_reasoning() ← NEW"] D --> E{"provider == 'xiaomi'?"} D --> F{"base_url host = xiaomimimo.com?"} D --> G{"model starts with 'xiaomi/' or 'mimo-'?"} E -- yes --> H[enforce echo-back] F -- yes --> H G -- yes --> HCloses #24443