Allow arbitrary arguments order for Q3C, Q3CN, and Qwen3.5 (#1352)

This should fix the read file at offset/limit issue, where the tool
definition has offset before limit, while the model sets limit before
offset.
This commit is contained in:
Yap Sok Ann
2026-03-03 21:39:16 +07:00
committed by GitHub
parent 505e2c57f9
commit ea3e8e30e1
3 changed files with 38 additions and 19 deletions

View File

@@ -1250,16 +1250,19 @@ static common_chat_params common_chat_params_init_qwen3_coder_xml(const common_c
}
// build grammar for tool call
static const xml_tool_call_format form {
/* form.scope_start = */ "",
/* form.tool_start = */ "\n<tool_call>\n<function=",
/* form.tool_sep = */ ">\n",
/* form.key_start = */ "<parameter=",
/* form.key_val_sep = */ ">\n",
/* form.val_end = */ "\n</parameter>\n",
/* form.tool_end = */ "</function>\n</tool_call>",
/* form.scope_end = */ "",
};
static const xml_tool_call_format form = ([]() {
xml_tool_call_format form {};
form.scope_start = "";
form.tool_start = "\n<tool_call>\n<function=";
form.tool_sep = ">\n";
form.key_start = "<parameter=";
form.key_val_sep = ">\n";
form.val_end = "\n</parameter>\n";
form.tool_end = "</function>\n</tool_call>";
form.scope_end = "";
form.relax_arg = true;
return form;
})();
build_grammar_xml_tool_call(data, params.tools, form);
return data;