Skip to content

Consolidate reasoning_content echo detection, add Xiaomi MiMo support#24832

Open
stanleylai wants to merge 1 commit into
NousResearch:mainfrom
stanleylai:fix/consolidate-reasoning-echo-detection
Open

Consolidate reasoning_content echo detection, add Xiaomi MiMo support#24832
stanleylai wants to merge 1 commit into
NousResearch:mainfrom
stanleylai:fix/consolidate-reasoning-echo-detection

Conversation

@stanleylai

Copy link
Copy Markdown

Bug Description

Xiaomi MiMo (mimo-v2.5-pro) requires reasoning_content to be echoed back on assistant messages in multi-turn conversations. Without it, the API returns HTTP 400:

"The reasoning_content in the thinking mode must be passed back to the API."

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_PROVIDERS table. Add Xiaomi MiMo entries:

  • _REASONING_ECHO_PROVIDERS table at module level — tuple of (provider, model_substr, host) rows, checked as OR
  • _needs_reasoning_content_echo() — one method replacing three, iterates the table
  • Xiaomi entries: "mimo-" model substring (hyphen avoids false positives on the common ML acronym) + api.xiaomimimo.com host fallback
  • Deleted: _needs_deepseek_tool_reasoning(), _needs_kimi_tool_reasoning(), _needs_thinking_reasoning_pad()
  • Updated all call sites and comments to mention MiMo
  • Net: +107 / −65 lines across 2 files

How to Verify

  1. hermes chat -q "What model are you?" -m mimo-v2.5-pro --provider opencode-go — turn 1 works
  2. hermes chat --resume <session_id> -q "What did I just ask?" — turn 2 works (previously HTTP 400)
  3. grep reasoning_content ~/.hermes/logs/agent.log — no 400 errors after restart
  4. python -m pytest tests/run_agent/test_deepseek_reasoning_content_echo.py -v — 44/44 pass

Test Plan

  • Unit tests pass (44/44)
  • Live verification: multi-turn MiMo conversation works, zero 400s in logs
  • Regression: DeepSeek and Kimi detection still works (covered by existing parametrized tests)
  • Negative test: non-MiMo models (e.g. qwen3.5-plus) correctly return False

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.

@stanleylai stanleylai force-pushed the fix/consolidate-reasoning-echo-detection branch from 6428c67 to 0b0df6c Compare May 13, 2026 05:48
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change comp/agent Core agent loop, run_agent.py, prompt builder provider/xiaomi Xiaomi MiLM P2 Medium — degraded but workaround exists labels May 13, 2026
@stanleylai stanleylai force-pushed the fix/consolidate-reasoning-echo-detection branch 2 times, most recently from cfb2803 to ef6efb5 Compare May 15, 2026 05:41
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>
@stanleylai stanleylai force-pushed the fix/consolidate-reasoning-echo-detection branch from ef6efb5 to d0287f7 Compare May 16, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists provider/xiaomi Xiaomi MiLM type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants