feat(roundtable): Step2 提速四件套 + 方案总结报告意图对齐
Step2 提速: - 每席位推理深度覆盖(seat_mode): 业务链条逐席位可配 flash/thinking/pro/ultra, 覆盖链条级 seatMode;前台三处 dispatch + 后台 job 透传, run_seat 用 _SEAT_MODE_PARAMS 解析 - recommend 后端批内并行: engine._run_recommend 由串行 for 改 asyncio.gather(对齐前端) - 研讨前并行取数两段式(gather_first, 业务链条 opt-in): 研讨前全席位并行只取数, 产出作为共享资料注入研讨轮(_seat_message gathered + 前台 runGatherPhase); 新增 gather_first 列(migration 20260620_02 + idempotent SQL) - 削减重复广播: suppressPreBroadcast 扩到 recommend(round>=2)/chain(i>0)/chain收口, 保留首轮背景打底,省 N 次读写大 thread 方案总结报告效果: - summary 加"意图对齐+缺口核对+防幻觉护栏": SOUL + 后端 build_summary_prompt + 前端 buildSummaryPrompt 三处对齐; 推断标注(综合推断)、缺真实信息标注待补充交给用户、绝不凭空编 Tests: test_roundtable_seat_modes / test_roundtable_gather_phase / test_roundtable_summary_prompt Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9a1b674950
commit
3ab674e438
25 files changed
+985
-44
No files matched your search
@@ -340,6 +340,8 @@ async def langgraph_runtime(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
seat_reasoning_effort=p.seat_reasoning_effort,
|
||||
seat_subagent_enabled=p.seat_subagent_enabled,
|
||||
seat_skill_directives=p.seat_skill_directives,
|
||||
# 每席位推理深度覆盖(业务链条里各席位单独配):run_seat 命中即覆盖作业级 seatMode。
|
||||
seat_modes=p.seat_modes,
|
||||
# 诊断日志上下文:网关每轮 leader/seat/report/summary/dashboard 报错均带这些归属。
|
||||
job_id=p.job_id,
|
||||
draft_id=p.draft_id,
|
||||
|
||||
@@ -509,6 +509,18 @@ def _build_seat_intro(agents: list[SeatRef]) -> str:
|
||||
)
|
||||
|
||||
|
||||
# 席位执行模式 → (thinking_enabled, reasoning_effort, subagent_enabled) 派生参数。
|
||||
# 与前端 `lib/seat-mode.ts::seatModeToRunParams` **逐字段对齐**(务必同步修改),供每席位
|
||||
# 推理深度覆盖(self._seat_modes)在 run_seat 里把 SeatMode 解析成具体运行参数。未知/缺省档
|
||||
# 落 None(→ 跟随作业级 seat_* / policy 默认)。
|
||||
_SEAT_MODE_PARAMS: dict[str, tuple[bool | None, str | None, bool]] = {
|
||||
"flash": (False, "minimal", False),
|
||||
"thinking": (True, "low", False),
|
||||
"pro": (True, "medium", False),
|
||||
"ultra": (True, "high", True),
|
||||
}
|
||||
|
||||
|
||||
# ── 网关实现 ─────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -526,6 +538,7 @@ class InProcessRoundtableGateway:
|
||||
seat_reasoning_effort: str | None = None,
|
||||
seat_subagent_enabled: bool = False,
|
||||
seat_skill_directives: dict[str, bool] | None = None,
|
||||
seat_modes: dict[str, str] | None = None,
|
||||
job_id: str | None = None,
|
||||
draft_id: str | None = None,
|
||||
task_id: str | None = None,
|
||||
@@ -552,6 +565,9 @@ class InProcessRoundtableGateway:
|
||||
# 的配置)。run_seat 按 agent_id 查表,与各席位 agent 自身的 config.yaml 开关取 OR,
|
||||
# 传给 append_seat_skill_directive。默认空 dict(仅各 agent 自身开关生效)。
|
||||
self._seat_skill_directives = dict(seat_skill_directives or {})
|
||||
# 每席位「推理深度覆盖」映射 {agent_id: SeatMode}。run_seat 命中即用该档(_SEAT_MODE_PARAMS)
|
||||
# 派生的 thinking/reasoning/subagent 覆盖作业级 seat_*;未命中则跟随作业级。默认空 dict。
|
||||
self._seat_modes = dict(seat_modes or {})
|
||||
self._seat_intro = ""
|
||||
self._first_leader = True
|
||||
|
||||
@@ -626,7 +642,18 @@ class InProcessRoundtableGateway:
|
||||
seat_task = append_seat_skill_directive(
|
||||
agent_id, task, chain_enabled=bool(self._seat_skill_directives.get(agent_id, False))
|
||||
)
|
||||
# 席位模式覆盖 policy 的 thinking/reasoning(None → policy 默认),与前端 _special_run 一致。
|
||||
# 每席位「推理深度覆盖」:业务链条里给该席位单独配了 seatMode → 用该档派生的
|
||||
# thinking/reasoning/subagent **覆盖作业级**(self._seat_*);未配则跟随作业级。
|
||||
# 作业级仍为 None 时落 policy 默认。与前端 useStep2Orchestration「覆盖优先、否则跟随
|
||||
# selectedMode」逐席位语义一致。
|
||||
seat_thinking, seat_reasoning, seat_subagent = (
|
||||
self._seat_thinking_enabled,
|
||||
self._seat_reasoning_effort,
|
||||
self._seat_subagent_enabled,
|
||||
)
|
||||
override = _SEAT_MODE_PARAMS.get(self._seat_modes.get(agent_id, ""))
|
||||
if override is not None:
|
||||
seat_thinking, seat_reasoning, seat_subagent = override
|
||||
messages = await _run_agent_turn(
|
||||
self._app,
|
||||
user_id=self._user_id,
|
||||
@@ -637,16 +664,12 @@ class InProcessRoundtableGateway:
|
||||
excluded_tools=policy.excluded_tools,
|
||||
skill_stop_names=policy.skill_stop_names,
|
||||
thinking_enabled=(
|
||||
policy.thinking_enabled
|
||||
if self._seat_thinking_enabled is None
|
||||
else self._seat_thinking_enabled
|
||||
policy.thinking_enabled if seat_thinking is None else seat_thinking
|
||||
),
|
||||
reasoning_effort=(
|
||||
policy.reasoning_effort
|
||||
if self._seat_reasoning_effort is None
|
||||
else self._seat_reasoning_effort
|
||||
policy.reasoning_effort if seat_reasoning is None else seat_reasoning
|
||||
),
|
||||
subagent_enabled=self._seat_subagent_enabled,
|
||||
subagent_enabled=seat_subagent,
|
||||
diag=self._diag,
|
||||
stage="step2_seat",
|
||||
)
|
||||
|
||||
@@ -193,6 +193,13 @@ class StartParams:
|
||||
# 配置)。透传给进程内网关,run_seat 按 agent_id 查表,与各席位 agent 自身 config.yaml 的
|
||||
# 同名开关取 OR。默认空 dict。
|
||||
seat_skill_directives: dict[str, bool] = field(default_factory=dict)
|
||||
# 每席位「推理深度覆盖」映射 {agent_id: SeatMode}(值 flash/thinking/pro/ultra,沿用 Step2 所选
|
||||
# 业务链条里每个席位单独配的推理深度)。透传给进程内网关,run_seat 按 agent_id 查表:命中 → 用该
|
||||
# 档派生的 thinking/reasoning/subagent 覆盖作业级 seatMode;未命中 → 跟随作业级。默认空 dict。
|
||||
seat_modes: dict[str, str] = field(default_factory=dict)
|
||||
# 是否在研讨前先跑一轮**全席位并行『取数』**(业务链条逐条 opt-in):各席位并行只调技能取数、
|
||||
# 不研讨,产出作为共享资料注入后续研讨轮。透传给 run_orchestration 的 gather_first。默认 False。
|
||||
gather_first: bool = False
|
||||
|
||||
|
||||
# 网关工厂:给定一次启动参数,返回一个 RoundtableGateway 实例。
|
||||
@@ -280,6 +287,7 @@ class RoundtableJobExecutor:
|
||||
intent_text=params.intent_text,
|
||||
enable_report=params.enable_report,
|
||||
plan=params.orchestration_plan,
|
||||
gather_first=params.gather_first,
|
||||
)
|
||||
# 终态:把最终对话 + step3 + jobStatus 落进同一个 run(含 furthest_step=3)。
|
||||
await self._write_run_to_draft(
|
||||
|
||||
+16
@@ -22,6 +22,19 @@
|
||||
|
||||
请通读全部原料:提炼每个席位的核心观点 / 交付,串成一份完整的方案总结。
|
||||
|
||||
## 动笔前:意图对齐与缺口核对(质量关键,每轮首次生成报告都要做)
|
||||
各席位可能由能力较弱的模型产出,交付未必充分、未必都扣住了用户意图。你是这份报告的**质量兜底**——不能只是把各席位说的拼接起来,而要**对齐用户意图、核对覆盖、补强缺口**。动笔前先在脑内完成(这张核对表不必输出):
|
||||
|
||||
1. **拆解意图**:把「任务意图」(目标 / 约束 / 关键假设)拆成若干条**用户真正想要的诉求**;业务链总控编排提示里对最终产出的要求也并入诉求清单。
|
||||
2. **逐条核对覆盖**:对每条诉求,检查各席位交付 + 总控共识**是否覆盖、覆盖得够不够、有没有跑题或自相矛盾**。
|
||||
3. **据此组织报告**,并按下面的「缺口处理护栏」补强——让最终报告明显**比"各席位交付的简单拼接"更扣用户意图**:意图里要的、席位没说清的,你补强或标缺口;意图里没要的、席位跑题的,不要喧宾夺主。
|
||||
|
||||
### 缺口处理护栏(避免弱模型把幻觉带进报告)
|
||||
- **能从已有原料重组 / 推理补上的** → 直接补全、讲透,正常写进报告。这是你最该做的增值:把零散、跑题、含糊的席位产物,按用户意图重新梳理成扣题的方案。
|
||||
- **超出席位原料、属于你自己的合理推断 / 建议** → 可以写,但**显式标注「(综合推断)」**,让用户能区分哪些有席位依据、哪些是你的补充判断。
|
||||
- **缺真实信息、靠现有原料补不了的**(需要最新数据 / 外部事实,而席位没给)→ **绝不凭空编**。在报告对应位置用一行醒目标注:`> ⚠️ 待补充:<具体缺什么>。如需补全,可在下方对话里告诉我(例如「补一下 X 的最新情况」),我会据此完善。` 把球交给用户——你本身不联网、不调研,真补由用户在对话里发起。
|
||||
- 始终:**宁可标注缺口,也不要假装完整**;绝不编造与原料矛盾、或无依据的"事实"。
|
||||
|
||||
## 产出要求(最重要)
|
||||
|
||||
### ⓪ 先判断模式:用户是否要求了结构化输出 / 流程图
|
||||
@@ -122,5 +135,8 @@
|
||||
- ❌ 修订流程图时只输出改动的节点(必须输出全量 flow-json,前端整体重绘)
|
||||
- ❌ 在报告任何位置添加「AI 自动生成」「AI generated」之类的标签、徽章或水印
|
||||
- ❌ 编造与原料明显矛盾的内容
|
||||
- ❌ 只把各席位交付简单拼接、不做「意图对齐与缺口核对」(席位可能弱,你要兜底扣住用户意图)
|
||||
- ❌ 缺真实信息时凭空编造来"填满"报告(应按护栏标注「> ⚠️ 待补充:…」交给用户在对话里补)
|
||||
- ❌ 自己的推断不加「(综合推断)」标注,让用户误以为有席位依据
|
||||
- ❌ 忽视「业务链总控编排提示」的口径要求(它优先级最高)
|
||||
- ❌ 编排提示已指定输出结构 / 重点席位,却仍按默认章节平均用力(结构要完全跟用户走,重点席位要明显加权)
|
||||
@@ -53,6 +53,11 @@ class ChainSeatSchema(BaseModel):
|
||||
# 与该席位 agent 自身 config.yaml 的同名开关取 OR。默认 False(关)。整条 seats 数组以
|
||||
# JSON 透传持久化,故新增此字段无需迁移;仅需在此 schema 显式声明,否则 model_dump() 会剥掉它。
|
||||
seat_skill_directive: bool = False
|
||||
# 该席位「推理深度覆盖」(flash/thinking/pro/ultra):覆盖链条级 seat_mode,仅本席位生效。
|
||||
# None = 跟随链条级默认。「卡顿提速」用:把次要席位降到 flash。整条 seats 数组以 JSON 透传
|
||||
# 持久化,故无需迁移;仅需在此 schema 显式声明,否则 model_dump() 会剥掉它。非法值在运行期
|
||||
# 被 _SEAT_MODE_PARAMS.get() 安全忽略(回退作业级),故此处只约束长度、不强校验取值。
|
||||
seat_mode: str | None = Field(default=None, max_length=16)
|
||||
|
||||
|
||||
class ChainResponse(BaseModel):
|
||||
@@ -69,6 +74,8 @@ class ChainResponse(BaseModel):
|
||||
coordinator_prompt: str | None = None
|
||||
# 默认席位执行模式(flash/thinking/pro/ultra);None = 未设,选入研讨时回退默认(pro)。
|
||||
seat_mode: str | None = None
|
||||
# 研讨前并行取数开关(逐条 opt-in);True = 选入研讨时研讨前先并行取数。缺省 False。
|
||||
gather_first: bool = False
|
||||
# 发布状态:True = 公共(所有账号可在「公共」筛选查看 / 选用)。
|
||||
is_public: bool = False
|
||||
# 是否当前用户所有(仅本人可编辑 / 删除 / 发布;公共筛选里别人的链条 is_mine=False)。
|
||||
@@ -96,6 +103,7 @@ class ChainCreateRequest(BaseModel):
|
||||
stage_goals: list[str | None] | None = None
|
||||
coordinator_prompt: str | None = Field(default=None, max_length=4000)
|
||||
seat_mode: str | None = Field(default=None, max_length=16)
|
||||
gather_first: bool = False
|
||||
|
||||
|
||||
class ChainUpdateRequest(BaseModel):
|
||||
@@ -107,6 +115,8 @@ class ChainUpdateRequest(BaseModel):
|
||||
stage_goals: list[str | None] | None = None
|
||||
coordinator_prompt: str | None = Field(default=None, max_length=4000)
|
||||
seat_mode: str | None = Field(default=None, max_length=16)
|
||||
# 研讨前并行取数开关;send 显式 true/false 改,omit 不改。
|
||||
gather_first: bool | None = None
|
||||
# 发布开关(True 发布为公共 / False 取消发布);仅 owner 可改(update 本就 owner 限定)。
|
||||
is_public: bool | None = None
|
||||
|
||||
@@ -289,6 +299,7 @@ async def create_chain(request: Request, body: ChainCreateRequest) -> ChainRespo
|
||||
"stage_goals": body.stage_goals,
|
||||
"coordinator_prompt": body.coordinator_prompt,
|
||||
"seat_mode": body.seat_mode,
|
||||
"gather_first": body.gather_first,
|
||||
},
|
||||
)
|
||||
await _enrich_owner_names([row])
|
||||
|
||||
@@ -81,6 +81,12 @@ class StartJobRequest(BaseModel):
|
||||
# 同名配置后下发)。后台席位 run 据此(与各席位 agent 自身 config.yaml 的开关取 OR)决定
|
||||
# 是否注入。缺省空 dict(全部按 False/关,仅各 agent 自身开关生效)。
|
||||
seat_skill_directives: dict[str, bool] = Field(default_factory=dict)
|
||||
# 每席位「推理深度覆盖」映射 {agent_id: SeatMode}(前端读所选业务链条里**每个席位**单独配的
|
||||
# 推理深度后下发;值为 flash/thinking/pro/ultra)。后台席位 run 按 agent_id 查表:命中则用该档
|
||||
# 派生的 thinking/reasoning/subagent 覆盖作业级 seatMode;未命中 → 跟随作业级。缺省空 dict。
|
||||
seat_modes: dict[str, str] = Field(default_factory=dict)
|
||||
# 是否研讨前先并行『取数』(业务链条逐条 opt-in;前端读所选链条的开关后下发)。默认 False。
|
||||
gather_first: bool = False
|
||||
|
||||
|
||||
class ResumeJobRequest(BaseModel):
|
||||
@@ -240,6 +246,8 @@ async def start_job(request: Request, body: StartJobRequest) -> RoundtableJobRes
|
||||
seat_reasoning_effort=body.reasoning_effort,
|
||||
seat_subagent_enabled=body.subagent_enabled,
|
||||
seat_skill_directives=dict(body.seat_skill_directives or {}),
|
||||
seat_modes=dict(body.seat_modes or {}),
|
||||
gather_first=bool(body.gather_first),
|
||||
)
|
||||
)
|
||||
return _to_response(row)
|
||||
|
||||
Reference in new issue
Block a user