feat(roundtable): 会商诊断日志 + 后台挂起卡死兜底(idle 超时)
- 新增会商全流程诊断日志:新表 roundtable_diagnostics + 仓储 + admin API (/api/roundtable-diagnostics) + 管理员诊断页(会商页右上角设置按钮入口), 覆盖第一/二/三步及后台执行器/进程内网关各处报错与关键事件,支持按 范围/阶段/级别/事件/关键词筛选 + 分页。诊断写入全程 best-effort,绝不打断会商。 - 修复后台挂起「执行完第一个席位后永久卡死」:进程内网关每轮 agent run 改为 idle(无活动)超时(默认 20min)——只要还在持续产出 token/工具事件就一直等, 仅当连续无任何输出才判卡死并取消+报错+落 seat_turn_timeout 诊断;慢但活着的 生成绝不打断。可经 ROUNDTABLE_SEAT_IDLE_TIMEOUT_SECONDS 调整。 - 一并提交进行中的会商 seat-skill 注入 / 业务链条编辑器相关改动。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8ca16c74bc
commit
4a403c95c5
27 files changed
+1873
-61
No files matched your search
@@ -0,0 +1,95 @@
|
||||
"""会商第二步席位「技能识别」强化(弱模型友好)。
|
||||
|
||||
痛点:席位是一次自定义 agent run,其配置技能(agent ``config.yaml → skills``)只通过
|
||||
**系统提示**里的 ``<skill_system>`` 块注入(列出 name/description + SKILL.md 路径,靠模型
|
||||
自己 ``read_file`` 并遵循)。强模型会照做;**弱模型(如 deepseek-chat)往往无视系统提示里
|
||||
的技能块,从不 read_file SKILL.md**,于是配置的技能形同虚设——只凭模型自身知识作答。
|
||||
|
||||
解法:在**派给席位的本轮任务消息(human turn)**里,显式把该席位配置的每个技能(名称 +
|
||||
描述 + SKILL.md 容器路径)列出来,并下达硬指令「先 read_file 对应 SKILL.md、按其说明用工具
|
||||
去取信息 / 走流程,再产出交付」。把指令放进 user turn(而非仅系统提示)对弱模型的牵引力
|
||||
强得多——这与本仓已有的弱模型补偿手法(``_SEAT_NO_ASK``、总控派活强化、AI 写作 SKILL.md
|
||||
注入,见 ``project-ai-writing-skill-agent``)一脉相承。
|
||||
|
||||
两条席位执行路径共用本 helper:
|
||||
- 前端手动:``multi_agent._special_run``(seat / seat_parallel 角色);
|
||||
- 后台挂起:``roundtable_inprocess_gateway.InProcessRoundtableGateway.run_seat``。
|
||||
|
||||
无配置技能的席位 → 返回空串(完全无副作用)。可用 ``ROUNDTABLE_SEAT_SKILL_DIRECTIVE=0``
|
||||
全局关闭(默认开)。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_TRUTHY = frozenset({"1", "true", "yes", "on", "y"})
|
||||
|
||||
|
||||
def _directive_enabled() -> bool:
|
||||
"""读 ``ROUNDTABLE_SEAT_SKILL_DIRECTIVE``(默认开)。空 / 未设 = 开。"""
|
||||
return (os.getenv("ROUNDTABLE_SEAT_SKILL_DIRECTIVE") or "1").strip().lower() in _TRUTHY
|
||||
|
||||
|
||||
def build_seat_skill_directive(agent_id: str | None) -> str:
|
||||
"""为某席位 agent 构建「必须先读 SKILL.md 再用技能」的本轮任务追加指令。
|
||||
|
||||
返回 ``""`` 表示无需追加(开关关闭 / 无 agent_id / 该席位没有配置技能 / 解析失败),
|
||||
调用方原样使用任务文本,零副作用。
|
||||
"""
|
||||
if not _directive_enabled() or not agent_id:
|
||||
return ""
|
||||
try:
|
||||
from deerflow.config.agents_config import load_agent_config
|
||||
|
||||
cfg = load_agent_config(agent_id)
|
||||
configured = [name for name in (cfg.skills or []) if name] if cfg else []
|
||||
if not configured:
|
||||
return ""
|
||||
|
||||
from deerflow.skills.storage import get_or_new_skill_storage
|
||||
|
||||
try:
|
||||
from deerflow.config import get_app_config
|
||||
|
||||
container_base_path = get_app_config().skills.container_path
|
||||
except Exception: # noqa: BLE001 — 配置读不到时退回默认挂载路径
|
||||
container_base_path = "/mnt/skills"
|
||||
|
||||
by_name = {s.name: s for s in get_or_new_skill_storage().load_skills(enabled_only=True)}
|
||||
# 保留席位 config 里的配置顺序,剔除已删除 / 未启用的技能名。
|
||||
wanted = [by_name[name] for name in configured if name in by_name]
|
||||
if not wanted:
|
||||
return ""
|
||||
|
||||
lines: list[str] = [
|
||||
"【你已配置以下专属技能,必须优先使用——这是硬性要求,不要只凭自身知识作答】",
|
||||
"完成本轮交付前,请先判断哪些技能与任务相关,**用 read_file 工具读取对应技能的 SKILL.md 全文**,"
|
||||
"严格按其中的说明(检索方式 / 接口 / 流程 / 输出格式)去**获取真实信息或执行处理流程**"
|
||||
"(其中可能要求你调用 bash / write_file 等工具),再据此产出交付:",
|
||||
"",
|
||||
]
|
||||
for i, s in enumerate(wanted, 1):
|
||||
desc = (s.description or "").strip().replace("\n", " ")
|
||||
lines.append(f"{i}. 「{s.name}」{desc}".rstrip())
|
||||
lines.append(f" - 技能说明文件(先 read_file 它):{s.get_container_file_path(container_base_path)}")
|
||||
lines.append("")
|
||||
lines.append(
|
||||
"注意:只要某个技能与本轮任务相关,**务必先 read_file 它的 SKILL.md 并按其指引调用工具**,"
|
||||
"不要跳过技能直接凭记忆回答;技能里写明的接口 / 命令要真正执行,不要假装调用。"
|
||||
)
|
||||
return "\n".join(lines)
|
||||
except Exception: # noqa: BLE001 — 强化失败绝不能拖垮席位本身的执行
|
||||
logger.debug("build seat skill directive failed for agent %s", agent_id, exc_info=True)
|
||||
return ""
|
||||
|
||||
|
||||
def append_seat_skill_directive(agent_id: str | None, task: str) -> str:
|
||||
"""把技能识别指令追加到席位本轮任务文本后(无指令时原样返回)。"""
|
||||
directive = build_seat_skill_directive(agent_id)
|
||||
if not directive:
|
||||
return task
|
||||
return f"{task}\n\n---\n\n{directive}"
|
||||
Reference in new issue
Block a user