From 06d0b398fc9cd573a033dd4a50beca93c70fe79a Mon Sep 17 00:00:00 2001 From: Haiping Chen <101423@smsassist.com> Date: Mon, 30 Sep 2024 15:33:14 -0500 Subject: [PATCH] reload agent in case it has been changed by hook --- .../Services/ConversationService.SendMessage.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs index 13e8edf1..610c1ab4 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs @@ -74,6 +74,12 @@ public partial class ConversationService // Routing with reasoning var settings = _services.GetRequiredService(); + // reload agent in case it has been changed by hook + if (message.CurrentAgentId != agent.Id) + { + agent = await agentService.LoadAgent(message.CurrentAgentId); + } + if (agent.Type == AgentType.Routing) { response = await routing.InstructLoop(message, dialogs);