fix(agent): honor requests not to download during review

This commit is contained in:
134 2026-10-21 14:05:56 +08:00
parent 05ff5069f9
commit 16b65dc8d0
2 changed files with 5 additions and 1 deletions

View File

@ -3,9 +3,11 @@ import type { AgentCallRecord, AgentRunSnapshot } from "./protocol";
// A spontaneous download command is not an unfinished image edit. Keep genuine
// download requests and all editor panels waiting for their actual interaction.
export function isAncillaryDownload(snapshot: AgentRunSnapshot, call: AgentCallRecord) {
const intent = [snapshot.objective, ...snapshot.inputs.map(input => input.text)].join("\n")
.replace(/(?:不要|无需|不需要|不用|不必|禁止|别)(?:再|主动|自动|继续)?\s*(?:下载|导出|保存.{0,8}(?:本地|电脑))|(?:do\s+not|don't|never)\s+(?:download|export)/gi, "");
return call.name === "image_download" && call.status === "succeeded" &&
call.output?.mode === "interactive" && finalResultNodeIds(snapshot).length > 0 &&
!/下载|导出|保存.*(?:本地|电脑)|download|export/i.test([snapshot.objective, ...snapshot.inputs.map(input => input.text)].join("\n"));
!/下载|导出|保存.*(?:本地|电脑)|download|export/i.test(intent);
}
export function finalImageResultNodeIds(

View File

@ -141,6 +141,8 @@ test("an unsolicited download cannot block verified image results; requested dow
const f = await fixture('{"passed":true,"issues":[]}');
f.params.snapshot.calls.push({ id: "download", name: "image_download", input: {}, status: "succeeded", output: { mode: "interactive" } });
expect((await verifyCanvasAgentResults(f.params)).passed).toBe(true);
f.params.snapshot.inputs.push({ id: "no-download", text: "只核验现有结果,不要下载,不要重新生成", applied: true });
expect((await verifyCanvasAgentResults(f.params)).passed).toBe(true);
f.params.snapshot.objective += "并下载到电脑";
expect((await verifyCanvasAgentResults(f.params)).passed).toBe(false);
f.params.snapshot.objective = "修改图片";