chat : add qwen3 specialized parser - #26252
Conversation
|
Tested PR #26252 at commit 4bc63c9.
Image: Digest: |
|
/bot review |
Automated code review
Let me reconsider finding 1 with concrete token names from the PR description:
The reasoning parser: If the model:
Let me write the review accordingly, using the concrete tokens from the PR. Now let me finalize the review messageStatic review of PR #26252 (commit 4bc63c9). Reviewed The Correctness - please confirm with a test(point 1) Omitting the tool-call start token while a reasoning block is open is not handled and is untested. In the new parser the reasoning block is terminated with Either it and the grammar stays inactive for the whole call, or document that omitted opening tokens are only expected when no reasoning block is open. Will slow the review(point 3) Worst-case grammar size. Nits(point 4) (point 5) (point 6) Optional args use (point 7) The TOOL delimiter ` Reproduced. Now let me write the final review cleanly with the actual token namesStatic review of PR #26252 (commit 4bc63c9). Reviewed The Correctness - please confirm with a test(point 1) Omitting the tool-call start token while a reasoning block is open is not handled and is untested. In the new parser the open-reasoning block is Will slow the review(point 3) Worst-case grammar size. Nits(point 4) (point 5) (point 6) Optional args use (point 7) The TOOL delimiter This review was generated automatically by pi coding agent using |
|
@aldehir bot went crazy but I think one point is valid, i.e. the in-thinking tool call only accepts the full syntax ( |
That was intentional to support Qwen3-Coder which sometimes doesn't emit the tool call tag, and it's not a thinking model. |
|
Oh :) maybe add a comment for this then. |
|
@pwilkin Done. |
* Add tagged thinking tool parser * chat : refactor and add permute helper * cont : add support for <tool_call> omission * cont : update tool delimiters * cont : add comment for qwen3-coder * cont : fix trigger pattern for <function --------- Co-authored-by: Bart de Boer <bart.deboer@gmail.com>
* Add tagged thinking tool parser * chat : refactor and add permute helper * cont : add support for <tool_call> omission * cont : update tool delimiters * cont : add comment for qwen3-coder * cont : fix trigger pattern for <function --------- Co-authored-by: Bart de Boer <bart.deboer@gmail.com>
* Add tagged thinking tool parser * chat : refactor and add permute helper * cont : add support for <tool_call> omission * cont : update tool delimiters * cont : add comment for qwen3-coder * cont : fix trigger pattern for <function --------- Co-authored-by: Bart de Boer <bart.deboer@gmail.com>
* Add tagged thinking tool parser * chat : refactor and add permute helper * cont : add support for <tool_call> omission * cont : update tool delimiters * cont : add comment for qwen3-coder * cont : fix trigger pattern for <function --------- Co-authored-by: Bart de Boer <bart.deboer@gmail.com>
* Add tagged thinking tool parser * chat : refactor and add permute helper * cont : add support for <tool_call> omission * cont : update tool delimiters * cont : add comment for qwen3-coder * cont : fix trigger pattern for <function --------- Co-authored-by: Bart de Boer <bart.deboer@gmail.com>
* Add tagged thinking tool parser * chat : refactor and add permute helper * cont : add support for <tool_call> omission * cont : update tool delimiters * cont : add comment for qwen3-coder * cont : fix trigger pattern for <function --------- Co-authored-by: Bart de Boer <bart.deboer@gmail.com>
* Add tagged thinking tool parser * chat : refactor and add permute helper * cont : add support for <tool_call> omission * cont : update tool delimiters * cont : add comment for qwen3-coder * cont : fix trigger pattern for <function --------- Co-authored-by: Bart de Boer <bart.deboer@gmail.com>
Overview
Supersedes #24202, #26244
Qwen 3 models may occasionally emit a
<tool_call>after<think>\n, usually without any reasoning which leads me to believe this is a valid tool call and not a reasoning trace.This PR supports both
</think>and<tool_call>as reasoning end sequences. It also adds support for older models that sometimes omit<tool_call>. Although I rather not support these outdated models, it seems there is community desire for support.Additionally, we bring back argument permutation support, previously tried by @pwilkin, but optimized to minimize the number of active stacks in the grammar sampler at any one point in time. We have seen Qwen 3 try really hard to order arguments differently, to the point we had to impose harsher grammar constraints. Rather than fight it, we might as well allow it.
Requirements