@@ -247,9 +247,13 @@ public async Task OnAgentEnqueued(string agentId, string preAgentId, string? rea
247247 {
248248 var conversationId = _state . GetConversationId ( ) ;
249249 var agent = await _agentService . LoadAgent ( agentId ) ;
250- var preAgent = await _agentService . LoadAgent ( preAgentId ) ;
251250
252- var log = $ "{ agent . Name } is enqueued{ ( reason != null ? $ " ({ reason } )" : "" ) } ";
251+ // Agent queue log
252+ var log = $ "{ agent . Name } is enqueued";
253+ await _chatHub . Clients . User ( _user . Id ) . SendAsync ( "OnAgentQueueChanged" , BuildAgentQueueChangedLog ( conversationId , log ) ) ;
254+
255+ // Content log
256+ log = $ "{ agent . Name } is enqueued{ ( reason != null ? $ " ({ reason } )" : "" ) } ";
253257 var message = new RoleDialogModel ( AgentRole . System , log )
254258 {
255259 MessageId = _routingCtx . MessageId
@@ -270,7 +274,12 @@ public async Task OnAgentDequeued(string agentId, string currentAgentId, string?
270274 var agent = await _agentService . LoadAgent ( agentId ) ;
271275 var currentAgent = await _agentService . LoadAgent ( currentAgentId ) ;
272276
273- var log = $ "{ agent . Name } is dequeued{ ( reason != null ? $ " ({ reason } )" : "" ) } , current agent is { currentAgent ? . Name } ";
277+ // Agent queue log
278+ var log = $ "{ agent . Name } is dequeued";
279+ await _chatHub . Clients . User ( _user . Id ) . SendAsync ( "OnAgentQueueChanged" , BuildAgentQueueChangedLog ( conversationId , log ) ) ;
280+
281+ // Content log
282+ log = $ "{ agent . Name } is dequeued{ ( reason != null ? $ " ({ reason } )" : "" ) } , current agent is { currentAgent ? . Name } ";
274283 var message = new RoleDialogModel ( AgentRole . System , log )
275284 {
276285 MessageId = _routingCtx . MessageId
@@ -291,7 +300,12 @@ public async Task OnAgentReplaced(string fromAgentId, string toAgentId, string?
291300 var fromAgent = await _agentService . LoadAgent ( fromAgentId ) ;
292301 var toAgent = await _agentService . LoadAgent ( toAgentId ) ;
293302
294- var log = $ "{ fromAgent . Name } is replaced to { toAgent . Name } { ( reason != null ? $ " ({ reason } )" : "" ) } ";
303+ // Agent queue log
304+ var log = $ "Agent queue is replaced from { fromAgent . Name } to { toAgent . Name } ";
305+ await _chatHub . Clients . User ( _user . Id ) . SendAsync ( "OnAgentQueueChanged" , BuildAgentQueueChangedLog ( conversationId , log ) ) ;
306+
307+ // Content log
308+ log = $ "{ fromAgent . Name } is replaced to { toAgent . Name } { ( reason != null ? $ " ({ reason } )" : "" ) } ";
295309 var message = new RoleDialogModel ( AgentRole . System , log )
296310 {
297311 MessageId = _routingCtx . MessageId
@@ -309,9 +323,13 @@ public async Task OnAgentReplaced(string fromAgentId, string toAgentId, string?
309323 public async Task OnAgentQueueEmptied ( string agentId , string ? reason = null )
310324 {
311325 var conversationId = _state . GetConversationId ( ) ;
312- var agent = await _agentService . LoadAgent ( agentId ) ;
313326
314- var log = reason ?? "Agent queue is cleared" ;
327+ // Agent queue log
328+ var log = $ "Agent queue is empty";
329+ await _chatHub . Clients . User ( _user . Id ) . SendAsync ( "OnAgentQueueChanged" , BuildAgentQueueChangedLog ( conversationId , log ) ) ;
330+
331+ // Content log
332+ log = reason ?? "Agent queue is cleared" ;
315333 var message = new RoleDialogModel ( AgentRole . System , log )
316334 {
317335 MessageId = _routingCtx . MessageId
@@ -423,4 +441,16 @@ private string BuildStateChangeLog(StateChangeModel stateChange)
423441
424442 return JsonSerializer . Serialize ( log , _options . JsonSerializerOptions ) ;
425443 }
444+
445+ private string BuildAgentQueueChangedLog ( string conversationId , string log )
446+ {
447+ var model = new AgentQueueChangedLogModel
448+ {
449+ ConversationId = conversationId ,
450+ Log = log ,
451+ CreateTime = DateTime . UtcNow
452+ } ;
453+
454+ return JsonSerializer . Serialize ( model , _options . JsonSerializerOptions ) ;
455+ }
426456}
0 commit comments