diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingHook.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingHook.cs index 84d9779f9..5ff7e37e1 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingHook.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingHook.cs @@ -15,6 +15,15 @@ public interface IRoutingHook : IHookBase Task OnRoutingInstructionReceived(FunctionCallFromLlm instruct, RoleDialogModel message) => Task.CompletedTask; + /// + /// Routing instruction execution is completed + /// + /// + /// + /// + Task OnRoutingInstructionCompleted(FunctionCallFromLlm instruct, RoleDialogModel message) + => Task.CompletedTask; + Task OnRoutingInstructionRevised(FunctionCallFromLlm instruct, RoleDialogModel message) => Task.CompletedTask; diff --git a/src/Infrastructure/BotSharp.Core/Routing/Reasoning/InstructExecutor.cs b/src/Infrastructure/BotSharp.Core/Routing/Reasoning/InstructExecutor.cs index c71d0f07e..23eee53d2 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/Reasoning/InstructExecutor.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/Reasoning/InstructExecutor.cs @@ -44,6 +44,13 @@ await HookEmitter.Emit(_services, async hook => await hook.OnRouti var agent = await agentService.GetAgent(agentId); inst.AgentName = agent.Name; + await HookEmitter.Emit(_services, async hook => await hook.OnRoutingInstructionCompleted(inst, message), + agent.Id); + if (message.StopCompletion) + { + return message; + } + if (inst.ExecutingDirectly) { message.Content = inst.Question;