File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -392,6 +392,7 @@ def _limit_conversation_to_pairs(self, messages):
392392 conversation_messages = [msg for msg in messages if msg .get ("sender" ) in {"human" , "ai" }]
393393
394394 if not conversation_messages :
395+ log .debug ("AUDIT: No human/ai messages found after filtering, returning empty history" )
395396 return []
396397
397398 # Extract complete Q&A pairs (human → ai)
@@ -418,12 +419,14 @@ def _limit_conversation_to_pairs(self, messages):
418419
419420 i += 1
420421
421- # Take the last 10 pairs maximum
422- if len (pairs ) > 10 :
423- pairs = pairs [- 10 :]
422+ # Take the last 10 pairs maximum (slice works even with fewer pairs)
423+ original_pair_count = len (pairs )
424+ pairs = pairs [- 10 :]
425+
426+ if original_pair_count > 10 :
424427 log .info (
425428 "AUDIT: Limited conversation history from %d to %d Q&A pairs for LLM context" ,
426- len ( conversation_messages ) // 2 ,
429+ original_pair_count ,
427430 len (pairs ),
428431 )
429432
You can’t perform that action at this time.
0 commit comments