diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs index 9df6ae7f..055db3cc 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs @@ -51,6 +51,7 @@ public interface IConversationService /// /// Whether to reset all states /// Append user init words + /// /// - Task UpdateBreakpoint(bool resetStates = false, string? reason = null); + Task UpdateBreakpoint(bool resetStates = false, string? reason = null, params string[] excludedStates); } diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.UpdateBreakpoint.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.UpdateBreakpoint.cs index 7453a202..8f88f44f 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.UpdateBreakpoint.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.UpdateBreakpoint.cs @@ -4,7 +4,7 @@ namespace BotSharp.Core.Conversations.Services; public partial class ConversationService : IConversationService { - public async Task UpdateBreakpoint(bool resetStates = false, string? reason = null) + public async Task UpdateBreakpoint(bool resetStates = false, string? reason = null, params string[] excludedStates) { var db = _services.GetRequiredService(); var routingCtx = _services.GetRequiredService(); @@ -22,7 +22,13 @@ public partial class ConversationService : IConversationService { var states = _services.GetRequiredService(); // keep language state - states.CleanStates(StateConst.LANGUAGE); + if (excludedStates == null) excludedStates = new string[] { }; + if (!excludedStates.Contains(StateConst.LANGUAGE)) + { + excludedStates = excludedStates.Append(StateConst.LANGUAGE).ToArray(); + } + + states.CleanStates(excludedStates); } var hooks = _services.GetServices() diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs index 6b126a37..31caa932 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs @@ -118,6 +118,7 @@ public class RoutingContext : IRoutingContext var message = new RoleDialogModel(AgentRole.User, $"Try to route to agent {agent.Name}") { + CurrentAgentId = currentAgentId, FunctionName = "route_to_agent", FunctionArgs = JsonSerializer.Serialize(new FunctionCallFromLlm { diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs index 6ed27b32..71d824b3 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs @@ -298,6 +298,7 @@ public class ConversationController : ControllerBase MessageId = msg.MessageId, Text = msg.Indication, Function = "indicating", + Instruction = msg.Instruction, States = new Dictionary() }; await OnChunkReceived(Response, indicator);