From b7d468ee13a027a7cf1d7043bab19bba151f631f Mon Sep 17 00:00:00 2001 From: Jakob Michael Werner Date: Fri, 17 Apr 2026 03:15:49 -0500 Subject: [PATCH] fix: disable thinking in analyze-prompt for Haiku compatibility When Claude Code has alwaysThinkingEnabled: true in settings.json, the SDK enables thinking mode globally and the analyze-prompt hook fails with a 400 error because Haiku does not support thinking. Set maxThinkingTokens: 0 in the query options so the user setting does not apply to analysis queries. Analysis only emits a JSON response, so thinking is not needed regardless of model. Fixes #6 Co-Authored-By: Claude Opus 4.7 --- src/lib/prompt-analyzer.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/prompt-analyzer.ts b/src/lib/prompt-analyzer.ts index 4d716cc..d6f1938 100644 --- a/src/lib/prompt-analyzer.ts +++ b/src/lib/prompt-analyzer.ts @@ -355,11 +355,16 @@ Respond with JSON only, no explanation.`; const tempAnalysisDir = getTempDirectoryPath('PROMPT_ANALYSIS'); await fs.mkdir(tempAnalysisDir, { recursive: true }).catch(() => {}); - // Simplified options - optimize for speed in hook mode + // Simplified options - optimize for speed in hook mode. + // maxThinkingTokens: 0 disables thinking regardless of the user's Claude + // Code settings (e.g. alwaysThinkingEnabled). Haiku does not support + // thinking, so without this the API returns 400 when the global setting + // is on. Analysis does not need thinking anyway; it only emits JSON. const queryOptions = { maxTurns: 1, // Single turn only model: selectedModel, // Use selected model (haiku by default) disallowedTools: ['*'], // No tools needed for JSON response + maxThinkingTokens: 0, // Required for Haiku compatibility cwd: tempAnalysisDir // Use temp directory to isolate analysis sessions };