Skip to content

MiniMax-M3 Native Tool-Call Parser#2008

Merged
ikawrakow merged 1 commit into
ikawrakow:mainfrom
jkyamog:minimax-m3-native-parser
Jun 23, 2026
Merged

MiniMax-M3 Native Tool-Call Parser#2008
ikawrakow merged 1 commit into
ikawrakow:mainfrom
jkyamog:minimax-m3-native-parser

Conversation

@jkyamog

@jkyamog jkyamog commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

This adds native MiniMax-M3 chat-template parsing support for tool calls and reasoning extraction.

MiniMax-M3 uses its own namespace token and XML-like function-call format:

]<]minimax[>[<tool_call>
]<]minimax[>[<invoke name="tool-name">
]<]minimax[>[<arg>value]<]minimax[>[</arg>
]<]minimax[>[</invoke>
]<]minimax[>[</tool_call>

The previous PR #1963 used a MiniMax-M2-style <parameter name="..."> format. That was parser-friendly, but it did not match the native MiniMax-M3 template and caused fragile downstream behavior with clients expecting native M3 output.

Changes

  • Add a specialized MiniMax-M3 PEG parser in common/chat.cpp.
  • Detect MiniMax-M3 templates by the native namespace/tool-call markers.
  • Parse <mm:think>...</mm:think> into reasoning_content.
  • Parse single and parallel native tool calls into structured tool_calls.
  • Remove the obsolete models/templates/MiniMax-M3.jinja override, which used the old M2-style compatibility wrapper.
  • Add a regression test covering reasoning plus two native tool calls.

Validation

  • Syntax-checked common/chat.cpp and tests/test-chat-template.cpp against two existing compile databases.
  • Built successfully in the Docker CUDA image used by the local deployment.
  • Deployed locally with MiniMax-M3 Q6 and verified an OpenAI-compatible tool-call smoke:
    • content was empty
    • reasoning_content contained hidden reasoning
    • tool_calls contained a structured function call with JSON arguments
    • used Hermes and Pi Agent as end to end test

Notes

This intentionally relies on the native MiniMax-M3 chat template, normally embedded in the GGUF metadata. No external --chat-template-file override is required when the model already carries the native template.

This is a breaking cleanup for the old PR #1963 MiniMax-M3 template override. That file preserved a MiniMax-M2-style <parameter name="..."> wrapper and should not be kept now that native M3 tool parsing is supported directly.

The parser handles MiniMax-M3 generation prompts that already end with <mm:think>, so generated reasoning is still extracted into reasoning_content instead of leaking into visible content.

@jkyamog

jkyamog commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

the short story of this PR, Minimax M3 was very unreliable with tool calls. Initially I thought it was the model, that is why I switched to GLM-5.2. However I thought surely Minimax M3 Q6 should not be worse the smaller Qwen 27B, 35B. After asking and pushing codex, eventually I understood that the PR $1963 last week was problematic. Sorry breaking change, codex insisted on keeping the template but I think that is confusing having a template that is not really used most of the time.

@ikawrakow ikawrakow requested a review from firecoperana June 22, 2026 14:53
@ikawrakow ikawrakow merged commit 69a8336 into ikawrakow:main Jun 23, 2026
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