Skip to content

Commit ad7b3a4

Browse files
committed
optimize UpdateBreakpoint
1 parent 245384e commit ad7b3a4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Task<bool> SendMessage(string agentId,
5151
/// </summary>
5252
/// <param name="resetStates">Whether to reset all states</param>
5353
/// <param name="reason">Append user init words</param>
54+
/// <param name="excludedStates"></param>
5455
/// <returns></returns>
55-
Task UpdateBreakpoint(bool resetStates = false, string? reason = null);
56+
Task UpdateBreakpoint(bool resetStates = false, string? reason = null, params string[] excludedStates);
5657
}

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.UpdateBreakpoint.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ public async Task UpdateBreakpoint(bool resetStates = false, string? reason = nu
2222
{
2323
var states = _services.GetRequiredService<IConversationStateService>();
2424
// keep language state
25-
if(excludedStates.IsNullOrEmpty()) excludedStates = new string[] { StateConst.LANGUAGE };
25+
if (excludedStates == null) excludedStates = new string[] { };
26+
if (!excludedStates.Contains(StateConst.LANGUAGE))
27+
{
28+
excludedStates = excludedStates.Append(StateConst.LANGUAGE).ToArray();
29+
}
30+
2631
states.CleanStates(excludedStates);
2732
}
2833

0 commit comments

Comments
 (0)