From 5051b0bfd7cd424d38324597d3cc2d446cd97a8e Mon Sep 17 00:00:00 2001 From: mohe Date: Sat, 20 Jun 2026 01:41:40 +0800 Subject: [PATCH] add silent phrase interception: block LLM announcing silence instead of being silent --- xmpp_agent_core.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xmpp_agent_core.py b/xmpp_agent_core.py index 7d5f186..764a1a0 100644 --- a/xmpp_agent_core.py +++ b/xmpp_agent_core.py @@ -193,6 +193,12 @@ class AgentBot(ClientXMPP): if reply_stripped.startswith('__SILENT__') or reply_stripped.startswith('`__SILENT__`'): logging.info(f"⏭️ {AGENT_NAME} 决定沉默,不发送") return + # 额外拦截:LLM 说"我沉默""我不说了"等宣布沉默的话→当 SILENT 处理 + _silent_phrases = ['我沉默', '我不说', '不说了', '不回复', '不插嘴', '我闭嘴', + '闭嘴上', '沉默是', '彻底沉默', '我会沉默', '将保持沉默'] + if any(p in reply for p in _silent_phrases): + logging.info(f"⏭️ {AGENT_NAME} 宣布沉默(命中关键词),拦截") + return finish = data.get("choices", [{}])[0].get("finish_reason", "") if reply.strip() and finish != "silent":