diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationSideCar.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationSideCar.cs index 569555c2..8dab52e1 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationSideCar.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationSideCar.cs @@ -7,5 +7,5 @@ public interface IConversationSideCar List GetConversationDialogs(string conversationId); void UpdateConversationBreakpoint(string conversationId, ConversationBreakpoint breakpoint); ConversationBreakpoint? GetConversationBreakpoint(string conversationId); - Task Execute(string conversationId, string agentId, string text, PostbackMessageModel? postback = null, List? states = null); + Task Execute(string agentId, string text, PostbackMessageModel? postback = null, List? states = null); } diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingContext.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingContext.cs index 854832c6..f75e8e0e 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingContext.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingContext.cs @@ -21,7 +21,7 @@ public interface IRoutingContext int CurrentRecursionDepth { get; } int GetRecursiveCounter(); - int IncreaseRecursiveCounter(); + void IncreaseRecursiveCounter(); void SetRecursiveCounter(int counter); void ResetRecursiveCounter(); diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationSideCar.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationSideCar.cs index 903b8ee0..ae72fbdb 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationSideCar.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationSideCar.cs @@ -80,7 +80,7 @@ public class ConversationSideCar : IConversationSideCar } } - public async Task Execute(string conversationId, string agentId, string text, + public async Task Execute(string agentId, string text, PostbackMessageModel? postback = null, List? states = null) { BeforeExecute(); diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs index f6c146a8..8ee4c662 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs @@ -394,7 +394,9 @@ public class ConversationStateService : IConversationStateService, IDisposable public void SetCurrentState(ConversationState state) { - _curStates = state; + var values = _curStates.Values.ToList(); + var copy = JsonSerializer.Deserialize>(JsonSerializer.Serialize(values)); + _curStates = new ConversationState(copy ?? new()); } public void ResetCurrentState() diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs index 3450d41e..5c1f1903 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs @@ -214,9 +214,9 @@ public class RoutingContext : IRoutingContext return _currentRecursionDepth; } - public int IncreaseRecursiveCounter() + public void IncreaseRecursiveCounter() { - return _currentRecursionDepth; + _currentRecursionDepth++; } public void SetRecursiveCounter(int counter)