Handle empty string AI responses as fallback
The null-coalescing operator only caught null, not empty/whitespace responses. When Ollama returns empty content (common when the model hesitates between tool calling and text), the empty string was saved as the assistant message. Now uses IsNullOrWhiteSpace to catch both. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -248,7 +248,9 @@ public class ChatService : IChatService
|
||||
}
|
||||
else
|
||||
{
|
||||
var rawContent = response?.Message?.Content ?? "I'm sorry, I couldn't process that request.";
|
||||
var rawContent = string.IsNullOrWhiteSpace(response?.Message?.Content)
|
||||
? "I'm sorry, I couldn't process that request."
|
||||
: response!.Message!.Content;
|
||||
|
||||
// If the model responded without calling any tools on the first attempt
|
||||
// AND there are no prior tool results AND no page context data, it
|
||||
|
||||
Reference in New Issue
Block a user