From d2a165d56d7eb06ac8a9311e39bd3ce4e5f4d0b4 Mon Sep 17 00:00:00 2001 From: Nunze Date: Wed, 21 Oct 2026 08:25:10 +0200 Subject: [PATCH] jinja: the caps probe hands the template an empty tools array, not [null] -- GLM-5.3's template iterated it and lost string content json{nullptr} is the one-element array [null], not an empty one. The string-content probe passed it as `tools`; GLM-5.3's template iterates `tools` under `{% if tools %}`, so the probe's render threw on the null element, the throw was taken for "cannot render string content", and with typed content unsupported as well every request logged `render_message_to_json: Neither string content nor typed content is supported`. llama.cpp master passes json::array() (PR #27130); so does this probe now. The GLM-shaped template in chat_test asserts string content. Co-Authored-By: Claude Fable 5.1 --- tests/chat_test.cpp | 3 +++ vendor/llama/common/jinja/caps.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/chat_test.cpp b/tests/chat_test.cpp index df154adb..5a2bd8db 100644 --- a/tests/chat_test.cpp +++ b/tests/chat_test.cpp @@ -1032,6 +1032,9 @@ TEST(a_dotted_integer_is_an_index_as_in_jinja2) { "{%- if add_generation_prompt %}{% endif %}", "", "")); CHECK(glm.caps().tools); CHECK(glm.caps().tool_calls); + /* The string-content probe hands the template an empty tools array, not [null]: this + * template iterates `tools`, threw on the null, and lost string content. */ + CHECK(glm.caps().string_content); ChatTemplate first; CHECK_OK(first.load("{{ messages.0.content }}|{{ messages.1.role }}", "", "")); diff --git a/vendor/llama/common/jinja/caps.cpp b/vendor/llama/common/jinja/caps.cpp index ead86476..ae9e0c95 100644 --- a/vendor/llama/common/jinja/caps.cpp +++ b/vendor/llama/common/jinja/caps.cpp @@ -110,8 +110,10 @@ caps caps_get(jinja::program & prog) { }); }, [&]() { - // tools - return json{nullptr}; + // tools: an empty array, as llama.cpp master hands it. json{nullptr} is the one-element + // array [null]; a template that iterates `tools` (GLM-5.3's does) threw on the null + // and the probe took the throw for "cannot render string content". + return json::array(); }, [&](bool success, value & messages, value &) { auto & content = messages->at(0)->at("content");