Skip to content

Commit 06d0b39

Browse files
author
Haiping Chen
committed
reload agent in case it has been changed by hook
1 parent 26de11f commit 06d0b39

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ public async Task<bool> SendMessage(string agentId,
7474
// Routing with reasoning
7575
var settings = _services.GetRequiredService<RoutingSettings>();
7676

77+
// reload agent in case it has been changed by hook
78+
if (message.CurrentAgentId != agent.Id)
79+
{
80+
agent = await agentService.LoadAgent(message.CurrentAgentId);
81+
}
82+
7783
if (agent.Type == AgentType.Routing)
7884
{
7985
response = await routing.InstructLoop(message, dialogs);

0 commit comments

Comments
 (0)