@@ -860,8 +860,10 @@ public List<string> GetExecutionLogs(string conversationId)
860
860
#region LLM Completion Log
861
861
public void SaveLlmCompletionLog ( LlmCompletionLog log )
862
862
{
863
+ if ( log == null || string . IsNullOrEmpty ( log . ConversationId ) ) return ;
864
+
863
865
var convDir = FindConversationDirectory ( log . ConversationId ) ;
864
- if ( ! Directory . Exists ( convDir ) ) return ;
866
+ if ( string . IsNullOrEmpty ( convDir ) ) return ;
865
867
866
868
var logDir = Path . Combine ( convDir , "llm_prompt_log" ) ;
867
869
if ( ! Directory . Exists ( logDir ) )
@@ -870,7 +872,7 @@ public void SaveLlmCompletionLog(LlmCompletionLog log)
870
872
}
871
873
872
874
log . Id = Guid . NewGuid ( ) . ToString ( ) ;
873
- var index = GetLlmCompletionLogIndex ( logDir , log . MessageId ) ;
875
+ var index = GetNextLlmCompletionLogIndex ( logDir , log . MessageId ) ;
874
876
var file = Path . Combine ( logDir , $ "{ log . MessageId } .{ index } .log") ;
875
877
File . WriteAllText ( file , JsonSerializer . Serialize ( log , _options ) ) ;
876
878
}
@@ -969,6 +971,8 @@ private List<AgentResponse> FetchResponses(string fileDir)
969
971
970
972
private string ? FindConversationDirectory ( string conversationId )
971
973
{
974
+ if ( string . IsNullOrEmpty ( conversationId ) ) return null ;
975
+
972
976
var dir = Path . Combine ( _dbSettings . FileRepository , _conversationSettings . DataDir , conversationId ) ;
973
977
if ( ! Directory . Exists ( dir ) ) return null ;
974
978
@@ -1024,7 +1028,7 @@ private List<StateKeyValue> CollectConversationStates(string stateDir)
1024
1028
return states ;
1025
1029
}
1026
1030
1027
- private int GetLlmCompletionLogIndex ( string logDir , string id )
1031
+ private int GetNextLlmCompletionLogIndex ( string logDir , string id )
1028
1032
{
1029
1033
var files = Directory . GetFiles ( logDir ) ;
1030
1034
if ( files . IsNullOrEmpty ( ) )
0 commit comments