diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs index e18f53372..15500ee5a 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs @@ -32,8 +32,6 @@ public async Task SendMessage(string agentId, message.SenderId = _user.Id; } - _storage.Append(_conversationId, message); - var conv = _services.GetRequiredService(); var dialogs = conv.GetDialogHistory(); @@ -72,6 +70,12 @@ public async Task SendMessage(string agentId, } } + // Persist to storage + _storage.Append(_conversationId, message); + + // Add to thread + dialogs.Add(message); + if (!stopCompletion) { // Routing with reasoning