@@ -253,6 +253,7 @@ func Test_makeDetector(t *testing.T) {
253253 HistorySize : 5 ,
254254 CheckShortMessages : true ,
255255 },
256+ LLM : rules.LLMCommonRules {HistoryContextSize : 3 },
256257 }
257258
258259 res := makeDetectorWithRuleSet (opts , ruleSet )
@@ -268,6 +269,7 @@ func Test_makeDetector(t *testing.T) {
268269 assert .Equal (t , 4 , res .OpenAIHistorySize )
269270 assert .True (t , res .GeminiVeto )
270271 assert .Equal (t , 5 , res .GeminiHistorySize )
272+ assert .Equal (t , 3 , res .LLMHistoryContextSize )
271273 assert .Empty (t , res .LLMMode )
272274 })
273275}
@@ -437,7 +439,7 @@ func TestAssembleRuntimeUsesActiveRuleSet(t *testing.T) {
437439 require .NoError (t , err )
438440 _ , err = db .ExecContext (ctx ,
439441 "INSERT INTO rule_set_versions (workspace_id, gid, tenant_id, version, source, payload, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)" ,
440- "gr1" , opts .InstanceID , opts .InstanceID , 2 , "test" , `{"workspace_id":"gr1","version":2,"source":"test","meta":{"links_limit":5,"mentions_limit":4},"duplicates":{"threshold":4,"window":60000000000},"abnormal_spacing":{"enabled":true,"space_ratio_threshold":0.25,"short_word_ratio_threshold":0.6,"short_word_len":5,"min_words":8},"moderation":{"first_strike":900000000000,"second_strike":21600000000000,"soft_ban":true,"dry_run":true},"reports":{"enabled":true,"threshold":5,"auto_ban_threshold":6,"rate_limit":2,"rate_period":120000000000},"openai":{"enabled":false,"veto":true,"model":"gpt-active","history_size":3,"check_short_messages":true},"gemini":{"enabled":false,"veto":false,"model":"gemini-active","history_size":7,"check_short_messages":false}}` ,
442+ "gr1" , opts .InstanceID , opts .InstanceID , 2 , "test" , `{"workspace_id":"gr1","version":2,"source":"test","meta":{"links_limit":5,"mentions_limit":4},"duplicates":{"threshold":4,"window":60000000000},"abnormal_spacing":{"enabled":true,"space_ratio_threshold":0.25,"short_word_ratio_threshold":0.6,"short_word_len":5,"min_words":8},"moderation":{"first_strike":900000000000,"second_strike":21600000000000,"soft_ban":true,"dry_run":true},"reports":{"enabled":true,"threshold":5,"auto_ban_threshold":6,"rate_limit":2,"rate_period":120000000000},"llm":{"history_context_size":6}," openai":{"enabled":false,"veto":true,"model":"gpt-active","history_size":3,"check_short_messages":true},"gemini":{"enabled":false,"veto":false,"model":"gemini-active","history_size":7,"check_short_messages":false}}` ,
441443 time .Now ().UTC (),
442444 )
443445 require .NoError (t , err )
@@ -457,6 +459,7 @@ func TestAssembleRuntimeUsesActiveRuleSet(t *testing.T) {
457459 assert .Equal (t , 4 , assembly .Detector .DuplicateDetection .Threshold )
458460 assert .True (t , assembly .Detector .AbnormalSpacing .Enabled )
459461 assert .Equal (t , 3 , assembly .Detector .OpenAIHistorySize )
462+ assert .Equal (t , 6 , assembly .Detector .LLMHistoryContextSize )
460463
461464 tbAPI := & tbapi.BotAPI {Self : tbapi.User {UserName : "bot" }}
462465 listener := assembly .makeTelegramListener (opts , tbAPI )
@@ -607,7 +610,7 @@ func TestBuildDetectorConfig_ReadsDetectionFromRuleSet(t *testing.T) {
607610 FirstMessagesCount : 1 ,
608611 ParanoidMode : false ,
609612 },
610- LLM : rules.LLMCommonRules {Mode : "flagged" , Consensus : "any" },
613+ LLM : rules.LLMCommonRules {Mode : "flagged" , Consensus : "any" , HistoryContextSize : 4 },
611614 }
612615
613616 cfg := buildDetectorConfig (opts , rs )
@@ -620,6 +623,7 @@ func TestBuildDetectorConfig_ReadsDetectionFromRuleSet(t *testing.T) {
620623 assert .Equal (t , 1 , cfg .FirstMessagesCount )
621624 assert .Equal (t , tgspam .LLMMode ("flagged" ), cfg .LLMMode )
622625 assert .Equal (t , tgspam .LLMConsensusMode ("any" ), cfg .LLMConsensus )
626+ assert .Equal (t , 4 , cfg .LLMHistoryContextSize )
623627 assert .Equal (t , "https://api.cas.chat" , cfg .CasAPI )
624628}
625629
0 commit comments