@@ -46,6 +46,18 @@ await _chatHub.Clients.User(_user.Id).SendAsync("OnConversationContentLogGenerat
4646 BuildContentLog ( conversationId , _user . UserName , log , ContentLogSource . UserInput , message ) ) ;
4747 }
4848
49+ public override async Task OnConversationRedirected ( string toAgentId , RoleDialogModel message )
50+ {
51+ var agentService = _services . GetRequiredService < IAgentService > ( ) ;
52+ var conversationId = _state . GetConversationId ( ) ;
53+ var fromAgent = await agentService . LoadAgent ( message . CurrentAgentId ) ;
54+ var toAgent = await agentService . LoadAgent ( toAgentId ) ;
55+
56+ var log = $ "{ message . Content } \r \n =====\r \n REDIRECTED TO { toAgent . Name } ";
57+ await _chatHub . Clients . User ( _user . Id ) . SendAsync ( "OnConversationContentLogGenerated" ,
58+ BuildContentLog ( conversationId , fromAgent . Name , log , ContentLogSource . HardRule , message ) ) ;
59+ }
60+
4961 public async Task BeforeGenerating ( Agent agent , List < RoleDialogModel > conversations )
5062 {
5163 if ( ! _convSettings . ShowVerboseLog ) return ;
@@ -83,23 +95,26 @@ public async Task AfterGenerated(RoleDialogModel message, TokenStatsModel tokenS
8395 var agent = await agentService . LoadAgent ( message . CurrentAgentId ) ;
8496 var logSource = string . Empty ;
8597
98+ var log = tokenStats . Prompt ;
99+ logSource = ContentLogSource . Prompt ;
100+ await _chatHub . Clients . User ( _user . Id ) . SendAsync ( "OnConversationContentLogGenerated" ,
101+ BuildContentLog ( conversationId , agent ? . Name , log , logSource , message ) ) ;
102+
86103 // Log routing output
87104 try
88105 {
89106 var inst = message . Content . JsonContent < FunctionCallFromLlm > ( ) ;
90- logSource = ContentLogSource . AgentResponse ;
91- await _chatHub . Clients . User ( _user . Id ) . SendAsync ( "OnConversationContentLogGenerated" ,
92- BuildContentLog ( conversationId , agent ? . Name , message . Content , logSource , message ) ) ;
107+ if ( ! string . IsNullOrEmpty ( inst . Function ) )
108+ {
109+ logSource = ContentLogSource . AgentResponse ;
110+ await _chatHub . Clients . User ( _user . Id ) . SendAsync ( "OnConversationContentLogGenerated" ,
111+ BuildContentLog ( conversationId , agent ? . Name , message . Content , logSource , message ) ) ;
112+ }
93113 }
94114 catch
95115 {
96116 // ignore
97117 }
98-
99- var log = tokenStats . Prompt ;
100- logSource = ContentLogSource . Prompt ;
101- await _chatHub . Clients . User ( _user . Id ) . SendAsync ( "OnConversationContentLogGenerated" ,
102- BuildContentLog ( conversationId , agent ? . Name , log , logSource , message ) ) ;
103118 }
104119
105120 /// <summary>
@@ -118,7 +133,7 @@ public override async Task OnResponseGenerated(RoleDialogModel message)
118133 {
119134 var agentService = _services . GetRequiredService < IAgentService > ( ) ;
120135 var agent = await agentService . LoadAgent ( message . CurrentAgentId ) ;
121- var log = $ "[ { agent ? . Name } ]: { message . Content } ";
136+ var log = $ "{ message . Content } ";
122137 if ( message . RichContent != null && message . RichContent . Message . RichType != "text" )
123138 {
124139 var richContent = JsonSerializer . Serialize ( message . RichContent , _serializerOptions ) ;
0 commit comments