diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs index 0d0aa03d9..5d08098f6 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs @@ -28,14 +28,18 @@ public async Task InvokeFunction(string name, RoleDialogModel message, Inv clonedMessage.FunctionName = name; clonedMessage.Indication = await funcExecutor.GetIndicatorAsync(message); - var conv = _services.GetRequiredService(); - var messageHub = _services.GetRequiredService>>(); - messageHub.Push(new() + // An empty indicator means the callee has nothing worth announcing for this call. + if (!string.IsNullOrEmpty(clonedMessage.Indication)) { - EventName = ChatEvent.OnIndicationReceived, - Data = clonedMessage, - RefId = conv.ConversationId - }); + var conv = _services.GetRequiredService(); + var messageHub = _services.GetRequiredService>>(); + messageHub.Push(new() + { + EventName = ChatEvent.OnIndicationReceived, + Data = clonedMessage, + RefId = conv.ConversationId + }); + } var hooks = _services.GetHooksOrderByPriority(clonedMessage.CurrentAgentId); foreach (var hook in hooks) @@ -44,6 +48,10 @@ public async Task InvokeFunction(string name, RoleDialogModel message, Inv await hook.OnFunctionExecuting(clonedMessage, options); } + // Already pushed and logged: clear it so nested calls resolve their own indication + // instead of inheriting this one through GetIndication's `message.Indication ??` fallback. + clonedMessage.Indication = null; + bool result = false; try