Fix dead loop when depth exceeds the limit.

This commit is contained in:
hchen2020 2023-08-23 10:40:46 -05:00 committed by Haiping Chen
parent bccf362a52
commit ebf6f5c01c

View file

@ -21,12 +21,21 @@ public partial class ConversationService
currentRecursiveDepth++;
if (currentRecursiveDepth > maxRecursiveDepth)
{
_logger.LogError($"Exceeded max recursive depth.");
await HandleAssistantMessage(new RoleDialogModel(AgentRole.Assistant, "I'm sorry, can you see it again?")
_logger.LogWarning($"Exceeded max recursive depth.");
var latestResponse = wholeDialogs.Last();
var text = latestResponse.Content;
if (latestResponse.Role == AgentRole.Function)
{
text = latestResponse.Content.Split("=>").Last();
}
await HandleAssistantMessage(new RoleDialogModel(AgentRole.Assistant, text)
{
CurrentAgentId = agent.Id,
Channel = wholeDialogs.Last().Channel
}, onMessageReceived);
return false;
}