@@ -247,9 +247,13 @@ public async Task OnAgentEnqueued(string agentId, string preAgentId, string? rea
247
247
{
248
248
var conversationId = _state . GetConversationId ( ) ;
249
249
var agent = await _agentService . LoadAgent ( agentId ) ;
250
- var preAgent = await _agentService . LoadAgent ( preAgentId ) ;
251
250
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 } )" : "" ) } ";
253
257
var message = new RoleDialogModel ( AgentRole . System , log )
254
258
{
255
259
MessageId = _routingCtx . MessageId
@@ -270,7 +274,12 @@ public async Task OnAgentDequeued(string agentId, string currentAgentId, string?
270
274
var agent = await _agentService . LoadAgent ( agentId ) ;
271
275
var currentAgent = await _agentService . LoadAgent ( currentAgentId ) ;
272
276
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 } ";
274
283
var message = new RoleDialogModel ( AgentRole . System , log )
275
284
{
276
285
MessageId = _routingCtx . MessageId
@@ -291,7 +300,12 @@ public async Task OnAgentReplaced(string fromAgentId, string toAgentId, string?
291
300
var fromAgent = await _agentService . LoadAgent ( fromAgentId ) ;
292
301
var toAgent = await _agentService . LoadAgent ( toAgentId ) ;
293
302
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 } )" : "" ) } ";
295
309
var message = new RoleDialogModel ( AgentRole . System , log )
296
310
{
297
311
MessageId = _routingCtx . MessageId
@@ -309,9 +323,13 @@ public async Task OnAgentReplaced(string fromAgentId, string toAgentId, string?
309
323
public async Task OnAgentQueueEmptied ( string agentId , string ? reason = null )
310
324
{
311
325
var conversationId = _state . GetConversationId ( ) ;
312
- var agent = await _agentService . LoadAgent ( agentId ) ;
313
326
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" ;
315
333
var message = new RoleDialogModel ( AgentRole . System , log )
316
334
{
317
335
MessageId = _routingCtx . MessageId
@@ -423,4 +441,16 @@ private string BuildStateChangeLog(StateChangeModel stateChange)
423
441
424
442
return JsonSerializer . Serialize ( log , _options . JsonSerializerOptions ) ;
425
443
}
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
+ }
426
456
}
0 commit comments