v22.2 issue: tools calls are escaping in regular output

#83
by anjeysapkovski - opened

The template seems to be broken with VS Code + Kilo Code harness. Native template works reliably, but this one mixes tool calling and regular output.

I'll create a comprehensive Windows-style desktop application as a single HTML file with six apps, start menu, task manager, and console.

<function=write> <parameter=filePath> D:\test\desktop.html <parameter=content>

Desktop OS
...

Hi @anjeysapkovski ,

This happens because Qwen 3.x models use native XML tags (<function=...><parameter=...>) by default. Our template defaults to canonical XML because Qwen follows XML much more reliably than JSON, avoiding syntax and escaping issues.

Client harnesses like Kilo Code expect OpenAI-style JSON tool calls ({"name": "...", "arguments": {...}}). When they receive XML tags, they treat them as plain assistant text instead of intercepting them as tool actions.

If your harness requires JSON tool calling, you can switch the template format by passing the tool_call_format template kwarg:

{
  "tool_call_format": "json"
}

Depending on what backend server you are running (LM Studio, llama.cpp, vLLM, or Ollama), you can add tool_call_format: "json" to your template configuration or request kwargs, and the template will emit standard JSON tool call blocks.

Thanks for detailed info. I tried new switcher, set it tool_call_format to json. Now it seems to with with Kilo Code, thought it seems, that I got loops more often like:

Read  [value={"filePath":"\"D:\\\\_O3\\\\gallery.html\", \"offset\": 254, \"limit\": 50}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 320, \"limit\": 50}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 640, \"limit\": 15}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 350, \"limit\": 20}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 267, \"limit\": 30}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 120, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 325, \"limit\": 15}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 355, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 643, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 650, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 258, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 270, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 280, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 330, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 356, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 644, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 646, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 648, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 260, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 272, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 282, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 332, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 358, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 645, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 647, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 649, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 261, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<function=read>\n<parameter=filePath>\n\"D:\\\\_O3\\\\gallery.html\", \"offset\": 273, \"limit\": 10}}\n</tool_call>\n<tool_call>\n<z
...endless loop ....

Good to hear tool_call_format: 'json' fixed the tool parsing in Kilo Code.

For the looping on read calls, in v22.3/v22.4 I added a two-tier error escalation warning that catches repetitive failures and tells the model to change approach. Grabbing the latest template should help with that.

froggeric changed discussion status to closed

Sign up or log in to comment