From 7b74f49761aa090b0287a192e07c5cde75233db1 Mon Sep 17 00:00:00 2001 From: Bryce M <52695653+bmage8923@users.noreply.github.com> Date: Tue, 19 May 2026 12:49:53 -0600 Subject: [PATCH] fix(hooks): RepeatDetection injects warning via stdout, not stderr+exit 2 RepeatDetection.hook.ts is a UserPromptSubmit hook. On a >=60% similarity match it called process.stderr.write() then process.exit(2). For UserPromptSubmit hooks, exit code 2 blocks AND erases the prompt, and routes stderr to the user only -- the model never receives the message. So the repeat-detection warning the hook is meant to inject into the model's context never arrives, and the user's resent message is silently dropped. The correct channel for UserPromptSubmit context injection is exit 0 with the text on stdout: stdout is appended to the model's context and the prompt proceeds normally. Swaps process.stderr.write -> process.stdout.write and process.exit(2) -> process.exit(0) in the trigger branch. Detection logic (threshold, tokenizer, trigrams) is unchanged. --- Releases/v5.0.0/.claude/hooks/RepeatDetection.hook.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Releases/v5.0.0/.claude/hooks/RepeatDetection.hook.ts b/Releases/v5.0.0/.claude/hooks/RepeatDetection.hook.ts index a1882efc6e..9539a81b3f 100755 --- a/Releases/v5.0.0/.claude/hooks/RepeatDetection.hook.ts +++ b/Releases/v5.0.0/.claude/hooks/RepeatDetection.hook.ts @@ -106,15 +106,18 @@ function main(): void { // Threshold: 0.6 (60%) similarity triggers warning if (similarity >= 0.6) { - // Output warning to stderr — this gets injected into model context - process.stderr.write( + // Inject the warning into the model's context WITHOUT blocking the prompt. + // On a UserPromptSubmit hook, exit 0 + stdout is appended to the model's + // context and the user's message still goes through. Exit 2 would instead + // ERASE the prompt and route stderr to the user only — the model would + // never see the message, which defeats the purpose of this hook. + process.stdout.write( `⚠️ REPEAT DETECTION: This message is ${Math.round(similarity * 100)}% similar to the previous message. ` + `The user is likely REPEATING a request you missed. ` + `STOP. Re-read their message carefully. Do NOT proceed with what you were doing before. ` + `Address their ACTUAL request this time.`, ); - // Exit 2 = blocking error, stderr fed to Claude - process.exit(2); + process.exit(0); } process.exit(0);