Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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":
Expand Down