@@ -31,8 +31,6 @@ public async Task<bool> Execute(RoleDialogModel message)
3131 fromAgent = await agentService . LoadAgent ( message . CurrentAgentId ) ;
3232 }
3333
34- var wholeDialogs = routingCtx . GetDialogs ( ) ;
35- var dialogs = AssembleFiles ( conv . ConversationId , args ? . ImageUrls , wholeDialogs ) ;
3634 var agent = new Agent
3735 {
3836 Id = BuiltInAgentId . UtilityAssistant ,
@@ -41,6 +39,13 @@ public async Task<bool> Execute(RoleDialogModel message)
4139 TemplateDict = new Dictionary < string , object > ( )
4240 } ;
4341
42+ var wholeDialogs = routingCtx . GetDialogs ( ) ;
43+ if ( wholeDialogs . IsNullOrEmpty ( ) )
44+ {
45+ wholeDialogs = conv . GetDialogHistory ( ) ;
46+ }
47+
48+ var dialogs = AssembleFiles ( conv . ConversationId , args ? . ImageUrls , wholeDialogs ) ;
4449 var response = await GetChatCompletion ( agent , dialogs ) ;
4550 message . Content = response ;
4651 return true ;
@@ -76,7 +81,7 @@ private List<RoleDialogModel> AssembleFiles(string conversationId, IEnumerable<s
7681
7782 if ( ! imageUrls . IsNullOrEmpty ( ) )
7883 {
79- var lastDialog = dialogs . Last ( ) ;
84+ var lastDialog = dialogs . LastOrDefault ( x => x . Role == AgentRole . User ) ?? dialogs . Last ( ) ;
8085 var files = lastDialog . Files ?? [ ] ;
8186 var addnFiles = imageUrls . Select ( x => x ? . Trim ( ) )
8287 . Where ( x => ! string . IsNullOrWhiteSpace ( x ) )
0 commit comments