深链接会商(taskId+goPath,businessCode)下按所选业务链完整层级强制校正 结构化抽取(flow-json) 与 方案总结报告: - 新增 harness 层 extraction_spec(app+harness 共用,单份领域知识两角色用法): build_structure_directive / build_summary_directive 按 businessCode 取 · rwfx(6BF):线性 任务→目的→行为体→预期行为→驱动因素→叙事;预期行为↔驱动因素 1:1、余 1:N · xdfx(7BF):分叉汇聚 DAG,根=行动;行动→受众目标/关键传播节点(1:N)→脆弱点(1:N)→策略(多对一) · 其余业务通用规范(强约束完整性+命名+取数、不套固定模板);business_code 空→零副作用 - 结构化抽取:flow_extract._hierarchy_hint + _validate_messages 用 structure_directive 权威覆盖默认层级(根治"无论什么业务都按目的→行为体抽/停在行为体");前端 streamFlowExtract 传 business_code(源 ingestBusinessCode) - 方案总结报告:前台 multi_agent._special_run(summary) + 后台 build_summary_prompt 注入 business 完整性核对(StartJobRequest/StartParams 透传) - 报告产物策略:.md 报告文件保持完整、干净、无需修改(不写 待补充/不足/⚠️); 「核对说明」(意图对齐+业务链完整性+不足/可补充)改为只在对话回复正文、且每次必出 - 种子 roundtable-structure SOUL 层级顺序改 spec-driven、去 rwfx 写死示例 Tests: test_roundtable_extraction_spec / test_roundtable_summary_prompt Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
53 lines
2.3 KiB
Python
53 lines
2.3 KiB
Python
"""方案总结报告 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
|