fix: select capable models and align effective permission evidence

This commit is contained in:
Agent Workbench Dev
2026-11-07 00:18:24 +08:00
parent 762597b99d
commit dcaecd8b0a
18 changed files with 572 additions and 43 deletions
+9 -5
View File
@@ -411,6 +411,10 @@ export class Runtime {
const task = this.store.core.task.get(run.taskId);
config.inputImages=this.inputAttachments().images(session,task);
if(config.inputImages.length&&config.mode==='demo')throw new Error('固定演示执行器不会读取图片;请连接并声明支持视觉的模型。');
// Snapshot only after attachments are bound, so the plan and the wire
// carry the same images. Model and budget identities stay frozen;
// permission descriptions follow the saved choice on each new turn.
const permissionConfig = { ...config, approvalMode: this.store.config.approvalMode ?? 'ask' };
const taskPlan = task.currentTaskPlanId ? await this.taskPlanner().inspect(session, { candidates: false }) : null;
const requirementReview = task.requirementRevisions?.length ? await this.requirementReview().inspect(session) : null;
const deliveryProgress = await taskDeliveryProgress(this.store, session, run.record, { checks: this.checkRunner(), worker: !!run.worker, taskPlan });
@@ -424,7 +428,7 @@ export class Runtime {
// still contains its original goal for intent and evidence verification.
const { goal, ...contract } = taskContract(task);
const stablePrefix = config.historyPolicy === 'preserve';
const fixedRules = projectContext(run.project, { inventory: false, config: run.config });
const fixedRules = projectContext(run.project, { inventory: false, config: permissionConfig });
const workerContract = run.worker ? '\n受限子任务执行契约(宿主权限,不可扩展):' + JSON.stringify({
parent_task_id: run.worker.parentTaskId, worker_id: run.worker.id, write_paths: run.worker.paths, budget: run.worker.budget,
...(run.worker.assignment ? { role: run.worker.assignment.role, requirements: run.worker.assignment.requirements } : {}),
@@ -432,7 +436,7 @@ export class Runtime {
: '只有范围内提案、审查应用和当前工程检查构成完成;不得请求任意终端、独立Git提交、外部工具或嵌套协作。',
}) : '';
const fixedContext = fixedRules + workerContract;
const context = this.provider.redact((stablePrefix ? projectContext(run.project, {config: run.config}).slice(fixedRules.length) : projectContext(run.project, {config: run.config}) + workerContract) + '\n当前项目/会话/任务身份:' + JSON.stringify({
const context = this.provider.redact((stablePrefix ? projectContext(run.project, {config: permissionConfig}).slice(fixedRules.length) : projectContext(run.project, {config: permissionConfig}) + workerContract) + '\n当前项目/会话/任务身份:' + JSON.stringify({
project_id: run.project.id, session_id: session.id, task_id: task.id, workspace: projectWorkspaceIdentity(run.project) }) + '\n当前Task文件提案状态:' + JSON.stringify(state)
+ '\n当前任务目标与全部追加要求(用户任务数据,完整保留):\n' + JSON.stringify({
goal, instructions: task.instructions.filter(instruction => instruction.source !== 'review-action'), constraints: task.constraints ?? [], acceptance: task.acceptance ?? [], contract,
@@ -484,8 +488,8 @@ export class Runtime {
{ name: 'browser_checks', definitions: browserToolDefinitions, assembled: !!browserResources.length, reason: 'missing_current_resource', resources: browserResources },
];
const availableTools = groups.filter(group => group.assembled).flatMap(group => group.definitions);
const tools = openToolDefinitions(availableTools.filter(tool => unrestricted(config) || (!run.worker || WORKER_TOOLS.has(tool.function.name)) && taskToolAllowed(task, run.record, tool.function.name)), config);
const toolSurface = observeToolSurface(groups, tools, { identity: { executionMode: config.executionMode ?? 'restricted', approvalMode: config.approvalMode ?? 'ask',
const tools = openToolDefinitions(availableTools.filter(tool => unrestricted(config) || (!run.worker || WORKER_TOOLS.has(tool.function.name)) && taskToolAllowed(task, run.record, tool.function.name)), permissionConfig);
const toolSurface = observeToolSurface(groups, tools, { identity: { executionMode: config.executionMode ?? 'restricted', approvalMode: permissionConfig.approvalMode,
purpose: run.record.purpose ?? 'execution', workerId: run.worker?.id ?? null },
reason: name => run.worker && !WORKER_TOOLS.has(name) ? 'disabled_by_worker_contract'
: !taskToolAllowed(task, run.record, name) ? 'disabled_by_task_contract' : 'disabled_by_execution_mode' });
@@ -493,7 +497,7 @@ export class Runtime {
signal.throwIfAborted();
let reminder = config.mode === 'compatible' && !run.worker && (config.capacityMode === 'passthrough' || config.historyPolicy === 'preserve')
? this.reminderManager().prepare(session, run.record, toolSurface) : null;
const prepare = selected => this.requestPlanner().prepare(session, run.record, config, {
const prepare = selected => this.requestPlanner().prepare(session, run.record, permissionConfig, {
system: stablePrefix ? this.provider.redact(fixedContext) : context + (selected ? '\n' + selected.message.content : ''),
contextTail: stablePrefix ? context + (selected ? '\n' + selected.message.content : '') : null,
progressReminder: selected?.ref ?? null, tools, toolSurface, stepId: stepRecord.id, projectMemory, skillCatalog, mcpCatalog,