Private
Public Access
fix(ai_loop): wrap MiniMax reasoning in <thinking> tags for parse_thinking_trace (FR3, Bug #3)
Adds a new wrap_reasoning_in_text: bool = False keyword argument to
run_with_tool_loop. When True and reasoning_content is non-empty, the
returned text is prepended with <thinking>...</thinking> tags so
thinking_parser.parse_thinking_trace can extract a ThinkingSegment
for the discussion entry.
The wrap is conditional (default False) so it doesn't break providers
that already wrap inline (e.g. DeepSeek, which wraps at line 2117-2118
before run_with_tool_loop sees the response).
_send_minimax now passes wrap_reasoning_in_text=bool(caps.reasoning).
When caps.reasoning is True (M2.5/M2.7), the reasoning is wrapped in
<thinking> tags. When False (M2/M2.1), the parameter is False and
no wrap happens (avoids useless getattr on non-reasoning models).
Also fixes a bug in the test_fr3_minimax_thinking_in_returned_text
test mock: it was returning a raw MagicMock instead of a Result
object, which caused the test to see auto-created MagicMock attributes
instead of the expected text. Now wraps in Result(data=MagicMock(...))
and sets ai_client._model to ensure get_capabilities('minimax', _model)
resolves to the M2.7 capabilities (reasoning=True).
This commit is contained in:
@@ -204,7 +204,7 @@ def test_fr3_minimax_thinking_in_returned_text() -> None:
|
||||
|
||||
def _fake_send_openai_compatible(client, request, *, capabilities):
|
||||
captured_text.append("send_openai_compatible was called")
|
||||
return MagicMock(
|
||||
return Result(data=MagicMock(
|
||||
text="The final answer is 42",
|
||||
tool_calls=[],
|
||||
usage_input_tokens=0,
|
||||
@@ -212,11 +212,12 @@ def test_fr3_minimax_thinking_in_returned_text() -> None:
|
||||
usage_cache_read_tokens=0,
|
||||
usage_cache_creation_tokens=0,
|
||||
raw_response=fake_raw,
|
||||
)
|
||||
))
|
||||
|
||||
from src import openai_compatible as oc
|
||||
from src.vendor_capabilities import register, VendorCapabilities
|
||||
register(VendorCapabilities(vendor="minimax", model="MiniMax-M2.7", reasoning=True))
|
||||
ai_client._model = "MiniMax-M2.7"
|
||||
|
||||
with patch.object(oc, "send_openai_compatible", side_effect=_fake_send_openai_compatible), \
|
||||
patch("src.ai_client._ensure_minimax_client", return_value=MagicMock()), \
|
||||
|
||||
Reference in New Issue
Block a user