From 486155fb5b7a503474dab9b9fec79547752a4114 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 Aug 2025 18:43:34 +0000 Subject: [PATCH 1/2] Initial plan From b3c4883b051735c818880b6faa65ecbf06232715 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 Aug 2025 19:00:45 +0000 Subject: [PATCH 2/2] Fix thinking detection logic for Hermes 2 Pro function to handle diverse template patterns Co-authored-by: ExtReMLapin <3909752+ExtReMLapin@users.noreply.github.com> --- common/chat.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/chat.cpp b/common/chat.cpp index 23a446da91655..e968dee07561a 100644 --- a/common/chat.cpp +++ b/common/chat.cpp @@ -1767,9 +1767,14 @@ static common_chat_params common_chat_params_init_hermes_2_pro(const common_chat } if (!inputs.tools.is_null()) { - auto supports_thinking = tmpl.source().find("") != std::string::npos; - // you should not be able to call enable_thinking if is not supported - GGML_ASSERT(!extra_context["enable_thinking"] || extra_context["enable_thinking"] == supports_thinking); + auto supports_thinking = tmpl.source().find("") != std::string::npos || + tmpl.source().find("'\\n'") != std::string::npos || + tmpl.source().find("\"\\n\"") != std::string::npos; + + // If the template doesn't support thinking, disable thinking regardless of the input setting + if (!supports_thinking && extra_context["enable_thinking"]) { + extra_context["enable_thinking"] = false; + } // (content)?({"name": "foo", "arguments": {"a": 1}})* data.grammar_lazy = true; data.grammar = build_grammar([&](const common_grammar_builder & builder) {