diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs index 455a23a02..a58b83947 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs @@ -38,6 +38,7 @@ public class ConversationStateService : IConversationStateService /// States in the previous rounds of conversation /// private ConversationState _historyStates; + private bool _isReadOnly; public ConversationStateService( IServiceProvider services, @@ -153,7 +154,8 @@ public IConversationStateService SetState(string name, T value, bool isNeedVe public async Task> Load(string conversationId, bool isReadOnly = false) { - _conversationId = !isReadOnly ? conversationId : null; + _isReadOnly = isReadOnly; + _conversationId = conversationId; Reset(); var endNodes = new Dictionary(); @@ -232,7 +234,7 @@ public async Task> Load(string conversationId, bool i public async Task Save() { - if (_conversationId == null || _sidecar?.IsEnabled == true) + if (_conversationId == null || _sidecar?.IsEnabled == true || _isReadOnly) { return; }