From a9974ac18fbdf2cb40462bf29a5feed9b2d1ad1a Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Mon, 14 Sep 2026 11:07:34 +0200 Subject: [PATCH] Keep regenerating an answer working when the chat holds no question of its own --- .../Components/ChatComponent.razor.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/MindWork AI Studio/Components/ChatComponent.razor.cs b/app/MindWork AI Studio/Components/ChatComponent.razor.cs index 7c50940c..9ffe4b5b 100644 --- a/app/MindWork AI Studio/Components/ChatComponent.razor.cs +++ b/app/MindWork AI Studio/Components/ChatComponent.razor.cs @@ -1025,7 +1025,16 @@ public partial class ChatComponent : MSGComponentBase } } else - lastUserPrompt = this.ChatThread.Blocks.Last(x => x.Role is ChatRole.USER).Content; + { + // + // Regenerating asks again with the prompt that led to this answer. A thread which never + // carried one -- a chat template whose example conversation holds AI blocks only -- has + // nothing to reuse here. That is no reason to fail: the thread itself is what the model + // is given, and everything downstream already reads a missing prompt as "no data source + // lookup, just answer again". + // + lastUserPrompt = this.ChatThread.Blocks.LastOrDefault(x => x.Role is ChatRole.USER)?.Content; + } // // Add the AI response to the thread: