Merge pull request #325 from hchen2020/master

Fix Pop agent bug.
This commit is contained in:
C. Oceania 2024-02-28 20:47:47 -06:00 committed by GitHub
commit 91a017c43d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 5 deletions

View file

@ -1,7 +1,4 @@
using BotSharp.Abstraction.Functions;
using BotSharp.Abstraction.Repositories;
using BotSharp.Abstraction.Repositories.Filters;
using BotSharp.Abstraction.Routing;
using BotSharp.Abstraction.Routing.Models;
using System.Drawing;

View file

@ -53,6 +53,11 @@ public class RoutingContext : IRoutingContext
public string GetCurrentAgentId()
{
if (_stack.Count == 0)
{
return string.Empty;
}
return _stack.Peek();
}
@ -80,9 +85,10 @@ public class RoutingContext : IRoutingContext
}
var agentId = _stack.Pop();
var currentAgentId = GetCurrentAgentId();
HookEmitter.Emit<IRoutingHook>(_services, async hook =>
await hook.OnAgentDequeued(agentId, _stack.Peek(), reason: reason)
await hook.OnAgentDequeued(agentId, currentAgentId, reason: reason)
).Wait();
}

View file

@ -182,7 +182,7 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR
var agent = await _agentService.LoadAgent(agentId);
var currentAgent = await _agentService.LoadAgent(currentAgentId);
var log = $"{agent.Name} is dequeued{(reason != null ? $" ({reason})" : "")}, current agent is {currentAgent.Name}";
var log = $"{agent.Name} is dequeued{(reason != null ? $" ({reason})" : "")}, current agent is {currentAgent?.Name}";
await _chatHub.Clients.User(_user.Id).SendAsync("OnConversationContentLogGenerated",
BuildContentLog(conversationId, "Router", log, ContentLogSource.HardRule, new RoleDialogModel(AgentRole.System, log)
{