fix: hand off complete changes and retain verified source context

This commit is contained in:
Agent Workbench Dev
2026-11-03 07:58:13 +08:00
parent 876df5f421
commit c1521e6cd2
35 changed files with 669 additions and 79 deletions
+18
View File
@@ -498,6 +498,7 @@ export class Runtime {
this.store.save(session); return;
}
let deliveryReview = null, mcpReview = null;
const preparedSets = new Set();
for (const call of calls) {
let result;
if (deliveryReview || mcpReview) {
@@ -513,6 +514,7 @@ export class Runtime {
else if (signal.aborted) result = { status: 'interrupted', message: '用户停止了任务,这次调用没有执行。' };
else result = await this.executeTool(session, call, run);
session.providerMessages.push({ role: 'tool', tool_call_id: call.id, content: JSON.stringify(result) });
if (call.function.name === 'prepare_change_set' && result.status === 'awaiting_review') preparedSets.add(result.change_set_id);
if (call.function.name === 'call_registered_mcp' && result.requires_verification) mcpReview = result.mcp_job_id;
if (call.function.name === 'plan_delivery' && result.status === 'awaiting_review') {
deliveryReview = this.store.owned('delivery_plan', result.plan_id, session.id);
@@ -534,6 +536,22 @@ export class Runtime {
this.store.save(session, { type: 'delivery.awaiting_review', detail: { planId: deliveryReview.id } });
return;
}
// Settle the whole model turn first: later proposals can make a sealed
// set partial, and later tools may fail or need verification/stop.
for (const id of preparedSets) {
let ready = false;
try { ready = await this.changeSetManager().reviewReady(session, id, run.record); }
catch (error) {
this.store.event(session, { kind: 'system', source: 'workbench', label: '变更批次交接预检未通过', phase: 'failed',
output: this.provider.redact(error.message ?? String(error)) });
}
signal.throwIfAborted();
if (!ready) continue;
session.status = 'needs_review'; run.stopReason = 'change_set_review';
this.store.message(session, 'system', '当前任务的完整变更批次已封存,同轮工具结果已保存。请审查并应用或撤销批次;等待审查期间不继续请求模型。应用后可显式续接原任务进行检查。');
this.store.save(session, { type: 'change_set.awaiting_review', detail: { changeSetId: id } });
return;
}
if (this.store.core.task.get(run.taskId).readProgress?.pause) throw new BudgetExceeded('no_progress',
'模型连续重复读取工件或核对相同的工程状态,未推进当前任务。实际结果和原任务已保存,请核对后继续。');
}