Private
Public Access
1
0

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:
Catherine Renelle
2026-02-11 21:26:32 -05:00
parent 8e342045eb
commit 8a295c48dd
+3 -1
View File
@@ -248,7 +248,9 @@ public class ChatService : IChatService
} }
else 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 // 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 // AND there are no prior tool results AND no page context data, it