fix(runtime): advertise tools according to the existing task contract

This commit is contained in:
Agent Workbench Dev
2026-11-08 00:05:53 +08:00
parent d5207dc6cc
commit 87ca075175
3 changed files with 45 additions and 7 deletions
+4 -2
View File
@@ -488,10 +488,12 @@ 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)), permissionConfig);
// Task intent already controls execution, including open/full mode.
// Advertise the same contract so a diagnostic does not invite writes.
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'
reason: name => run.worker && !unrestricted(config) && !WORKER_TOOLS.has(name) ? 'disabled_by_worker_contract'
: !taskToolAllowed(task, run.record, name) ? 'disabled_by_task_contract' : 'disabled_by_execution_mode' });
const projectMemory = await this.memoryManager().context(session, { redact: value => this.provider.redact(value) });
signal.throwIfAborted();