Skip to content

Conversation

@aldehir
Copy link
Collaborator

@aldehir aldehir commented Dec 3, 2025

Parser implementation for Ministral 3 Reasoning/Instruct and Mistral Large 3 Instruct. It deviates from the current Mistral implementation by accepting tool calls in the form: [TOOL_CALLS]tool_name[ARGS]{"arg1": ... }...

Features

  • Extracts reasoning to reasoning_content when reasoning_format = auto/deepseek. If reasoning_format = none, the traces are left in content.
  • Formats system and assistant messages containing reasoning_content into {"type": "thinking", "thinking": "..."} content blocks the chat template expects. server: thinking type rejected as invalid but used by Ministral 3 #17700
  • Supports tool calling for both tool_choice = auto and tool_choice = required (with thinking).
  • Supports parallel tool calls
  • Supports response_format with thinking.

Additional Changes

  • Exposed reasoning_format during chat param init to build the appropriate parser.
  • Added make_peg_parser helper in tests/test-chat.cpp for use with peg parsers.
  • Included the Unsloth template. Minja does not detect tool calling capabilities with the official template because of an exception it raises.

@aldehir aldehir changed the title common : add parser for ministral/mistral 3 common : add parser for ministral/mistral large 3 Dec 3, 2025
@github-actions github-actions bot added documentation Improvements or additions to documentation testing Everything test related examples server labels Dec 3, 2025
@aldehir aldehir marked this pull request as ready for review December 4, 2025 07:13
@aldehir aldehir requested a review from pwilkin December 4, 2025 07:18
@aldehir
Copy link
Collaborator Author

aldehir commented Dec 4, 2025

@pwilkin don't worry, I'm still leaving Qwen3-Coder for you. I added some testing logic since you had ideas about how we should test.

Copy link
Collaborator

@pwilkin pwilkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you could make those test cases into universal test cases for a testcase class / lambda where the only parameters for the actual test case are the parser and the expected string? So that the test case invocations look like:

test_hello_world(&p, "Hello world");
...
test_tool_with_reasoning(&p, "{iamthinking}Thinking of calling tool get_weather{iamnotthinking}{iamcallingatool}get_weather{withparameter}place{ofvalue}Paris{imdonecallingatool}");

?

@aldehir
Copy link
Collaborator Author

aldehir commented Dec 4, 2025

I get where you're coming from. I'll play around with it. Another option is table driven tests. They work well at reducing duplication when you have many similar looking tests.

One thing I don't like about some of the helpers at the top is that I have scroll up to find the actual content it compares against.

@pwilkin
Copy link
Collaborator

pwilkin commented Dec 4, 2025

One thing I don't like about some of the helpers at the top is that I have scroll up to find the actual content it compares against.

I think a decent idea to combat that is to have a comment that keeps a template of all the tests with placeholders - then when you implement the model, you just move the comment to after the new model :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation examples server testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants