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");