fix(agent): require a real deliverable before bypassing failed read checks
This commit is contained in:
parent
36df8c70fb
commit
72fb4ec4be
@ -192,6 +192,13 @@ export async function runZcodeCanvasTask(ports: Ports): Promise<CanvasAgentRunSt
|
||||
// actual outputs below instead of failing a task because an earlier read timed out.
|
||||
if (snapshot.calls.some(call => (call.status === "failed" && !call.rejected && !ports.tools[call.name]?.readOnly) || call.uncertain))
|
||||
return await save("部分工具结果待确认,已保留执行记录,请核对后继续。", "needs_review");
|
||||
const unresolvedRead = snapshot.calls.some((call, index) => call.status === "failed" && !call.rejected &&
|
||||
!snapshot.calls.slice(index + 1).some(later => later.name === call.name && later.status === "succeeded" &&
|
||||
JSON.stringify(later.input) === JSON.stringify(call.input)));
|
||||
// Without a real result to independently inspect, a viewport/UI action
|
||||
// cannot turn a failed analysis into a completed task.
|
||||
if (unresolvedRead && !snapshot.resultNodeIds.length)
|
||||
return await save("图片或资料暂未读取成功,已保留记录,请稍后继续核对。", "needs_review");
|
||||
if (question || snapshot.calls.some(call => call.output?.mode === "interactive"))
|
||||
return await save(question || "请在已打开的工具面板中完成操作,然后继续任务。", "needs_review");
|
||||
const supplements = snapshot.inputs.filter(input => !startedInputs.has(input.id));
|
||||
@ -206,10 +213,6 @@ export async function runZcodeCanvasTask(ports: Ports): Promise<CanvasAgentRunSt
|
||||
// still use the existing independent checks against actual saved nodes.
|
||||
const mutated = snapshot.calls.some(call => !call.rejected && !ports.tools[call.name]?.readOnly);
|
||||
if (!mutated && !snapshot.requirements?.expectedImageCount) {
|
||||
const unresolvedRead = snapshot.calls.some((call, index) => call.status === "failed" && !call.rejected &&
|
||||
!snapshot.calls.slice(index + 1).some(later => later.name === call.name && later.status === "succeeded" &&
|
||||
JSON.stringify(later.input) === JSON.stringify(call.input)));
|
||||
if (unresolvedRead) return await save("图片或资料暂未读取成功,已保留记录,请稍后继续核对。", "needs_review");
|
||||
const expectsChange = /生成|抠图|去背景|换背景|删除|移除|替换|改名|移动|放大|裁剪|旋转|导出|下载|制作|添加|上传/.test(snapshot.objective)
|
||||
&& !/只(?:要|需)?(?:分析|讨论|建议|提示词)|不要(?:执行|生成|修改)/.test(snapshot.objective);
|
||||
return await save(expectsChange ? "尚未执行画布操作,请核对任务计划后继续。" : result.response || "已完成画布分析。", expectsChange ? "needs_review" : "completed");
|
||||
|
||||
@ -153,10 +153,22 @@ let checks = 0;
|
||||
h.ports.native = async options => {
|
||||
await options.execute('planCanvasTask', {}, 'plan', options.signal!);
|
||||
await options.execute('edit', { nodeIds: ['a'] }, 'edit', options.signal!);
|
||||
h.snapshot.resultNodeIds = ['real-result'];
|
||||
await assert.rejects(options.execute('readCanvas', {}, 'failed-read', options.signal!)); return result;
|
||||
};
|
||||
assert.equal(await runZcodeCanvasTask(h.ports), 'needs_review'); assert.match(h.snapshot.message, /实际结果不符合要求/); checks++;
|
||||
}
|
||||
{
|
||||
const h = fixture('分析画布'); let reviews = 0;
|
||||
h.ports.tools.readCanvas.execute = async () => { throw new Error('read timeout'); };
|
||||
h.ports.verify = async () => { reviews++; return { passed: true, issues: [] }; };
|
||||
h.ports.native = async options => {
|
||||
await options.execute('planCanvasTask', {}, 'plan', options.signal!);
|
||||
await assert.rejects(options.execute('readCanvas', {}, 'failed-read', options.signal!));
|
||||
await options.execute('edit', { nodeIds: ['a'] }, 'only-ui-action', options.signal!); return result;
|
||||
};
|
||||
assert.equal(await runZcodeCanvasTask(h.ports), 'needs_review'); assert.equal(reviews, 0); checks++;
|
||||
}
|
||||
{
|
||||
const h = fixture();
|
||||
h.ports.tools.edit.execute = async () => { throw new Error('paid request outcome unknown'); };
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user