From ce18608582867b81cd8b48dcf23c7640eaef60eb Mon Sep 17 00:00:00 2001 From: Agent Workbench Dev Date: Sun, 1 Nov 2026 14:28:57 +0800 Subject: [PATCH] fix: retain diagnostic evidence readers and legacy proposal completion --- CHANGELOG.md | 2 ++ src/shared/contracts/task-control.mjs | 8 +++++--- tests/engine.test.mjs | 7 ++++++- tests/research.test.mjs | 16 +++++++++++++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b66e3b75..c8ec0d4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Windows停止核验处理进程在快照和用户查询之间退出的竞态,仅经新查询确认进程不存在才判定退出;用户权限失败、查询失败或PID复用继续拒绝。 - 所属宿主启动期间的健康探测超时可在原期限内继续只读等待,每次核对原进程创建/用户/程序身份,最终仍须完整连接证明;超时不重启第二个宿主。 +- 只读诊断保留查看原引擎核验、登记工件和REA Evidence的工具,解释故障时仍可取回所属原报告;不重新运行引擎或REA分析,也不把未交付任务标成完成。 +- 兼容没有Task记录的既有手动文件提案:全部审查并应用后正确结束会话,原文件备份与新任务的检查约定继续核对。 - 原目标、检查约定与短句续接独立保存。错误诊断使用只读Run,答复结束保留原任务状态;明确修复要求仍正常执行。 - 审查后继续改为中性系统操作,不再新增通用测试要求。无需测试的文件在审查应用后直接反馈路径,模型文字不替代文件交付或检查通过。 diff --git a/src/shared/contracts/task-control.mjs b/src/shared/contracts/task-control.mjs index e9408162..e74870ae 100644 --- a/src/shared/contracts/task-control.mjs +++ b/src/shared/contracts/task-control.mjs @@ -35,7 +35,8 @@ export function updateTaskContract(task, instruction) { if (current.checks === 'skip') task.constraints.push('用户明确要求无需测试;不得自动扩大为工程测试任务。'); } -export const DIAGNOSTIC_TOOLS = new Set(['inspect_session', 'inspect_project', 'list_files', 'read_file', 'search_files', 'read_artifact', 'inspect_task_plan', 'read_browser_result', 'read_registered_skill']); +export const DIAGNOSTIC_TOOLS = new Set(['inspect_session', 'inspect_project', 'list_files', 'read_file', 'search_files', 'read_artifact', 'inspect_task_plan', 'read_browser_result', 'read_registered_skill', + 'inspect_engine_checks', 'list_research_targets', 'read_research_evidence']); export const AUTOMATIC_CHECK_TOOLS = new Set(['plan_checks', 'run_checks', 'plan_browser', 'run_browser']); export function taskToolAllowed(task, run, tool, args = {}) { @@ -47,9 +48,10 @@ export function taskToolAllowed(task, run, tool, args = {}) { export function settleAppliedTask(store, session) { const task = store.core.task.get(session.taskId); - if (!task || session.changes.some(change => ['pending', 'conflict'].includes(change.status))) return; - const applied = session.changes.filter(change => change.status === 'applied' && (!change.taskId || change.taskId === task.id)); + if (session.changes.some(change => ['pending', 'conflict'].includes(change.status))) return; + const applied = session.changes.filter(change => change.status === 'applied' && (!task || !change.taskId || change.taskId === task.id)); if (!applied.length) return; + if (!task) { if (!session.taskId) session.status = 'completed'; return; } const contract = taskContract(task, id => store.core.task.get(id)); task.delivery = { status: 'files_applied', paths: applied.map(change => change.path), at: new Date().toISOString(), checks: contract.checks === 'skip' ? 'not_requested' : task.verification?.status ?? 'not_configured' }; diff --git a/tests/engine.test.mjs b/tests/engine.test.mjs index c1b70c1d..28fa522d 100644 --- a/tests/engine.test.mjs +++ b/tests/engine.test.mjs @@ -161,6 +161,7 @@ test('model argument validation and runtime activity do not grant external engin test('a follow-up question receives the actual failed engine check from its original Task and keeps its report unchanged', async t => { const f = setup(t, { mode: 'bad-ready' }), job = await f.manager.start(f.session, { root: f.root }).promise; assert.equal(job.status, 'failed'); const originalReport = f.manager.originalReport(f.session, job), taskId = job.taskId; + const originalWireCount = f.audit().length, originalGoal = f.store.core.task.get(taskId).goal; const provider = new Provider(); let requests = 0; provider.complete = async (_config, messages, _project, _signal, _progress, _plan, tools) => { requests++; @@ -176,6 +177,10 @@ test('a follow-up question receives the actual failed engine check from its orig const runtime = new Runtime(f.store, provider); runtime.engines = f.manager; f.onCleanup(() => runtime.stopAll()); runtime.start(f.session.id, '刚才的引擎连接检查为什么报错?'); await runtime.active.get(f.session.id).promise; - assert.equal(f.session.taskId, taskId); assert.equal(f.session.status, 'completed'); assert.equal(requests, 2); + assert.equal(f.session.taskId, taskId); assert.equal(f.session.status, 'paused'); assert.equal(requests, 2); + const diagnostic = f.store.core.run.get(f.session.runId); + assert.equal(diagnostic.purpose, 'diagnostic'); assert.equal(diagnostic.status, 'completed'); assert.equal(diagnostic.stopReason, 'diagnostic_answered'); + assert.equal(f.store.core.task.get(taskId).status, 'paused'); assert.equal(f.store.core.task.get(taskId).goal, originalGoal); + assert.equal(f.audit().length, originalWireCount, 'Reading the failed original report must not start or prompt the external engine again.'); assert.equal(f.manager.originalReport(f.session, job), originalReport); assert.match(f.session.messages.at(-1).content, /当前任务/); }); diff --git a/tests/research.test.mjs b/tests/research.test.mjs index 30d384e2..3cfa3504 100644 --- a/tests/research.test.mjs +++ b/tests/research.test.mjs @@ -168,11 +168,19 @@ test('research tools are only sent for registered Task artifacts and actual HTTP let requests = 0, jobId = null; const model = await compatibleFixture(t, (route, body) => { if (!route.endsWith('/chat/completions')) return { body: {} }; requests++; - assert.ok(body.tools.some(tool => tool.function.name === 'analyze_research_target')); + if (requests <= 3) assert.ok(body.tools.some(tool => tool.function.name === 'analyze_research_target')); + else { + assert.ok(body.tools.some(tool => tool.function.name === 'read_research_evidence')); + assert.ok(body.tools.some(tool => tool.function.name === 'list_research_targets')); + assert.equal(body.tools.some(tool => tool.function.name === 'analyze_research_target'), false); + } const tools = body.messages.filter(value => value.role === 'tool').map(value => JSON.parse(value.content)); if (requests === 1) return { body: completion([call('rea-fixture-analysis', 'analyze_research_target', { target_id: target.id, operation: 'javascript' })]) }; if (requests === 2) { jobId = tools.at(-1).research_job_id; assert.equal(tools.at(-1).evidence_verified, true); return { body: completion([call('rea-fixture-field', 'read_research_evidence', { research_job_id: jobId, pointer: '/normalized_result/graph' })]) }; } + if (requests === 4) { + return { body: completion([call('rea-diagnostic-original-field', 'read_research_evidence', { research_job_id: jobId, pointer: '/normalized_result/graph' })]) }; + } assert.equal(JSON.parse(tools.at(-1).content).nodes[0].name, 'owned entry'); return { body: completion([], '依据原静态Evidence完成机制核对,运行行为尚未观测。') }; }); @@ -180,6 +188,12 @@ test('research tools are only sent for registered Task artifacts and actual HTTP runtime.start(f.session.id, '用登记工件分析机制并核对原图字段。'); await until(() => !runtime.isActive(f.session.id), 20000); assert.equal(f.session.status, 'completed', f.session.failure?.message); assert.equal(requests, 3); assert.equal(f.calls.analyze, 1); assert.equal(f.store.core.research_job.get(jobId).status, 'completed'); assertToolPairs(f.session.providerMessages); + const originalTaskId = f.session.taskId, evidence = structuredClone(f.store.core.research_job.get(jobId).evidence); + runtime.start(f.session.id, '刚才的分析为什么报错?'); await until(() => !runtime.isActive(f.session.id), 20000); + assert.equal(requests, 5); assert.equal(f.calls.analyze, 1); assert.equal(f.session.taskId, originalTaskId); + const diagnostic = f.store.core.run.get(f.session.runId); + assert.equal(diagnostic.purpose, 'diagnostic'); assert.equal(diagnostic.status, 'completed'); assert.equal(diagnostic.stopReason, 'diagnostic_answered'); + assert.deepEqual(f.store.core.research_job.get(jobId).evidence, evidence); assertToolPairs(f.session.providerMessages); assert.throws(() => validateToolArgs('analyze_research_target', { target_id: target.id, operation: 'javascript', path: 'other.exe' }), /已登记/); assert.throws(() => validateToolArgs('analyze_research_target', { target_id: target.id, operation: 'execute' }), /静态分析方式/); const noTarget = f.store.createSession(f.project.id); assert.equal(f.manager.targets(noTarget).length, 0);