From 9bb396b0f5bc66117420cd3aa03f255c259cad96 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 17 Nov 2025 11:20:05 -0800 Subject: [PATCH] fix: filter out failure tool if no `--id` (#8754) * fix: filter out failure tool if no `--id` * Update index.tsx --- extensions/cli/src/tools/index.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/extensions/cli/src/tools/index.tsx b/extensions/cli/src/tools/index.tsx index 80a977c80..2c27d84bc 100644 --- a/extensions/cli/src/tools/index.tsx +++ b/extensions/cli/src/tools/index.tsx @@ -40,6 +40,18 @@ import { writeFileTool } from "./writeFile.js"; export type { Tool, ToolCall, ToolParametersSchema }; +/** + * Extract the agent ID from the --id command line flag + */ +function getAgentIdFromArgs(): string | undefined { + const args = process.argv; + const idIndex = args.indexOf("--id"); + if (idIndex !== -1 && idIndex + 1 < args.length) { + return args[idIndex + 1]; + } + return undefined; +} + // Base tools that are always available const BASE_BUILTIN_TOOLS: Tool[] = [ readFileTool, @@ -58,6 +70,21 @@ export async function getAllAvailableTools( ): Promise { const tools = [...BASE_BUILTIN_TOOLS]; + // Filter out ReportFailure tool if no agent ID is present + // (it requires --id to function and will confuse the agent if unavailable) + const agentId = getAgentIdFromArgs(); + if (!agentId) { + const reportFailureIndex = tools.findIndex( + (t) => t.name === reportFailureTool.name, + ); + if (reportFailureIndex !== -1) { + tools.splice(reportFailureIndex, 1); + logger.debug( + `Filtered out ${reportFailureTool.name} tool - no agent ID present (--id flag not provided)`, + ); + } + } + // If model is capable, exclude editTool in favor of multiEditTool const modelState = await serviceContainer.get( SERVICE_NAMES.MODEL,