intercept __SILENT__/__REPLY__ misuse in LLM response body

This commit is contained in:
2026-06-20 01:48:37 +08:00
parent 5051b0bfd7
commit 947bb1e6d0
+9
View File
@@ -190,9 +190,18 @@ class AgentBot(ClientXMPP):
data = json.loads(result.read())
reply = data.get("choices", [{}])[0].get("message", {}).get("content", "")
reply_stripped = reply.strip()
# 检查 __SILENT__ 标记
if reply_stripped.startswith('__SILENT__') or reply_stripped.startswith('`__SILENT__`'):
logging.info(f"⏭️ {AGENT_NAME} 决定沉默,不发送")
return
# 如果回复里任意位置出现了 __SILENT__,说明 LLM 没理解协议,整条作废
if '__SILENT__' in reply:
logging.info(f"⏭️ {AGENT_NAME} 回复中误用 __SILENT__,拦截")
return
# 如果回复里出现了 __REPLY__,也是协议混淆,拦截
if '__REPLY__' in reply:
logging.info(f"⏭️ {AGENT_NAME} 回复中误用 __REPLY__,拦截")
return
# 额外拦截:LLM 说"我沉默""我不说了"等宣布沉默的话→当 SILENT 处理
_silent_phrases = ['我沉默', '我不说', '不说了', '不回复', '不插嘴', '我闭嘴',
'闭嘴上', '沉默是', '彻底沉默', '我会沉默', '将保持沉默']