From 48becf2c5170c0e74fa6d8dcd1e8ca224217ca72 Mon Sep 17 00:00:00 2001 From: "Sheldon.li" <765985232@qq.com> Date: Tue, 17 Jun 2025 22:12:55 +0800 Subject: [PATCH] refactor(ContentFilterStage): Add logic for handling empty messages (#1525) -In the ContentFilterStage, logic for handling empty messages has been added to ensure that the pipeline continues to process even when the message is empty. - This change enhances the robustness of content filtering, preventing potential issues caused by empty messages. - This optimization was implemented to address the issue where, when someone is @ in a group chat and a message is sent without any content, the Source type messages in the message chain are lost. --- pkg/pipeline/cntfilter/cntfilter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/pipeline/cntfilter/cntfilter.py b/pkg/pipeline/cntfilter/cntfilter.py index 879b1295..0bbc5103 100644 --- a/pkg/pipeline/cntfilter/cntfilter.py +++ b/pkg/pipeline/cntfilter/cntfilter.py @@ -66,6 +66,8 @@ class ContentFilterStage(stage.PipelineStage): if query.pipeline_config['safety']['content-filter']['scope'] == 'output-msg': return entities.StageProcessResult(result_type=entities.ResultType.CONTINUE, new_query=query) + if not message.strip(): + return entities.StageProcessResult(result_type=entities.ResultType.CONTINUE, new_query=query) else: for filter in self.filter_chain: if filter_entities.EnableStage.PRE in filter.enable_stages: