From d6abb1cc23079576563fee3b42a5d1cb104c32bd Mon Sep 17 00:00:00 2001 From: liuwei Date: Tue, 7 Apr 2026 11:50:30 +0800 Subject: [PATCH] tighten xiaoniu reply triggers for direct mentions only --- plugins/ai_auto_response/main.py | 8 ++++++++ plugins/ai_auto_response/response_planner.py | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/ai_auto_response/main.py b/plugins/ai_auto_response/main.py index f78c204..4a7bb46 100644 --- a/plugins/ai_auto_response/main.py +++ b/plugins/ai_auto_response/main.py @@ -124,6 +124,8 @@ class AIAutoResponsePlugin(MessagePluginInterface): return False if self._should_ignore(content): return False + if self._is_targeting_other_user(message): + return False return True async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]: @@ -299,6 +301,12 @@ class AIAutoResponsePlugin(MessagePluginInterface): return True return any(content.startswith(prefix) for prefix in self.filters.get("ignore_prefixes", [])) + def _is_targeting_other_user(self, message: Dict[str, Any]) -> bool: + if message.get("is_at", False): + return False + raw_content = str(message.get("content", "") or "") + return "@" in raw_content + def _get_sender_name(self, room_id: str, sender: str) -> str: try: members = ContactManager.get_instance().get_group_members(room_id) diff --git a/plugins/ai_auto_response/response_planner.py b/plugins/ai_auto_response/response_planner.py index 4c9c41f..a42b431 100644 --- a/plugins/ai_auto_response/response_planner.py +++ b/plugins/ai_auto_response/response_planner.py @@ -16,8 +16,16 @@ class ResponsePlanner: return "social_short" if flow_state in {"deep_engaged"} else "refuse_or_skip" def should_reply(self, trigger: Dict, flow_state: str, allow_proactive: bool) -> bool: - if trigger.get("should_respond"): + if trigger.get("is_at"): return True + if trigger.get("is_question"): + return True + if trigger.get("is_followup"): + return False + if trigger.get("is_social_call"): + return False + if trigger.get("is_returning_member"): + return False if not allow_proactive: return False return flow_state in {"deep_engaged"} and trigger.get("priority", 0) >= 0.65