File size: 6,985 Bytes
385fef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>CTT-Bench — chat-template tool-call compatibility</title>
  <meta name="description" content="Leaderboard of 41 popular tool-calling chat templates on 10 apply_chat_template cases. A compatibility bench, not a model-quality score.">
  <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>
    .writeup-cta {
      display: block;
      margin: 0 0 1.25rem;
      padding: 0.85rem 1rem;
      background: var(--card);
      border: 1px solid var(--line);
      border-left: 4px solid var(--accent);
      box-shadow: var(--shadow);
      font-size: 0.95rem;
    }
    .writeup-cta a { font-weight: 600; text-decoration: none; }
    .writeup-cta a:hover { text-decoration: underline; }
  </style>
</head>
<body>
  <header class="site">
    <div class="brand">
      <p class="kicker">CTT-Bench v1.0</p>
      <h1>Chat-template tool-call compatibility</h1>
      <p class="lede">Does a published chat template survive the tool-call shapes that harnesses actually feed it? This is a spec-compatibility table, not a model-quality ranking.</p>
    </div>
    <p class="meta">Measured 16 Nov 2026, 22:16 IST · transformers 5.22.2 · 41 repos, 33 distinct templates, 10 cases</p>
  </header>

  <p class="writeup-cta"><a href="article.html">Read the write-up</a> — 31 of 40 popular chat templates crash on OpenAI-style tool calls.</p>

  <aside class="caveat" role="note">
    <strong>Caveat.</strong> A crash — or a clear <code>TemplateError</code> — when <code>arguments</code> is a JSON string is a chat-template compatibility issue, not a model bug. transformers documents arguments as a mapping. This bench still scores the OpenAI-style string because that is what APIs, traces, and many datasets produce.
  </aside>

  <section class="stats" id="stats" aria-label="Headline numbers"></section>

  <section class="legend" aria-label="Status key">
    <span><i class="pill pass">pass</i> rendered correctly</span>
    <span><i class="pill crash">crash</i> obscure Jinja / TypeError</span>
    <span><i class="pill clear">clear</i> honest “deserialize first” error</span>
    <span><i class="pill double">double</i> silently double-encoded</span>
    <span><i class="pill raw">verbatim</i> tool name pasted unescaped</span>
  </section>

  <section class="controls">
    <label class="search">
      <span class="sr">Search repos</span>
      <input type="search" id="q" placeholder="Filter by repo or hash" autocomplete="off">
    </label>
    <label class="check"><input type="checkbox" id="unique"> Unique templates only</label>
    <p class="showing" id="showing"></p>
  </section>

  <div class="table-wrap">
    <table id="board">
      <thead id="head"></thead>
      <tbody id="body"></tbody>
    </table>
  </div>
  <p class="hint">Click a row for the error or the rendered snippet. Click a header to sort.</p>

  <section class="cases" id="cases">
    <h2>The ten cases</h2>
    <div class="case-grid" id="case-grid"></div>
  </section>

  <section class="repro" id="repro">
    <h2>How to reproduce</h2>
    <p>The runner ships with the dataset. To re-score the same 41 repos:</p>
    <pre><code>pip install transformers==5.22.2
python scan.py --repos repos.json --out-dir .</code></pre>
    <p>Or one OpenAI-style string call, the case most templates fail (C2):</p>
    <div class="pre-wrap">
      <button type="button" class="copy" id="copy-c2">Copy</button>
      <pre><code id="c2-snippet">import json
from transformers import AutoTokenizer

tok = AutoTokenizer.from_pretrained("openbmb/MiniCPM5-2B")
tools = [{"type": "function", "function": {
    "name": "get_weather", "description": "Get weather",
    "parameters": {"type": "object", "properties": {
        "city": {"type": "string", "description": "City"},
        "metric": {"type": "boolean", "description": "Metric units"},
    }, "required": ["city"]},
}}]
messages = [
    {"role": "user", "content": "Weather in Paris?"},
    {"role": "assistant", "content": "", "tool_calls": [{
        "id": "c1", "type": "function",
        "function": {"name": "get_weather",
                     "arguments": json.dumps({"city": "Paris", "metric": True})},
    }]},
    {"role": "tool", "tool_call_id": "c1", "name": "get_weather",
     "content": '{"temp": 21}'},
]
print(tok.apply_chat_template(messages, tools=tools, tokenize=False))</code></pre>
    </div>
    <p>On many popular templates that raises <code>UndefinedError: 'str object' has no attribute 'items'</code> or <code>TypeError: Can only get item pairs from a mapping</code>. Passing a dict instead of the string is the documented shape (case C1) and usually works. In a harness, <code>json.loads</code> every <code>arguments</code> value before you template, and reject a tool name that is not in your declared list before you write it into history.</p>
  </section>

  <section class="method">
    <h2>Method, in brief</h2>
    <p>Population: top 500 <code>text-generation</code> models by Hub downloads, updated in the last 180 days, minus quants, abliterated forks, and tiny test repos, keeping those whose chat template references <code>tool_calls</code>. That leaves 41 repos (33 distinct template hashes). Scoring uses <code>tokenizer.apply_chat_template(..., tokenize=False)</code> only — no weights, no generation. Markers and snippets are taken from the post-user region of the prompt so a name that already appears in the tool schema is not counted as a successful call.</p>
    <p>A <span class="pill clear">clear</span> error is not a pass. It is a better failure mode than a crash, but it is still not OpenAI-string compatible. No template in this snapshot passes all 10 cases; the best score is 9/10, failing only tool-name escaping.</p>
    <p>Related reports: <a href="https://huggingface.co/Qwen/Qwen3.8-27B/discussions/240">Qwen #240</a>, <a href="https://huggingface.co/openbmb/MiniCPM5-2B/discussions/30">MiniCPM5 #30</a>, <a href="https://huggingface.co/ibm-granite/granite-4.1-3b/discussions/7">Granite #7</a>, <a href="https://huggingface.co/swiss-ai/Apertus-8B-Instruct-2509/discussions/36">Apertus PR #36</a>.</p>
  </section>

  <footer>
    <p><a href="article.html">Read the write-up</a>
      · 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>

  <script type="module" src="app.js"></script>
</body>
</html>