diff --git a/run_agent.py b/run_agent.py index f2f3379e0d78e..1d3464ab90f47 100644 --- a/run_agent.py +++ b/run_agent.py @@ -9980,13 +9980,14 @@ def _build_assistant_message(self, assistant_message, finish_reason: str) -> dic def _needs_thinking_reasoning_pad(self) -> bool: """Return True when the active provider enforces reasoning_content echo-back. - DeepSeek v4 thinking and Kimi / Moonshot thinking both reject replays - of assistant tool-call messages that omit ``reasoning_content`` (refs - #15250, #17400). + DeepSeek v4 thinking, Kimi / Moonshot thinking, and Xiaomi MiMo + thinking all reject replays of assistant tool-call messages that + omit ``reasoning_content`` (refs #15250, #17400, xiaomi). """ return ( self._needs_deepseek_tool_reasoning() or self._needs_kimi_tool_reasoning() + or self._needs_xiaomi_tool_reasoning() ) def _needs_kimi_tool_reasoning(self) -> bool: @@ -10018,6 +10019,20 @@ def _needs_deepseek_tool_reasoning(self) -> bool: or base_url_host_matches(self.base_url, "api.deepseek.com") ) + def _needs_xiaomi_tool_reasoning(self) -> bool: + """Return True when the current provider is Xiaomi MiMo thinking mode. + + Xiaomi MiMo thinking mode requires ``reasoning_content`` on every + assistant tool-call message; omitting it causes the next replay to + fail with HTTP 400 ("The reasoning_content in the thinking mode + must be passed back to the API"). + """ + provider = (self.provider or "").lower() + return ( + provider == "xiaomi" + or base_url_host_matches(self.base_url, "xiaomimimo.com") + ) + def _copy_reasoning_content_for_api(self, source_msg: dict, api_msg: dict) -> None: """Copy provider-facing reasoning fields onto an API replay message.""" if source_msg.get("role") != "assistant":