diff --git a/src/Infrastructure/BotSharp.Core/Routing/Handlers/RouteToAgentRoutingHandler.cs b/src/Infrastructure/BotSharp.Core/Routing/Handlers/RouteToAgentRoutingHandler.cs index b21250db..ea020fd3 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/Handlers/RouteToAgentRoutingHandler.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/Handlers/RouteToAgentRoutingHandler.cs @@ -47,10 +47,11 @@ public class RouteToAgentRoutingHandler : RoutingHandlerBase, IRoutingHandler if (!string.IsNullOrEmpty(goalAgent)) { inst.OriginalAgent = goalAgent; + // Emit hook + await HookEmitter.Emit(_services, async hook => + await hook.OnRoutingInstructionRevised(inst, message) + ); } - await HookEmitter.Emit(_services, async hook => - await hook.OnRoutingInstructionRevised(inst, message) - ); var agentId = routing.Context.GetCurrentAgentId();