SamJoshua's picture
Add write-up: 31 of 40 chat templates crash on OpenAI-style tool calls
94914a6 verified
Raw History Blame Contribute Delete
32.2 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>31 of 40 popular chat templates crash on OpenAI-style tool calls</title>
<meta name="description" content="Of 40 popular tool-calling chat templates that render dict arguments, 31 crash when arguments arrives as a JSON string — the OpenAI format.">
<meta property="og:title" content="31 of 40 popular chat templates crash on OpenAI-style tool calls">
<meta property="og:description" content="Of 40 popular tool-calling chat templates that render dict arguments, 31 crash when arguments arrives as a JSON string — the OpenAI format.">
<meta property="og:image" content="https://huggingface.co/spaces/SamJoshua/chat-template-toolcall-leaderboard/resolve/main/thumbnail.png">
<meta property="og:type" content="article">
<meta property="og:url" content="https://samjoshua-chat-template-toolcall-leaderboard.hf.space/article.html">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="31 of 40 popular chat templates crash on OpenAI-style tool calls">
<meta name="twitter:description" content="Of 40 popular tool-calling chat templates that render dict arguments, 31 crash when arguments arrives as a JSON string — the OpenAI format.">
<meta name="twitter:image" content="https://huggingface.co/spaces/SamJoshua/chat-template-toolcall-leaderboard/resolve/main/thumbnail.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<style>
body.writeup {
max-width: 52rem;
}
.writeup .back {
margin: 0 0 0.65rem;
font-size: 0.92rem;
}
.writeup .hero {
display: block;
width: 100%;
height: auto;
border: 1px solid var(--line);
margin: 0 0 1.5rem;
background: var(--card);
}
.writeup .prose {
font-size: 1.02rem;
line-height: 1.65;
}
.writeup .prose h2 {
margin: 2.1rem 0 0.7rem;
font-size: 1.2rem;
}
.writeup .prose p { margin: 0 0 0.95rem; }
.writeup .prose ul, .writeup .prose ol {
margin: 0 0 1rem;
padding-left: 1.35rem;
}
.writeup .prose li { margin: 0.3rem 0; }
.writeup .prose li > p { margin: 0 0 0.4rem; }
.writeup .prose :not(pre) > code {
font-size: 0.86em;
background: #efe9dd;
padding: 0.08em 0.28em;
}
.writeup .prose pre {
background: #1c1917;
color: #f5f0e8;
padding: 0.9rem 1rem;
overflow-x: auto;
font-size: 0.8rem;
line-height: 1.45;
margin: 0.5rem 0 1.1rem;
}
.writeup .prose pre code {
background: transparent;
padding: 0;
font-size: inherit;
color: inherit;
}
.writeup .prose .table-wrap {
margin: 0 0 1.2rem;
}
.writeup .prose table {
min-width: 36rem;
font-size: 0.86rem;
}
.writeup .prose th {
cursor: default;
text-transform: none;
letter-spacing: 0;
font-size: 0.78rem;
white-space: nowrap;
}
.writeup .prose td { vertical-align: top; }
.writeup .prose td:nth-child(2) {
text-align: right;
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
/* First (summary) table has no numeric downloads column in col 2 if
the header is "count" — still right-align numeric-looking cells via markdown. */
.writeup .prose em { font-style: italic; }
.writeup footer .back-foot { margin-bottom: 0.4rem; }
</style>
</head>
<body class="writeup">
<header class="site">
<div class="brand">
<p class="kicker">CTT-Bench v1.0 · Write-up</p>
<p class="back"><a href="index.html">← Back to the leaderboard</a></p>
<h1>31 of 40 popular chat templates crash on OpenAI-style tool calls</h1>
</div>
<p class="meta">Measured 16 November 2026 · transformers 5.22.2 · 41 repos, 33 distinct templates</p>
</header>
<img class="hero" src="thumbnail.png" width="1200" height="630" alt="31 of 40 popular chat templates crash on OpenAI-style tool calls">
<article class="prose">
<p>Of 40 popular tool-calling chat templates that render dict arguments, 31 crash when <code>arguments</code> arrives as a JSON string — the OpenAI format you get from compatible APIs, logged traces, and many function-calling datasets. The same templates accept those arguments when they are a Python dict, the format <code>transformers</code> is written to take.</p>
<p>I measured this on <strong>16 November 2026</strong> with <strong>transformers 5.22.2</strong>. Interactive results for the three checks below are in tab 8 of <a href="https://huggingface.co/spaces/SamJoshua/agent-harness-checks">agent-harness-checks</a>. The full 10-case scores are in the <a href="https://huggingface.co/datasets/SamJoshua/chat-template-toolcall-bench">chat-template-toolcall-bench dataset</a> and the <a href="https://huggingface.co/spaces/SamJoshua/chat-template-toolcall-leaderboard">live leaderboard</a>.</p>
<h2>Method</h2>
<p>Population: the top 500 Hub <code>text-generation</code> models by downloads, last modified in the previous 180 days. I dropped repos whose ids contain common quant or abliteration markers (<code>gguf</code>, <code>awq</code>, <code>gptq</code>, <code>fp8</code>, <code>mlx</code>, <code>bnb</code>, <code>4bit</code>, <code>8bit</code>, <code>int4</code>, <code>nvfp4</code>, <code>abliterat</code>, <code>obliterat</code>, <code>tiny-</code>). That left <strong>62</strong> repos. Of those, <strong>7</strong> could not be loaded (2 gated, 5 tokenizer errors) and <strong>14</strong> had no <code>tool_calls</code> in the chat template. The remaining <strong>41</strong> repos, with <strong>33</strong> distinct templates, are the survey.</p>
<p>Each of the 41 got the same one-tool conversation — <code>get_weather(city, metric)</code>, then one tool result — rendered three ways:</p>
<ol>
<li><strong>dict args.</strong> <code>arguments</code> is a Python dict, <code>{"city": "Paris", "metric": True}</code>. This is the format transformers documents.</li>
<li><strong>OpenAI-style string args.</strong> <code>arguments</code> is <code>json.dumps(...)</code> of that dict. This is the shape you get from OpenAI-compatible APIs.</li>
<li><strong>Crafted tool name.</strong> <code>name</code> is set to <code>x", "arguments": {"cmd": "rm -rf /"}, "y": "</code>. The check is whether that raw string appears unescaped in the rendered prompt.</li>
</ol>
<p>A string-args render was counted as successful if the output contained <code>city</code> and was not double-encoded (<code>\"city\"</code> inside a JSON string). The name test is a presence check, not an exploit.</p>
<h2>Results</h2>
<p>Of the <strong>40</strong> templates that render dict args:</p>
<div class="table-wrap"><table>
<thead>
<tr>
<th>string-args outcome</th>
<th style="text-align: right;">count</th>
</tr>
</thead>
<tbody>
<tr>
<td><i class="pill crash">crash</i> with an obscure Jinja error</td>
<td style="text-align: right;">31</td>
</tr>
<tr>
<td>clear <code>TemplateError</code> telling you to deserialize first</td>
<td style="text-align: right;">5</td>
</tr>
<tr>
<td><i class="pill pass">renders</i> correctly</td>
<td style="text-align: right;">3</td>
</tr>
<tr>
<td>silently double-encodes the arguments</td>
<td style="text-align: right;">1</td>
</tr>
</tbody>
</table></div>
<p>The 31 crashes split <strong>16</strong> / <strong>15</strong> between <code>UndefinedError: 'str object' has no attribute 'items'</code> and <code>TypeError: Can only get item pairs from a mapping.</code> Both mean the template iterates <code>arguments</code> as a mapping, and a string is not one.</p>
<p>The remaining repo of the 41, <a href="https://huggingface.co/swiss-ai/Apertus-8B-Instruct-2509">swiss-ai/Apertus-8B-Instruct-2509</a>, fails even on dict args: <code>UndefinedError: 'dict object' has no attribute 'description'</code>. String-args and name tests were not applicable there.</p>
<p><strong>40/40</strong> templates that produced a prompt pasted the crafted tool name into the prompt verbatim. None escaped it.</p>
<p>The 5 clear errors are the useful failure mode. <a href="https://huggingface.co/LiquidAI/LFM2.5-350M">LiquidAI/LFM2.5-350M</a>, <a href="https://huggingface.co/LiquidAI/LFM2.5-1.2B-Instruct">LiquidAI/LFM2.5-1.2B-Instruct</a>, and <a href="https://huggingface.co/LiquidAI/LFM3-1.7B">LiquidAI/LFM3-1.7B</a> raise <code>TemplateError: Tool call arguments must be a mapping, got a JSON-encoded string: parse arguments with json.loads() before applying the chat template</code>. <a href="https://huggingface.co/farbodtavakkoli/OTel-2.0-LLM-31B-IT">farbodtavakkoli/OTel-2.0-LLM-31B-IT</a> and <a href="https://huggingface.co/org2ai/Wald-26B-A4B">org2ai/Wald-26B-A4B</a> say the same thing in slightly different words. <a href="https://huggingface.co/LiquidAI/LFM2.5-230M-Base">LiquidAI/LFM2.5-230M-Base</a>, in the same family, still crashes with <code>UndefinedError</code> — it ships a different template.</p>
<p>The 3 that render string args correctly are <a href="https://huggingface.co/laion/delphi-1e22-9_7Bparams-160Btokens-base-wc386k_lr1e5-sft">laion/delphi-1e22-9_7Bparams-160Btokens-base-wc386k_lr1e5-sft</a>, <a href="https://huggingface.co/trl-internal-testing/small-Qwen3ForCausalLM">trl-internal-testing/small-Qwen3ForCausalLM</a>, and <a href="https://huggingface.co/Vxtzq/Crowd-v1">Vxtzq/Crowd-v1</a>. The last two share a template.</p>
<p>The one silent failure, <a href="https://huggingface.co/JackKozmo29/depguard-jev-style-1.5b">JackKozmo29/depguard-jev-style-1.5b</a>, writes <code>"arguments": "{\"city\": \"Paris\", \"metric\": true}"</code> instead of a JSON object. There is no exception. The model just sees the wrong shape.</p>
<p>Downloads in the table below are the Hub's 30-day counters at scan time.</p>
<div class="table-wrap"><table>
<thead>
<tr>
<th>Repo</th>
<th style="text-align: right;">Hub 30-day downloads (16 Nov 2026)</th>
<th>dict args</th>
<th>string args</th>
<th>tool name</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://huggingface.co/zai-org/GLM-5.3">zai-org/GLM-5.3</a></td>
<td style="text-align: right;">1,761,619</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/ornith-ai/Ornith-1.0-35B">ornith-ai/Ornith-1.0-35B</a></td>
<td style="text-align: right;">1,477,670</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16">nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16</a></td>
<td style="text-align: right;">1,337,614</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/zai-org/GLM-5">zai-org/GLM-5</a></td>
<td style="text-align: right;">1,167,565</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/kindlingai/glm-5.3-exlr8-k2-k3-k4">kindlingai/glm-5.3-exlr8-k2-k3-k4</a></td>
<td style="text-align: right;">1,034,567</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/MiniMaxAI/MiniMax-M2.5">MiniMaxAI/MiniMax-M2.5</a></td>
<td style="text-align: right;">1,027,114</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-BF16">nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-BF16</a></td>
<td style="text-align: right;">1,017,410</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/openbmb/MiniCPM5-2B">openbmb/MiniCPM5-2B</a></td>
<td style="text-align: right;">1,016,762</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/tencent/Hy3">tencent/Hy3</a></td>
<td style="text-align: right;">996,249</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16">nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16</a></td>
<td style="text-align: right;">963,117</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-BF16">nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-BF16</a></td>
<td style="text-align: right;">871,937</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/farbodtavakkoli/OTel-2.0-LLM-31B-IT">farbodtavakkoli/OTel-2.0-LLM-31B-IT</a></td>
<td style="text-align: right;">866,862</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill clear">clear error</i> (deserialize first)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/ornith-ai/Ornith-1.0-9B">ornith-ai/Ornith-1.0-9B</a></td>
<td style="text-align: right;">822,705</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/poolside/Laguna-XS.2">poolside/Laguna-XS.2</a></td>
<td style="text-align: right;">731,033</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/poolside/Laguna-M.1">poolside/Laguna-M.1</a></td>
<td style="text-align: right;">694,749</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/poolside/Laguna-XS-2.1">poolside/Laguna-XS-2.1</a></td>
<td style="text-align: right;">587,106</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/ornith-ai/Ornith-1.5-9B">ornith-ai/Ornith-1.5-9B</a></td>
<td style="text-align: right;">570,396</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/poolside/Laguna-S-2.1">poolside/Laguna-S-2.1</a></td>
<td style="text-align: right;">488,183</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/ornith-ai/Ornith-1.5-122B">ornith-ai/Ornith-1.5-122B</a></td>
<td style="text-align: right;">341,712</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/ornith-ai/Ornith-1.5-35B-A3B">ornith-ai/Ornith-1.5-35B-A3B</a></td>
<td style="text-align: right;">318,548</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/zai-org/GLM-5.2">zai-org/GLM-5.2</a></td>
<td style="text-align: right;">309,982</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/ornith-ai/Ornith-1.5-397B">ornith-ai/Ornith-1.5-397B</a></td>
<td style="text-align: right;">276,441</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/MiniMaxAI/MiniMax-M2.7">MiniMaxAI/MiniMax-M2.7</a></td>
<td style="text-align: right;">225,319</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/openbmb/MiniCPM5-1B">openbmb/MiniCPM5-1B</a></td>
<td style="text-align: right;">222,748</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/LiquidAI/LFM2.5-230M-Base">LiquidAI/LFM2.5-230M-Base</a></td>
<td style="text-align: right;">221,201</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/swiss-ai/Apertus-8B-Instruct-2509">swiss-ai/Apertus-8B-Instruct-2509</a></td>
<td style="text-align: right;">191,142</td>
<td><i class="pill crash">crash</i> (tool schema; <a href="https://huggingface.co/swiss-ai/Apertus-8B-Instruct-2509/discussions/36">PR #36</a>)</td>
<td><i class="pill na">n/a</i></td>
<td><i class="pill na">n/a</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/ornith-ai/Ornith-1.0-397B">ornith-ai/Ornith-1.0-397B</a></td>
<td style="text-align: right;">186,647</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/laion/delphi-1e22-9_7Bparams-160Btokens-base-wc386k_lr1e5-sft">laion/delphi-1e22-9_7Bparams-160Btokens-base-wc386k_lr1e5-sft</a></td>
<td style="text-align: right;">173,649</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/LiquidAI/LFM2.5-350M">LiquidAI/LFM2.5-350M</a></td>
<td style="text-align: right;">159,463</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill clear">clear error</i> (deserialize first)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/alibiserikbay/JevK5">alibiserikbay/JevK5</a></td>
<td style="text-align: right;">138,159</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/allenai/Olmo-3-7B-Instruct">allenai/Olmo-3-7B-Instruct</a></td>
<td style="text-align: right;">131,479</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/trl-internal-testing/small-Qwen3ForCausalLM">trl-internal-testing/small-Qwen3ForCausalLM</a></td>
<td style="text-align: right;">114,585</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/empero-ai/Qwen3.8-4B-Distill">empero-ai/Qwen3.8-4B-Distill</a></td>
<td style="text-align: right;">112,428</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/MiniMaxAI/MiniMax-M2">MiniMaxAI/MiniMax-M2</a></td>
<td style="text-align: right;">110,173</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>UndefinedError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/LiquidAI/LFM2.5-1.2B-Instruct">LiquidAI/LFM2.5-1.2B-Instruct</a></td>
<td style="text-align: right;">105,811</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill clear">clear error</i> (deserialize first)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/LiquidAI/LFM3-1.7B">LiquidAI/LFM3-1.7B</a></td>
<td style="text-align: right;">103,744</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill clear">clear error</i> (deserialize first)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/org2ai/Wald-4B">org2ai/Wald-4B</a></td>
<td style="text-align: right;">95,972</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/JackKozmo29/depguard-jev-style-1.5b">JackKozmo29/depguard-jev-style-1.5b</a></td>
<td style="text-align: right;">92,977</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill double">double-encoded</i></td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/org2ai/Wald-26B-A4B">org2ai/Wald-26B-A4B</a></td>
<td style="text-align: right;">92,517</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill clear">clear error</i> (deserialize first)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/Vxtzq/Crowd-v1">Vxtzq/Crowd-v1</a></td>
<td style="text-align: right;">90,982</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill raw">verbatim</i></td>
</tr>
<tr>
<td><a href="https://huggingface.co/MemTensor/MemT-1.0-Nano">MemTensor/MemT-1.0-Nano</a></td>
<td style="text-align: right;">89,724</td>
<td><i class="pill pass">renders</i></td>
<td><i class="pill crash">crash</i> (<code>TypeError</code>)</td>
<td><i class="pill raw">verbatim</i></td>
</tr>
</tbody>
</table></div>
<h2>The 10-case bench</h2>
<p>The three checks above are cases C1 (dict args), C2 (string args), and C10 (tool-name escaping) of a 10-case suite run on the same 41 repos. The full scores are in the <a href="https://huggingface.co/datasets/SamJoshua/chat-template-toolcall-bench">chat-template-toolcall-bench dataset</a> and the <a href="https://huggingface.co/spaces/SamJoshua/chat-template-toolcall-leaderboard">live leaderboard</a>.</p>
<p>No template in this slice passes all 10 cases. The best score is <strong>9/10</strong>, on the same three repos that render string args correctly. They still fail C10: <strong>0 of 40</strong> templates that produced a prompt escaped the tool name. <a href="https://huggingface.co/swiss-ai/Apertus-8B-Instruct-2509">swiss-ai/Apertus-8B-Instruct-2509</a> fails every case, including the dict-args baseline.</p>
<p>Interactive results for the original three-check survey remain in <a href="https://huggingface.co/spaces/SamJoshua/agent-harness-checks">tab 8 of agent-harness-checks</a>.</p>
<h2>Why this matters for agent builders and SFT</h2>
<p>This is a compatibility issue, not a claim that the models are broken. <code>transformers</code> wants a dict. The problem is that a lot of real traffic is not a dict.</p>
<p>In an agent loop the first turn can look fine, because there is not yet a tool call in the history. Then the model emits a call, the API or the logger stores <code>arguments</code> as a string, and the next <code>apply_chat_template</code> raises. What the user sees is a harness exception, not a bad model answer.</p>
<p>SFT pipelines have the same footgun. Function-calling traces and many public datasets are in OpenAI format. If you tokenize them with <code>apply_chat_template</code> and a crashing template, those rows disappear or abort the job. You either train on a quiet subset or you write a one-off workaround that only some templates need. Double-encoding is worse in a different way: the job succeeds, and the model is taught to treat arguments as a stringified JSON string.</p>
<p>The name result is a separate issue. If a model can be induced to emit a tool name that contains quotes, and you write that turn into history, the next render can forge structure inside a JSON-style tool-call block. XML-style tags are less exposed. "Verbatim" here only means the raw name appears unescaped. Whether that breaks the structure depends on the format around it.</p>
<h2>Two harness rules</h2>
<ol>
<li>
<p><strong><code>json.loads</code> every <code>tool_calls[].function.arguments</code> before you template</strong> — and before you run SFT on OpenAI-format traces. If the value is already a dict, leave it. This is the difference between the 31 crashes and a clean render, and it is also what the 5 clear <code>TemplateError</code>s tell you to do.</p>
</li>
<li>
<p><strong>Reject any tool call whose <code>name</code> is not one of your declared tools before you write it into history.</strong> Do not wait for the template to escape it. In this survey, 40/40 templates that rendered a name did not.</p>
</li>
</ol>
<h2>Reproduce</h2>
<p>This is the string-args check for one repo, using the same conversation as the survey. Swap the repo id to try another. <code>openbmb/MiniCPM5-2B</code> is one of the 31 that crash.</p>
<pre><code class="language-python">import json
from transformers import AutoTokenizer
repo = &quot;openbmb/MiniCPM5-2B&quot;
tok = AutoTokenizer.from_pretrained(repo)
tools = [{
&quot;type&quot;: &quot;function&quot;,
&quot;function&quot;: {
&quot;name&quot;: &quot;get_weather&quot;,
&quot;description&quot;: &quot;Get weather&quot;,
&quot;parameters&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
&quot;city&quot;: {&quot;type&quot;: &quot;string&quot;, &quot;description&quot;: &quot;City&quot;},
&quot;metric&quot;: {&quot;type&quot;: &quot;boolean&quot;, &quot;description&quot;: &quot;Metric units&quot;},
},
&quot;required&quot;: [&quot;city&quot;],
},
},
}]
def messages(args, name=&quot;get_weather&quot;):
return [
{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Weather in Paris?&quot;},
{
&quot;role&quot;: &quot;assistant&quot;,
&quot;content&quot;: &quot;&quot;,
&quot;tool_calls&quot;: [{
&quot;id&quot;: &quot;c1&quot;,
&quot;type&quot;: &quot;function&quot;,
&quot;function&quot;: {&quot;name&quot;: name, &quot;arguments&quot;: args},
}],
},
{
&quot;role&quot;: &quot;tool&quot;,
&quot;tool_call_id&quot;: &quot;c1&quot;,
&quot;name&quot;: &quot;get_weather&quot;,
&quot;content&quot;: '{&quot;temp&quot;: 21}',
},
]
args_dict = {&quot;city&quot;: &quot;Paris&quot;, &quot;metric&quot;: True}
args_str = json.dumps(args_dict)
print(&quot;dict args:&quot;)
tok.apply_chat_template(messages(args_dict), tools=tools, tokenize=False)
print(&quot;ok&quot;)
print(&quot;string args:&quot;)
try:
tok.apply_chat_template(messages(args_str), tools=tools, tokenize=False)
print(&quot;ok&quot;)
except Exception as e:
print(type(e).__name__, e)
print(&quot;string args after json.loads:&quot;)
tok.apply_chat_template(messages(json.loads(args_str)), tools=tools, tokenize=False)
print(&quot;ok&quot;)
</code></pre>
<p>On MiniCPM5-2B the middle call raises <code>UndefinedError: 'str object' has no attribute 'items'</code>. After <code>json.loads</code>, it renders.</p>
<h2>Earlier reports</h2>
<p>These are earlier, per-repo reports of the same classes of bug. The official Qwen3.8-27B and Granite 4.1-3b repos are not in this 41-repo slice; they are cited only as prior reports. MiniCPM5-2B and Apertus-8B are in the slice.</p>
<ul>
<li><a href="https://huggingface.co/Qwen/Qwen3.8-27B/discussions/240">Qwen/Qwen3.8-27B discussion #240</a> — the official Qwen3.8-27B template crashes with <code>|items</code> when <code>arguments</code> is a JSON string. That official repo is not in this slice. The same class of failure, <code>UndefinedError: 'str object' has no attribute 'items'</code>, is 16 of the 31 crashes here.</li>
<li><a href="https://huggingface.co/openbmb/MiniCPM5-2B/discussions/30">openbmb/MiniCPM5-2B discussion #30</a> — string <code>arguments</code> crash, plus a separate issue where non-string values can be written as Python repr. MiniCPM5-2B is in this survey and crashes with <code>UndefinedError</code> on string args. This survey did not re-test Python repr.</li>
<li><a href="https://huggingface.co/ibm-granite/granite-4.1-3b/discussions/7">ibm-granite/granite-4.1-3b discussion #7</a> — unescaped <code>tool_call.name</code> concatenated into JSON. That official repo is not in this slice. This survey found that 40/40 templates that rendered a name pasted it verbatim.</li>
<li><a href="https://huggingface.co/swiss-ai/Apertus-8B-Instruct-2509/discussions/36">swiss-ai/Apertus-8B-Instruct-2509 PR #36</a> — a PR to sync <code>chat_template.jinja</code> with vLLM's Apertus tool template so tools render in transformers. In this survey, Apertus is the one repo of 41 that fails on dict args.</li>
</ul>
<h2>Caveats</h2>
<ul>
<li>A crash on string args is a template compatibility issue with OpenAI-format messages. It is not, by itself, evidence that the model cannot call tools.</li>
<li>The 41 are repos, not unique templates. <strong>33</strong> distinct template hashes appear among them, so some families are counted more than once.</li>
<li>"Renders correctly" on string args is a heuristic: the output contains <code>city</code> and is not double-encoded. I did not parse every prompt back into structured tool calls.</li>
<li>"Verbatim" on the name test means the crafted string appears unescaped. Impact depends on whether the template embeds the name in JSON or in XML-style tags.</li>
<li>The quant filter is substring-based and incomplete. At least one quant-named repo, <code>ThorOdinson246/nl2sh-1.5b-Q4_K_M</code>, passed the filter and then failed to load.</li>
<li>The 14 repos with no <code>tool_calls</code> in the template were excluded. That does not mean those models have no other tool-use path.</li>
<li>Snapshot: 16 November 2026, transformers 5.22.2. Templates change. Downloads are the Hub 30-day counters at that time.</li>
<li>This survey does not cover other template bugs, including Python-repr of non-string values.</li>
</ul>
<p>The same three-check table is in <a href="https://huggingface.co/spaces/SamJoshua/agent-harness-checks">tab 8 of agent-harness-checks</a>. The 10-case scores are in the <a href="https://huggingface.co/datasets/SamJoshua/chat-template-toolcall-bench">dataset</a> and the <a href="https://huggingface.co/spaces/SamJoshua/chat-template-toolcall-leaderboard">leaderboard</a>.</p>
<p><em>Sam Joshua (<a href="https://huggingface.co/SamJoshua">@SamJoshua</a> · <a href="https://x.com/SAM_JOSHUA_S">@SAM_JOSHUA_S</a>)</em></p>
</article>
<footer>
<p class="back-foot"><a href="index.html">← Back to the leaderboard</a></p>
<p>Dataset: <a href="https://huggingface.co/datasets/SamJoshua/chat-template-toolcall-bench">SamJoshua/chat-template-toolcall-bench</a>
· Author: <a href="https://huggingface.co/SamJoshua">Sam Joshua</a>
· <a href="https://x.com/SAM_JOSHUA_S">@SAM_JOSHUA_S</a>
· Apache-2.0</p>
</footer>
</body>
</html>