feat: 岗位会商独立意图智能体与四项意图 schema
岗位会商 Step 1 改用 position-roundtable-intent 智能体,输出 coreGoals/riskWarnings/keyPoints/strategicSignificance 四项数组;支持单轮多张协助卡、按轮次计澄清上限,并兼容旧会话 objective/constraints 映射。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
ca32a22c0d
commit
f8757d1a43
24 files changed
+1258
-257
No files matched your search
@@ -470,15 +470,64 @@ def _markdown_delivery_changed(
|
||||
return bool(new_signatures - old_signatures)
|
||||
|
||||
|
||||
def _intent_string_list(intent: dict[str, Any], key: str) -> list[str]:
|
||||
"""Return a clean, display-safe string list from a persisted intent field."""
|
||||
value = intent.get(key)
|
||||
if not isinstance(value, list):
|
||||
return []
|
||||
return [item.strip() for item in value if isinstance(item, str) and item.strip()]
|
||||
|
||||
|
||||
def _position_intent_sections(intent: Any) -> dict[str, list[str]]:
|
||||
"""Read both the dedicated position-intent schema and legacy snapshots.
|
||||
|
||||
New position sessions persist the four position-specific fields. Mapping
|
||||
the legacy Step-1 fields keeps already-created sessions executable after
|
||||
this rollout instead of stranding them at the activation gate.
|
||||
"""
|
||||
if not isinstance(intent, dict):
|
||||
return {
|
||||
"coreGoals": [],
|
||||
"riskWarnings": [],
|
||||
"keyPoints": [],
|
||||
"strategicSignificance": [],
|
||||
}
|
||||
has_position_schema = any(
|
||||
key in intent
|
||||
for key in ("coreGoals", "riskWarnings", "keyPoints", "strategicSignificance")
|
||||
)
|
||||
if has_position_schema:
|
||||
return {
|
||||
"coreGoals": _intent_string_list(intent, "coreGoals"),
|
||||
"riskWarnings": _intent_string_list(intent, "riskWarnings"),
|
||||
"keyPoints": _intent_string_list(intent, "keyPoints"),
|
||||
"strategicSignificance": _intent_string_list(intent, "strategicSignificance"),
|
||||
}
|
||||
|
||||
objective = _text_from_keys(intent, ["objective", "goal"])
|
||||
return {
|
||||
"coreGoals": _intent_string_list(intent, "constraints"),
|
||||
"riskWarnings": [],
|
||||
"keyPoints": _intent_string_list(intent, "assumptions"),
|
||||
"strategicSignificance": [objective] if objective else [],
|
||||
}
|
||||
|
||||
|
||||
def _intent_node_answer(intent: Any) -> str:
|
||||
if not isinstance(intent, dict):
|
||||
return "情报分析岗已完成任务意图识别。"
|
||||
objective = _text_from_keys(intent, ["objective", "goal"], "已完成任务意图识别")
|
||||
constraints = intent.get("constraints") if isinstance(intent.get("constraints"), list) else []
|
||||
lines = ["情报分析岗已完成任务意图识别。", f"任务目标:{objective}"]
|
||||
if constraints:
|
||||
lines.append("关键约束:")
|
||||
lines.extend(f"- {item}" for item in constraints if isinstance(item, str) and item.strip())
|
||||
sections = _position_intent_sections(intent)
|
||||
lines = ["情报分析岗已完成任务意图识别。"]
|
||||
labels = (
|
||||
("核心目标", sections["coreGoals"]),
|
||||
("风险提示", sections["riskWarnings"]),
|
||||
("关键要点", sections["keyPoints"]),
|
||||
("战略意义", sections["strategicSignificance"]),
|
||||
)
|
||||
for label, values in labels:
|
||||
if values:
|
||||
lines.append(f"{label}:")
|
||||
lines.extend(f"- {item}" for item in values)
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
@@ -486,6 +535,15 @@ def _has_confirmed_intent(intent: Any) -> bool:
|
||||
"""Only structured Step-1 output may start a frozen business chain."""
|
||||
if not isinstance(intent, dict):
|
||||
return False
|
||||
if any(
|
||||
key in intent
|
||||
for key in ("coreGoals", "riskWarnings", "keyPoints", "strategicSignificance")
|
||||
):
|
||||
required = ("coreGoals", "riskWarnings", "keyPoints", "strategicSignificance")
|
||||
if not all(isinstance(intent.get(key), list) for key in required):
|
||||
return False
|
||||
sections = _position_intent_sections(intent)
|
||||
return bool(sections["coreGoals"] or sections["strategicSignificance"])
|
||||
objective = _text_from_keys(intent, ["objective", "goal"])
|
||||
constraints = intent.get("constraints")
|
||||
return bool(objective and isinstance(constraints, list))
|
||||
@@ -535,8 +593,7 @@ def _build_node_context_text(
|
||||
title = _text_from_keys(task, ["title", "taskName", "name"], "未命名任务")
|
||||
direction = _text_from_keys(task, ["direction", "taskDirection", "category"], "未填写")
|
||||
description = _text_from_keys(task, ["description", "taskContent", "overview", "content"], "暂无任务描述")
|
||||
objective = _text_from_keys(intent, ["objective", "goal"], "暂无意图结论")
|
||||
constraints = intent.get("constraints") if isinstance(intent.get("constraints"), list) else []
|
||||
sections = _position_intent_sections(intent)
|
||||
agent_name, position_id = _seat_meta(session, current)
|
||||
md_required = not _is_intent_position_node(current, _session_intent_position_id(session))
|
||||
lines = [
|
||||
@@ -548,11 +605,16 @@ def _build_node_context_text(
|
||||
f"- 任务描述:{description}",
|
||||
"",
|
||||
"【已识别意图】",
|
||||
f"- 任务目标:{objective}",
|
||||
]
|
||||
if constraints:
|
||||
lines.append("- 关键约束:")
|
||||
lines.extend(f" - {item}" for item in constraints if isinstance(item, str) and item.strip())
|
||||
for label, values in (
|
||||
("核心目标", sections["coreGoals"]),
|
||||
("风险提示", sections["riskWarnings"]),
|
||||
("关键要点", sections["keyPoints"]),
|
||||
("战略意义", sections["strategicSignificance"]),
|
||||
):
|
||||
if values:
|
||||
lines.append(f"- {label}:")
|
||||
lines.extend(f" - {item}" for item in values)
|
||||
lines.extend(
|
||||
[
|
||||
"",
|
||||
@@ -1005,8 +1067,7 @@ async def _build_builtin_prompt(
|
||||
title = _text_from_keys(task, ["title", "taskName", "name"], "未命名任务")
|
||||
direction = _text_from_keys(task, ["direction", "taskDirection", "category"], "未填写")
|
||||
description = _text_from_keys(task, ["description", "taskContent", "overview", "content"], "暂无任务描述")
|
||||
objective = _text_from_keys(intent, ["objective", "goal"], "暂无意图结论")
|
||||
constraints = intent.get("constraints") if isinstance(intent.get("constraints"), list) else []
|
||||
sections = _position_intent_sections(intent)
|
||||
stage_goals = chain.get("stageGoals") if isinstance(chain.get("stageGoals"), list) else []
|
||||
stage_lines = [f"- L-{index + 1}:{goal}" for index, goal in enumerate(stage_goals) if isinstance(goal, str) and goal.strip()]
|
||||
material = await _effective_delivery_material(session, nodes)
|
||||
@@ -1020,11 +1081,16 @@ async def _build_builtin_prompt(
|
||||
f"- 描述:{description}",
|
||||
"",
|
||||
"【情报分析岗已确认的意图】",
|
||||
f"- 核心目标:{objective}",
|
||||
]
|
||||
if constraints:
|
||||
common.append("- 关键约束:")
|
||||
common.extend(f" - {item}" for item in constraints if isinstance(item, str) and item.strip())
|
||||
for label, values in (
|
||||
("核心目标", sections["coreGoals"]),
|
||||
("风险提示", sections["riskWarnings"]),
|
||||
("关键要点", sections["keyPoints"]),
|
||||
("战略意义", sections["strategicSignificance"]),
|
||||
):
|
||||
if values:
|
||||
common.append(f"- {label}:")
|
||||
common.extend(f" - {item}" for item in values)
|
||||
if stage_lines:
|
||||
common.extend(["", "【业务链阶段】", *stage_lines])
|
||||
|
||||
|
||||
Reference in new issue
Block a user