fix: CC追问防压制——confirmed块让位+禁令例外扩围+伪回显示例

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-10-08 12:50:34 +08:00
parent 31ffb638b6
commit 206beae11b
4 changed files with 63 additions and 14 deletions
+16
View File
@@ -953,6 +953,21 @@ def test_contact_completion_note_serial_priority():
assert "邮箱也留一个呗" in note and marks == ["_email_asked"]
def test_reminder_cc_round_confirmed_block_yields_to_cc_note():
"""生产验收场景①修复: CC 追问轮 confirmed 块让位——同轮两个"逐字使用这句"
竞争时 GLM 稳定服从更显眼的 NO_CONTACT_ALREADY 确认句,压制国家代码追问。"""
raw = {"联系方式": {"whatsapp": "0501234567"}} # 裸号 → CC 追问轮
text = ConversationManager._build_context_reminder(raw, "yes", [])
assert "Could you send the full number with the country code" in text # CC 句在场
assert "Got it — our manager will reach out" not in text # 确认句让位(逐字建议消失)
assert "本轮不要使用确认句" in text # 让位语义钉死
# 反向钉死边界: 同画像换带前缀号(非 CC 轮) → 确认句回归
raw2 = {"联系方式": {"whatsapp": "+966501234567"}}
text2 = ConversationManager._build_context_reminder(raw2, "yes", [])
assert "Got it — our manager will reach out" in text2
assert "本轮不要使用确认句" not in text2
def test_contact_completion_two_round_serial_and_persistence(async_db, monkeypatch):
"""spec §6-6 计数持久化集成: 裸号两轮——第一轮 cc 追问注入且 _cc_asked 落库;
第二轮客户没配合(号码仍裸),按 §4.3b 串行规则转邮箱轻补并落 _email_asked。
@@ -974,6 +989,7 @@ def test_contact_completion_two_round_serial_and_persistence(async_db, monkeypat
# 第一轮正向断言: cc 追问句原文确实拼进了 reminder(非仅写计数)
assert "Could you send the full number with the country code" in ai.contexts[0]
assert "email address would help too" not in ai.contexts[0] # 串行: cc 优先
assert "Got it — our manager will reach out" not in ai.contexts[0] # 确认句让位(端到端)
profile = asyncio.run(manager._get_profile(conv.id))
assert (profile.raw_info or {}).get("_cc_asked") is True # 计数已落库
# 第二轮: 号码仍裸 → cc 不再问,串行规则转邮箱轻补(_cc_asked 已消耗)