sync update from LAN repo (source dhk-1 @ 3b1ec5b4)

This commit is contained in:
gozeros committed 2026-11-05 10:56:34 +08:00
1 parent da6521b6cb
commit 264e2200d6
995 files changed
+148105 -13399

No files matched your search

@@ -10,12 +10,13 @@
角色(``role``):
- ``leader`` —— 总控派活:短决策,关 thinking + low reasoning(首字节快);
**只保留 ``agent_orchestration`` / ``ask_clarification`` / ``present_files``**,
**只保留 ``agent_orchestration`` / ``ask_clarification``**,
其余「干活类」工具(``write_file`` / ``bash`` / ``str_replace`` / ``read_file`` /
``ls`` / ``view_image`` / ``task`` / ``write_todos`` / ``memory`` / ``hindsight_*``)
一律禁用——否则弱模型(如 deepseek-chat)会概率性地**自己写文件、跑 bash 干活**
而不是派活(已在生产日志里观测到总控 ``wc -l outputs/*.md`` 自检自己写的报告)。
总控的唯一职责是「派活 / 澄清 / 收口呈现」,没有任何理由动文件系统或执行命令。
总控的唯一职责是「派活 / 澄清 / 文字收口」,没有任何理由动文件系统、呈现文件
或执行命令。最终收口轮会进一步使用空白名单,物理禁用全部工具。
并配合 ``SkillStopMiddleware`` 在 ``agent_orchestration`` 调用后停图,便于网关从
AIMessage.tool_calls 解析派活列表。
- ``seat`` —— 子智能体交付:开 thinking + medium reasoning;**可写文件**
@@ -61,11 +62,14 @@ from dataclasses import dataclass
# 注意:``seat`` / ``report`` 都包含 ``web_search`` —— 圆桌研讨里联网搜索一律禁用
# (与前端 ``_special_run`` 的 excluded_tools 对齐)。
#
# ``leader`` 用「白名单」思路反推黑名单:总控**只允许** agent_orchestration(派活)、
# ask_clarification(澄清)、present_files(收口呈现子智能体产出的文件)三件事,
# 因此把其余所有工具全部禁掉。关键是 write_file / bash / str_replace —— 留着它们,
# 弱模型会绕过派活直接自己写报告(生产日志已实锤)。memory / hindsight_* 一并禁,
# 配合 ``memory_injection_enabled=False`` 让单例总控不被上轮会话的记忆带偏席位。
# ``leader`` 必须使用真正的白名单。历史上的「白名单思路反推黑名单」会在新增工具时
# 自动泄漏能力,曾导致总控循环调用 page_report_template / glob / grep / skill_manage 等
# 一百余次。``_LEADER_EXCLUDED`` 继续保留为兼容和纵深防御,但安全边界由
# ``_LEADER_ALLOWED`` 决定。
_LEADER_ALLOWED: list[str] = [
"agent_orchestration",
"ask_clarification",
]
_LEADER_EXCLUDED: list[str] = [
"web_search",
"view_image",
@@ -81,6 +85,7 @@ _LEADER_EXCLUDED: list[str] = [
"hindsight_reflect",
"hindsight_retain",
"read_peer_delivery", # 总控靠 _collect_delivery_status 直读各席位,不需要这个席位侧工具
"present_files",
]
# seat:席位**可以写文件**(write_file / str_replace)产出 md 等成品文档,**bash 放开**
# (2026-06 决策,业务需要 bash 跑知识库检索 / Python 辅助分析)。禁派活 / 澄清 /
@@ -175,14 +180,16 @@ _LEADER_SKILL_STOP: list[str] = ["agent_orchestration"]
class RoundtableRunPolicy:
"""一个角色单轮 run 的归一化参数。
与 ``multi_agent._run_payload`` 的入参一一对应:``excluded_tools`` /
``skill_stop_names`` / ``thinking_enabled`` / ``reasoning_effort``。
与 ``multi_agent._run_payload`` 的入参一一对应。``allowed_tools`` 为
``None`` 时沿用普通工具解析;空列表表示物理禁用全部普通工具。
"""
excluded_tools: list[str]
allowed_tools: list[str] | None
skill_stop_names: list[str]
thinking_enabled: bool
reasoning_effort: str
recursion_limit: int
def roundtable_run_policy(role: str) -> RoundtableRunPolicy:
@@ -194,59 +201,75 @@ def roundtable_run_policy(role: str) -> RoundtableRunPolicy:
if role == "leader":
return RoundtableRunPolicy(
excluded_tools=list(_LEADER_EXCLUDED),
allowed_tools=list(_LEADER_ALLOWED),
skill_stop_names=list(_LEADER_SKILL_STOP),
thinking_enabled=False,
reasoning_effort="low",
recursion_limit=1000,
)
if role == "seat":
return RoundtableRunPolicy(
excluded_tools=list(_SEAT_EXCLUDED),
allowed_tools=None,
skill_stop_names=[],
thinking_enabled=True,
reasoning_effort="medium",
recursion_limit=1000,
)
if role == "seat_parallel":
# 同 seat(thinking + medium),但额外禁写文件 / 跑命令(防并行沙箱打架)。
return RoundtableRunPolicy(
excluded_tools=list(_SEAT_PARALLEL_EXCLUDED),
allowed_tools=None,
skill_stop_names=[],
thinking_enabled=True,
reasoning_effort="medium",
recursion_limit=1000,
)
if role == "report":
return RoundtableRunPolicy(
excluded_tools=list(_REPORT_EXCLUDED),
allowed_tools=None,
skill_stop_names=[],
thinking_enabled=True,
reasoning_effort="medium",
recursion_limit=1000,
)
if role == "summary":
return RoundtableRunPolicy(
excluded_tools=list(_SUMMARY_EXCLUDED),
allowed_tools=None,
skill_stop_names=[],
thinking_enabled=True,
reasoning_effort="medium",
recursion_limit=1000,
)
if role == "action_plan":
return RoundtableRunPolicy(
excluded_tools=list(_ACTION_PLAN_EXCLUDED),
allowed_tools=None,
skill_stop_names=[],
thinking_enabled=True,
reasoning_effort="medium",
recursion_limit=1000,
)
if role == "dashboard":
return RoundtableRunPolicy(
excluded_tools=list(_DASHBOARD_EXCLUDED),
allowed_tools=None,
skill_stop_names=[],
thinking_enabled=True,
reasoning_effort="medium",
recursion_limit=1000,
)
if role == "ingest":
return RoundtableRunPolicy(
excluded_tools=list(_INGEST_EXCLUDED),
allowed_tools=None,
skill_stop_names=[],
thinking_enabled=True,
reasoning_effort="medium",
recursion_limit=1000,
)
raise ValueError(
f"unknown roundtable role: {role!r} (expected leader/seat/seat_parallel/report/summary/action_plan/dashboard/ingest)"