From df26453364c62aa38e071042a0a57c44d217951c Mon Sep 17 00:00:00 2001 From: "nick.yi" Date: Wed, 22 Jul 2026 16:56:03 +0800 Subject: [PATCH] add OnRoutingInstructionCompleted --- .../BotSharp.Abstraction/Routing/IRoutingHook.cs | 9 +++++++++ .../BotSharp.Core/Routing/Reasoning/InstructExecutor.cs | 7 +++++++ 2 files changed, 16 insertions(+) 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;