fix(agent): preserve MiMo thinking blocks on Anthropic replay - #26802
Open
CallMe1101 wants to merge 1 commit into
Open
fix(agent): preserve MiMo thinking blocks on Anthropic replay#26802CallMe1101 wants to merge 1 commit into
CallMe1101 wants to merge 1 commit into
Conversation
…search#24465) Xiaomi MiMo's Anthropic-compatible endpoint requires reasoning_content to round-trip on replayed assistant tool-call messages when thinking mode is enabled. Without this, multi-turn conversations fail with HTTP 400: The reasoning_content in the thinking mode must be passed back to the API. This applies the same strip-signed / keep-unsigned policy already used for Kimi (/coding) and DeepSeek (/anthropic) to MiMo endpoints. Changes to agent/anthropic_adapter.py: - Add _XIAOMI_MIMO_MODEL_PREFIXES, _model_name_is_xiaomi_mimo(), _is_xiaomi_mimo_anthropic_endpoint() for model/URL detection - Add MiMo to _preserve_unsigned_thinking condition - Inject single-space placeholder thinking block for assistant tool-use turns that lack any thinking/reasoning data (reproduces NousResearch#24726) Tests: - tests/agent/test_xiaomi_mimo_anthropic_thinking.py (277 lines) - tests/run_agent/test_xiaomi_mimo_reasoning_replay.py (138 lines) Refs: NousResearch#13848 (Kimi), NousResearch#16748 (DeepSeek), NousResearch#24465, NousResearch#24726, NousResearch#26775
Collaborator
teknium1
added a commit
that referenced
this pull request
Jun 15, 2026
Salvages the Xiaomi MiMo thinking/replay fixes from #27886/#25379/#26802/#27363 into one provider cluster, with MiMo reasoning replay enabled for native Xiaomi endpoints plus Nous/OpenRouter Xiaomi slugs. Co-authored-by: EloquentBrush0x <283442588+EloquentBrush0x@users.noreply.github.com> Co-authored-by: Peterson <pppan2003@gmail.com> Co-authored-by: Zhao Zhuoran <zhao.zr11@protonmail.com> Co-authored-by: zccyman <zccyman@users.noreply.github.com>
teknium1
reviewed
Jul 13, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for tracing the replay failure and covering signed versus unsigned thinking blocks. The current main path still lacks Xiaomi-specific unsigned-thinking preservation at agent/anthropic_adapter.py:2276-2279, so the underlying issue remains relevant.
Problems
agent/anthropic_adapter.py:509-513makes a MiMo model slug sufficient to select Xiaomi Anthropic replay behavior. The added tests deliberately accepthttps://llm.example.com/anthropicforxiaomi-mimo-*andxiaomi/mimo-*models (tests/agent/test_xiaomi_mimo_anthropic_thinking.py:31-32). A model name does not establish that an arbitrary proxy accepts Xiaomi's unsigned-thinking contract.
Suggested changes
- Scope detection to Xiaomi's
xiaomimimo.comhost and an/anthropicroute; add negative cases for OpenAI-compatible Xiaomi URLs and arbitrary proxy/aggregator slugs. Commit06d94943d671ad85119761d8657a7daa07eaea0acontains that narrower salvage direction, but is not on currentmain.
Automated hermes-sweeper review.
|
|
||
| See hermes-agent#24465, #24726. | ||
| """ | ||
| if _model_name_is_xiaomi_mimo(model): |
Contributor
There was a problem hiding this comment.
A MiMo-named model alone does not prove that an arbitrary Anthropic-compatible proxy implements Xiaomi's replay contract. Please gate this on Xiaomi's host plus the /anthropic route; the current tests at tests/agent/test_xiaomi_mimo_anthropic_thinking.py:31-32 lock in the overbroad proxy behavior.
This was referenced Jul 18, 2026
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
Xiaomi MiMo's Anthropic-compatible endpoint recently tightened thinking-mode validation. When thinking mode is enabled, prior assistant turns containing
tool_usemust replay their fullreasoning_contenton subsequent requests. If omitted, MiMo returns HTTP 400:Generic third-party Anthropic handling strips all thinking blocks, breaking MiMo replays — same root cause as Kimi (#13848) and DeepSeek (#16748).
Solution
MiMo follows the same replay contract as Kimi and DeepSeek: strip Anthropic-signed thinking blocks (third-party endpoints cannot validate signatures) but preserve unsigned thinking blocks synthesized from
reasoning_content.Changes to
agent/anthropic_adapter.py_XIAOMI_MIMO_MODEL_PREFIXES— model name prefixes (mimo-*,mimo_*,xiaomi-mimo-*,xiaomi_mimo_*)_model_name_is_xiaomi_mimo()— detects MiMo model names (strips vendor prefix, handles deep-namespaced forms)_is_xiaomi_mimo_anthropic_endpoint()— matches by model name or base_url host (xiaomimimo.com,mimo.com)_preserve_unsigned_thinkingto include MiMo alongside Kimi/DeepSeekTests
tests/agent/test_xiaomi_mimo_anthropic_thinking.py(277 lines): unsigned thinking preservation, signed block stripping, generic third-party behavior, placeholder injection, lookalike model names, deep-namespaced modelstests/run_agent/test_xiaomi_mimo_reasoning_replay.py(138 lines): reasoning padding for MiMo providers, missing/empty reasoning_content handling, lookalike detectionNotes
run_agent.pyalready has MiMo reasoning support (merged via fix(agent): add Xiaomi MiMo to reasoning_content echo-back providers (#25358) #25484). This PR completes the picture by adding the correspondinganthropic_adapter.pychanges.mainand only touchesanthropic_adapter.py+ tests.Testing
All 38 tests pass:
Related