Skip to content

tool-call: Qwen3 Coder chat format support #15162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

ochafik
Copy link
Collaborator

@ochafik ochafik commented Aug 8, 2025

WIP! Will fix #15012 & #15046 when done.

Depends on Minja fixes: #15161

Qwen3 Coder has a weird syntax for tool calls: a Qwen2-esque <tool_call>\n<function=${fn_name}>...</function></tool_call>, except the parameters aren't a JSON object. Instead they're a succession of XML-ish parameters:

<parameter=${name}>\n${typeof value === 'string' : value : JSON.stringify(value)}\n</parameter>\n

This special treatment of strings technically means it's impossible for the model to output a call argument string that contains the substring </parameter> (probably avoided having to train the model to do proper JSON string escapes?). This is quite unfortunate tbh. I don't think we should follow it to the letter. In this PR I'm just constraining the format to be:

<parameter=${name}>\n${JSON.stringify(value)}\n</parameter>\n

(that is, string arguments will have quotes and their content will need to be escaped)

@github-actions github-actions bot added the testing Everything test related label Aug 8, 2025
@Danmoreng
Copy link

Related to #15012 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Everything test related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Qwen3-Coder Tool Call Parser
2 participants