From 7f86616b6169e53a796cf70b03a357c39e964d47 Mon Sep 17 00:00:00 2001 From: Hamed Shams Date: Mon, 19 Oct 2026 17:15:58 +0300 Subject: [PATCH] fix: say which check found the Chain-of-Thought prefix (#489) --- src/heretic/main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/heretic/main.py b/src/heretic/main.py index dd5e521..8c2ee9d 100644 --- a/src/heretic/main.py +++ b/src/heretic/main.py @@ -487,7 +487,7 @@ def run(): print(f"* [bold]{len(response_prefix_test_prompts)}[/] prompts loaded") print() - print("Checking for common response prefix...") + print("Checking chat template for a Chain-of-Thought initializer...") # Detect if the model's chat template inserts a reasoning tag on its own # at the end of user's prompt (e.g. ) by using a dummy prompt. @@ -518,18 +518,26 @@ def run(): # We use only the closed CoT block here. Any whitespaces # will be handled by the 'Rechecking with prefix' logic below. settings.response_prefix = closed_cot_block + print( + f"* Chat template inserts [bold]{escape(repr(cot_initializer))}[/]" + ) print( f"* Closed Chain-of-Thought block: [bold]{escape(repr(settings.response_prefix))}[/]" ) cot_skip_applied = True break + if not cot_skip_applied: + print("* None found") + # Fallback to inference for models like mistral-3 which are specifically # instructed to generate thinking tags using the system prompt in their # chat template, instead of inserting a prefix tag (e.g. ) at # the end of user prompt like the case above. We expect the model to # generate those tags. if settings.response_prefix is None: + print() + print("Checking for common response prefix...") responses = model.get_responses_batched(response_prefix_test_prompts) # Despite being located in os.path, commonprefix actually performs