Skip to content

fix: MiniMax-M3 streaming parser when tool calls start before </mm:think>#2085

Merged
ikawrakow merged 2 commits into
ikawrakow:mainfrom
jkyamog:fix/minimax-m3-parser-streaming
Jul 9, 2026
Merged

fix: MiniMax-M3 streaming parser when tool calls start before </mm:think>#2085
ikawrakow merged 2 commits into
ikawrakow:mainfrom
jkyamog:fix/minimax-m3-parser-streaming

Conversation

@jkyamog

@jkyamog jkyamog commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

MiniMax-M3 can start a tool call while its <mm:think> block is still
unterminated in the streamed text. The existing parser treated the open thought
as normal reasoning only while waiting for </mm:think>, which allowed the
MiniMax tool-call namespace marker to be consumed as reasoning/content in some
streaming cases.

This PR updates the dedicated MiniMax-M3 parser so that, when tools are enabled,
the reasoning parser stops at either:

  • </mm:think>
  • ]<]minimax[>[<tool_call>

That keeps partial reasoning quarantined during streaming and prevents MiniMax
tool-call markers from leaking into reasoning_content or visible content.

@ikawrakow ikawrakow requested a review from firecoperana July 6, 2026 07:46
@jkyamog jkyamog marked this pull request as draft July 6, 2026 15:50
@jkyamog

jkyamog commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

convert to draft for now, saw another case to improve the parser. doing some more testing and will push a better version.

@jkyamog jkyamog force-pushed the fix/minimax-m3-parser-streaming branch 2 times, most recently from d69221f to 5d5d996 Compare July 7, 2026 02:30
@jkyamog jkyamog marked this pull request as ready for review July 7, 2026 10:44
@jkyamog

jkyamog commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Ok some improvements and more testing, so far the nested thinking and tools are all working well. Ready for review.

Comment thread common/chat.cpp
Comment thread common/chat.cpp
Comment thread common/chat.cpp
@jkyamog jkyamog force-pushed the fix/minimax-m3-parser-streaming branch from 5d5d996 to 3aa3621 Compare July 8, 2026 01:58
@jkyamog

jkyamog commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@firecoperana we caught another issue with m3 this the 2nd commit (ffe7034)

Codex explanation, I did ask if this low risk and code path is m3 specific.

This handles another MiniMax-M3 streaming edge case seen in real usage. MiniMax can begin emitting a new namespaced tool marker before the previous string tool argument is cleanly closed; without
this guard, that marker can be parsed as literal bash command text.

Risk should be low because the new logic is only called from common_chat_peg_minimax_m3_mapper::from_ast(), so it is specific to the MiniMax-M3 parser path. Other chat formats do not use this
mapper. I also added a regression test based on the observed failure shape, and test-chat-auto-parser passes.

@ikawrakow ikawrakow merged commit 3bb0e9f into ikawrakow:main Jul 9, 2026
@jkyamog jkyamog deleted the fix/minimax-m3-parser-streaming branch July 9, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants