diff --git a/src/llm/deepseek.rs b/src/llm/deepseek.rs index 4214187..30677cf 100644 --- a/src/llm/deepseek.rs +++ b/src/llm/deepseek.rs @@ -242,8 +242,21 @@ impl DeepSeekClient { result.choices .into_iter() .next() - .map(|c| c.message.content.trim().to_string()) - .ok_or_else(|| anyhow::anyhow!("No response from DeepSeek")) + .map(|c| { + let content = c.message.content.trim().to_string(); + if content.is_empty() { + c.reasoning_content + .map(|r| r.trim().to_string()) + .unwrap_or_default() + } else { + content + } + }) + .filter(|s| !s.is_empty()) + .ok_or_else(|| anyhow::anyhow!( + "No response from DeepSeek. \ + If thinking mode is enabled, try disabling it or ensure the model supports it." + )) } } diff --git a/src/llm/kimi.rs b/src/llm/kimi.rs index 08610a6..41c34b9 100644 --- a/src/llm/kimi.rs +++ b/src/llm/kimi.rs @@ -242,8 +242,21 @@ impl KimiClient { result.choices .into_iter() .next() - .map(|c| c.message.content.trim().to_string()) - .ok_or_else(|| anyhow::anyhow!("No response from Kimi")) + .map(|c| { + let content = c.message.content.trim().to_string(); + if content.is_empty() { + c.reasoning_content + .map(|r| r.trim().to_string()) + .unwrap_or_default() + } else { + content + } + }) + .filter(|s| !s.is_empty()) + .ok_or_else(|| anyhow::anyhow!( + "No response from Kimi. \ + If thinking mode is enabled, try disabling it or ensure the model supports it." + )) } } diff --git a/src/llm/mod.rs b/src/llm/mod.rs index 2b05430..810e4bc 100644 --- a/src/llm/mod.rs +++ b/src/llm/mod.rs @@ -211,10 +211,21 @@ impl LlmClient { /// Parse commit response from LLM fn parse_commit_response(&self, response: &str, format: crate::config::CommitFormat) -> Result { - let lines: Vec<&str> = response.lines().collect(); - + let lines: Vec<&str> = response.lines() + .map(|l| l.trim()) + .filter(|l| !l.is_empty()) + .collect(); + if lines.is_empty() { - bail!("Empty response from LLM"); + let preview: String = response.chars().take(200).collect(); + bail!( + "LLM returned empty or whitespace-only response. \ + Raw response preview: '{}'. \ + Hint: If using DeepSeek/Kimi with thinking enabled, \ + the model may have returned reasoning_content only. \ + Try disabling thinking mode or switching models.", + preview + ); } let first_line = lines[0];