minicpm5-2b native tool calls never parse
Author: khrotuCreated Sep 16, 2026Updated Sep 16, 2026
Labelsbug
What is the issue?
With tools passed to /api/chat (and /v1/chat/completions), MiniCPM5-2B attempts the native XML tool call, but the response always has tool_calls: null (native) / missing (OpenAI compat) and content contains a mangled fragment such as name="get_weather"> name="city">Paris. The model reasoning (thinking/reasoning) shows correct tool intent. Standard clients that branch on tool_calls or finish_reason: tool_calls never take the tool branch. finish_reason/done_reason is always stop.
repro:
curl http://localhost:11434/api/chat -H "Content-Type: application/json" -d '{
"model": "minicpm5-2b:latest",
"messages": [{"role": "user", "content": "What is the weather in Paris? Use the tool."}],
"stream": false,
"tools": [{"type": "function", "function": {"name": "get_weather",
"description": "Get weather for a city",
"parameters": {"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]}}}]
}'
response:
{"model":"minicpm5-2b:latest",
"message":{"role":"assistant",
"content":" name=\"get_weather\"> name=\"city\">Paris",
"thinking":"The user wants to know the weather in Paris. I need to use the get_weather function.\n"},
"done":true,"done_reason":"stop"}
tool_calls is null. OpenAI compat (/v1/chat/completions) returns the same mangled content, a correct reasoning field, no tool_calls, finish_reason: stop.
upstream reference:
- vLLM
minicpm5xml_tool_parser.py: "Tool XML tags are special tokens in MiniCPM5; must not strip them before tool parsing ...request.skip_special_tokens = False." - SGLang documents
--tool-call-parser minicpm5for MiniCPM5-1B XML tool calls. - OpenBMB/MiniCPM states SGLang is the recommended backend for MiniCPM5 tool calling.
Relevant log output
OS
Windows
GPU
Nvidia
CPU
Intel
Ollama version
0.30.8
Source: ollama/ollama