fix: 会商第二步只对可预览成品出文件卡/开沙箱,去掉干预并发送按钮

This commit is contained in:
董宏凯 committed 2026-08-30 20:02:21 +08:00
1 parent 7066798ab0
commit b92a26cdd4
3 files changed
+41 -29

No files matched your search

@@ -29,6 +29,7 @@ import {
} from "@/roundtable-planning/api/multi-agent";
import { isValidSeatDelivery, stripReasoning } from "@/roundtable-planning/lib/reasoning";
import { uploadFiles } from "@/core/uploads/api";
import { languageOfStreamingArtifact } from "@/core/artifacts/streaming-write-preview";
import { useUpdateSubtask } from "@/core/tasks/context";
/** 干预消息携带的上传文件引用(与 streamMultiAgent 的 files 字段同形)。 */
@@ -924,6 +925,9 @@ export function useStep2Orchestration(
? ((tc.args as { path?: string }).path as string)
: "";
if (!path) continue;
// 同 handleArtifactToolPhase 的门槛:跳过 .py/.txt 等过程文件与畸形路径,
// 沙箱跟随只落在该席位最近的**成品**文件上。
if (!languageOfStreamingArtifact(path)) continue;
const virtualUrl = buildWriteFileVirtualUrl(path, stub.id, tc.id);
// manual:false —— 沙箱跟随是系统行为,强制打开但**不**关闭 autoSelect(否则毒化
// 后续实时自动打开,见 openSeatVirtualArtifact 注释)。
@@ -1065,6 +1069,8 @@ export function useStep2Orchestration(
if (toolName === "write_file" || toolName === "str_replace") {
const path = step.args?.path;
if (typeof path !== "string" || !step.args) return;
// 与 MessageStepsCard 的可点判定同一道门槛:过程文件/畸形路径点了不开沙箱。
if (!languageOfStreamingArtifact(path)) return;
const { messageId, toolCallId } = upsertSeatToolCall(
seatThreadId,
toolName,
@@ -1116,6 +1122,10 @@ export function useStep2Orchestration(
}
return;
}
// 与主聊天 ArtifactWriteToolCall 的流式预览同一道门槛:只有 .md/.html/.mermaid
// 等可预览产物才自动打开沙箱。席位写的过程文件(fetch.py / r*.txt)与无扩展名的
// 畸形路径不再触发自动预览,免得右侧沙箱被无意义文件反复抢占。
if (!languageOfStreamingArtifact(path)) return;
const { messageId, toolCallId } = upsertSeatToolCall(
seatThreadId,
toolName as string,
@@ -1972,11 +1982,9 @@ export function useStep2Orchestration(
// 第 2 轮起(已有席位交付)才是「综合轮」:让后端注入各席位完整交付供总控收口。
// 首轮纯派活、无交付,传 false 保持上下文精简。
synthesisMode: safetyCounter > 1,
// 削减重复广播(2026-06-20):首轮(safetyCounter==1)保留预广播——它把任务背景播进各席位
// thread,为席位打底;第 2 轮起的续轮/综合广播是「总控收到:<续轮 prompt>」纯噪声 + N 次
// 读写巨大席位 thread 的纯浪费(还会让弱模型从历史模仿派活),故 suppress。席位的前序交付
// 另经「席位交付广播」(broadcastSeatDeliveryToOthers)送达,不受影响。
suppressPreBroadcast: safetyCounter > 1,
// 总控 prompt 含派活/编排指令,只能进入总控 thread。任何轮次都禁止广播到席位历史,
// 否则弱模型会模仿总控并声称要加载编排技能。席位上下文由具体 task 与交付广播提供。
suppressPreBroadcast: true,
// 用户随干预上传的参考文件(consume-once:仅首轮 leader 带,之后清空)。
files: takeOnce(pendingInjectFilesRef),
model: selectedModelRef.current || undefined,
@@ -2257,10 +2265,9 @@ export function useStep2Orchestration(
dAgentThreadId: ids,
agentName: coord,
newMessage: leaderTask,
// 削减重复广播(2026-06-20):首个席位(i===0)保留预广播为其打底任务背景;从第 2 个席位起
// suppress——后续席位的前序交付已由「席位交付广播」送达其 thread,总控派活 prompt 再播一遍
// 是 N 次读写巨大 thread 的纯浪费(还会让弱模型模仿派活)。
suppressPreBroadcast: i > 0,
// 链条首轮同样不能把「请总控调用 agent_orchestration」广播进席位 thread。
// 当前席位拿到的是总控生成的具体 task,后续席位再通过交付广播承接上下文。
suppressPreBroadcast: true,
// 用户随干预上传的参考文件(consume-once:仅首轮 leader 带,之后清空)。
files: takeOnce(pendingInjectFilesRef),
model: selectedModelRef.current || undefined,