From f191690d0108fa7dae27008588acf8ccb5dcf83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E5=BF=B5?= Date: Thu, 8 Oct 2026 12:06:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AC=AC=E4=B8=89=E5=A4=84app=E5=88=86?= =?UTF-8?q?=E6=94=AF=E7=A6=81=E4=BB=A4=E5=90=8C=E6=AD=A5=E6=94=B9=E5=86=99?= =?UTF-8?q?=E2=80=94=E2=80=94=E7=A6=81=E4=BB=A4=E9=9B=86=E5=AE=8C=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Code --- app/services/conversation.py | 5 ++++- tests/test_lead_email_trigger.py | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/services/conversation.py b/app/services/conversation.py index de6435f..950adbb 100644 --- a/app/services/conversation.py +++ b/app/services/conversation.py @@ -681,11 +681,14 @@ class ConversationManager: if confirmed or suspect: # 已留资: 索要我方联系方式 → 逐字"经理主动联系"版, # 与"禁止再索要"提醒不再打架 + # Task 3 收尾: 第三处禁令同步改写(禁令集完整)——与前两处 + # 同语义,只禁已提供过的渠道,缺失渠道放行轻补一次 contact_note = ( "⚠️ 客户正在索要我方联系方式,且客户已留过自己的联系方式。" "请逐字使用这句:\"Our manager will reach out to you at your " "WhatsApp shortly with the full quote!\"(中文同理)。" - "绝对禁止输出任何号码或邮箱,也绝对禁止再索要联系方式。") + "绝对禁止输出任何号码或邮箱,也绝对禁止再索要客户已提供过" + "的联系方式(缺失渠道可按轻补指引提一次)。") else: contact_note = ("⚠️ 客户正在索要我方联系方式(最高意向信号)。当前为 App 会话," "没有页面按钮——禁止使用任何 tap/button 按钮话术!请逐字使用这句:" diff --git a/tests/test_lead_email_trigger.py b/tests/test_lead_email_trigger.py index 5c62413..d6d7408 100644 --- a/tests/test_lead_email_trigger.py +++ b/tests/test_lead_email_trigger.py @@ -699,6 +699,19 @@ def test_reminder_app_contact_ask_gated_by_existing_contact(): assert "reach out to you at your WhatsApp" in text # 已留资版逐字脚本 +def test_reminder_app_contact_ask_confirmed_allows_missing_channel_once(): + # Task 3 收尾: contact_note app+已留资分支的第三处禁令同步改写(禁令集完整)。 + # 防空转设计: 双渠道齐 → 轻补 note 不注入;消息无价格词 → 边界分支不渲染; + # 此时"缺失渠道可按轻补指引提一次"只能来自该分支改写文本 + # (:651 版是"仅可按",不构成子串)。 + raw = {"联系方式": {"whatsapp": "+254712345678", "email": "a@b.com"}} + text = ConversationManager._build_context_reminder( + raw, "how can I contact you?", [], source="app") + assert "reach out to you at your WhatsApp" in text # 已留资版逐字脚本在场 + assert "缺失渠道可按轻补指引提一次" in text # 第三处禁令改写钉死 + assert "email address would help too" not in text # 双渠道齐→无轻补注入(防空转) + + def test_reminder_app_contact_ask_without_contact_keeps_script(): # App 会话未留资 → 原反向留资脚本原样保留 text = ConversationManager._build_context_reminder(