"""方案总结报告 prompt(build_summary_prompt)的意图对齐 + 缺口护栏内容测试。 效果改造 B:弱席位场景下,总结智能体不能只拼接各席位交付,而要先对齐用户意图、核对覆盖、 按护栏补强(推断标注「(综合推断)」、缺真实信息标注「待补充」交给用户、绝不凭空编)。 prompt 是纯函数,直接断言其文本包含这些指令 + 仍带齐意图/交付/共识/编排提示原料。 """ from __future__ import annotations from deerflow.agents.roundtable_orchestrator.engine import build_summary_prompt from deerflow.agents.roundtable_orchestrator.types import SeatRef _AGENTS = [SeatRef("seat-a", "情报"), SeatRef("seat-b", "方案")] _DELIVERIES = {"seat-a": "情报席位交付内容", "seat-b": "方案席位交付内容"} def test_summary_prompt_carries_intent_and_alignment_directive(): out = build_summary_prompt( "目标:拿下华东市场\n约束条件:\n- 预算有限", _AGENTS, _DELIVERIES, "总控共识:分两期推进", coordinator_prompt="重点突出风险", ) # 原料齐全 assert "拿下华东市场" in out assert "预算有限" in out assert "情报席位交付内容" in out and "方案席位交付内容" in out assert "总控共识:分两期推进" in out assert "重点突出风险" in out # 编排提示 # 意图对齐 + 缺口核对指令 assert "意图对齐与缺口核对" in out assert "核心诉求清单" in out # 防幻觉 + 报告文件完整干净(不足只在对话正文、不写进 .md)+ 对话必须有「核对说明」 assert "绝不凭空编" in out assert "无需用户修改" in out assert "不写进 .md" in out assert "核对说明" in out assert "不要省略" in out def test_summary_prompt_alignment_directive_present_even_without_coordinator_prompt(): out = build_summary_prompt("目标:X", _AGENTS, _DELIVERIES, "共识 Y") assert "意图对齐与缺口核对" in out assert "待补充" in out def test_summary_prompt_handles_empty_deliveries_gracefully(): out = build_summary_prompt("目标:X", _AGENTS, {}, "") # 无交付时仍给出兜底说明,且意图对齐指令照常在 assert "暂无文字交付" in out assert "意图对齐与缺口核对" in out