Moved the rollback rules into the chat thread

This commit is contained in:
Thorsten Sommer committed 2026-09-23 09:36:02 +02:00
1 parent 7695863201
commit 6e559145ef
2 files changed
+27 -16

No files matched your search

@@ -1463,21 +1463,11 @@ public partial class ChatComponent : MSGComponentBase
if (this.ChatThread is null || this.IsCurrentChatStreaming)
return;
if (!this.ChatThread.RemoveBlocksAfter(aiBlock))
// Which parts of the thread a rollback resets and which it keeps is documented at RollBackTo:
if (!this.ChatThread.RollBackTo(aiBlock))
return;
//
// Only the working state of the next turn is reset here: the augmented data and the
// AI-selected data sources are rebuilt by the RAG process anyway, so carrying the ones of a
// removed message over would just put stale context into the system prompt.
//
// What stays is everything the thread ratchets for security reasons, namely DataSecurity and
// RequiredProviderConfidence. Both only ever tighten, because the data which raised them was
// seen by this thread. Removing the message that brought it in does not unsee it, so the
// chat keeps demanding the same of every provider which continues it.
//
this.ChatThread.AugmentedData = string.Empty;
this.ChatThread.AISelectedDataSources = [];
// The rollback reset the AI-selected data sources, which the data source selection still shows:
this.dataSourceSelectionComponent?.ChangeOptionWithoutSaving(this.ChatThread.DataSourceOptions, this.ChatThread.AISelectedDataSources);
this.hasUnsavedChanges = true;
await this.SaveThread();