Consolidate reasoning_content echo detection, add Xiaomi MiMo support#24832
Open
stanleylai wants to merge 1 commit into
Open
Consolidate reasoning_content echo detection, add Xiaomi MiMo support#24832stanleylai wants to merge 1 commit into
stanleylai wants to merge 1 commit into
Conversation
6428c67 to
0b0df6c
Compare
14 tasks
cfb2803 to
ef6efb5
Compare
Merge _needs_deepseek_tool_reasoning(), _needs_kimi_tool_reasoning(),
and _needs_thinking_reasoning_pad() into a single
_needs_reasoning_content_echo() backed by a module-level
_REASONING_ECHO_PROVIDERS table.
Problem:
Xiaomi MiMo (mimo-v2.5-pro) requires reasoning_content echoed back
on assistant messages in multi-turn conversations, identical to
DeepSeek V4 and Kimi/Moonshot. Without it, the API returns HTTP 400:
'The reasoning_content in the thinking mode must be passed back.'
MiMo wasn't detected by any of the three existing methods, and adding
a fourth copy would continue the sprawl.
Solution:
- Replace three provider-specific detection methods with one table-
driven _needs_reasoning_content_echo(). Each row is
(provider, model_substr, host) with OR semantics — any non-None
column matching suffices.
- Add Xiaomi entries: ('xiaomi', 'mimo-', None) for provider+model
and (None, None, 'api.xiaomimimo.com') for host fallback.
- Preserve all existing DeepSeek and Kimi/Moonshot detection paths.
- Update tests: rename classes, add Xiaomi test cases (provider,
model substring, host match, non-match negative case).
This makes adding future providers a one-line table entry instead of
a new method. Existing providers unaffected — all 44 unit tests pass.
Co-authored-by: Hermes Agent <hermes@staneryln.com>
ef6efb5 to
d0287f7
Compare
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.
Bug Description
Xiaomi MiMo (mimo-v2.5-pro) requires
reasoning_contentto be echoed back on assistant messages in multi-turn conversations. Without it, the API returns HTTP 400:This is the same requirement as DeepSeek V4 and Kimi/Moonshot — Hermes already has fixes for those, but MiMo was not detected by any of the three existing methods (
_needs_deepseek_tool_reasoning,_needs_kimi_tool_reasoning,_needs_thinking_reasoning_pad).Impact: Anyone using MiMo via any provider (opencode-go, OpenRouter, custom endpoints) hits a hard failure on every message after the first turn.
Root Cause
Three separate detection methods existed for the same underlying requirement (echo
reasoning_content), each with its own provider-specific logic. MiMo wasn't in any of them, and adding yet another copy would compound the sprawl.Fix
Consolidate the three detection methods into a single
_needs_reasoning_content_echo()backed by a module-level_REASONING_ECHO_PROVIDERStable. Add Xiaomi MiMo entries:_REASONING_ECHO_PROVIDERStable at module level — tuple of(provider, model_substr, host)rows, checked as OR_needs_reasoning_content_echo()— one method replacing three, iterates the table"mimo-"model substring (hyphen avoids false positives on the common ML acronym) +api.xiaomimimo.comhost fallback_needs_deepseek_tool_reasoning(),_needs_kimi_tool_reasoning(),_needs_thinking_reasoning_pad()How to Verify
hermes chat -q "What model are you?" -m mimo-v2.5-pro --provider opencode-go— turn 1 workshermes chat --resume <session_id> -q "What did I just ask?"— turn 2 works (previously HTTP 400)grep reasoning_content ~/.hermes/logs/agent.log— no 400 errors after restartpython -m pytest tests/run_agent/test_deepseek_reasoning_content_echo.py -v— 44/44 passTest Plan
Risk Assessment
Low — The consolidated method preserves exact semantics for DeepSeek and Kimi (same match logic, same rows). MiMo detection uses
"mimo-"with hyphen to avoid false positives. Kimi detection is now case-insensitive (.lower()s first), which is harmless since providers are already normalized at init.