From 16b65dc8d08c1c974d02c85180523c1e63a72c98 Mon Sep 17 00:00:00 2001 From: 134 Date: Wed, 21 Oct 2026 14:05:56 +0800 Subject: [PATCH] fix(agent): honor requests not to download during review --- lib/ai/canvas-agent-runtime/results.ts | 4 +++- tests/routes/canvas-agent-runtime-review.test.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ai/canvas-agent-runtime/results.ts b/lib/ai/canvas-agent-runtime/results.ts index a3a2ca98c..e62bb8847 100644 --- a/lib/ai/canvas-agent-runtime/results.ts +++ b/lib/ai/canvas-agent-runtime/results.ts @@ -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( diff --git a/tests/routes/canvas-agent-runtime-review.test.ts b/tests/routes/canvas-agent-runtime-review.test.ts index 05358f860..77359c543 100644 --- a/tests/routes/canvas-agent-runtime-review.test.ts +++ b/tests/routes/canvas-agent-runtime-review.test.ts @@ -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 = "修改图片";