Skip to content

Commit 9bb396b

Browse files
fix: filter out failure tool if no --id (#8754)
* fix: filter out failure tool if no `--id` * Update index.tsx
1 parent d8cc0b6 commit 9bb396b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

extensions/cli/src/tools/index.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ import { writeFileTool } from "./writeFile.js";
4040

4141
export type { Tool, ToolCall, ToolParametersSchema };
4242

43+
/**
44+
* Extract the agent ID from the --id command line flag
45+
*/
46+
function getAgentIdFromArgs(): string | undefined {
47+
const args = process.argv;
48+
const idIndex = args.indexOf("--id");
49+
if (idIndex !== -1 && idIndex + 1 < args.length) {
50+
return args[idIndex + 1];
51+
}
52+
return undefined;
53+
}
54+
4355
// Base tools that are always available
4456
const BASE_BUILTIN_TOOLS: Tool[] = [
4557
readFileTool,
@@ -58,6 +70,21 @@ export async function getAllAvailableTools(
5870
): Promise<Tool[]> {
5971
const tools = [...BASE_BUILTIN_TOOLS];
6072

73+
// Filter out ReportFailure tool if no agent ID is present
74+
// (it requires --id to function and will confuse the agent if unavailable)
75+
const agentId = getAgentIdFromArgs();
76+
if (!agentId) {
77+
const reportFailureIndex = tools.findIndex(
78+
(t) => t.name === reportFailureTool.name,
79+
);
80+
if (reportFailureIndex !== -1) {
81+
tools.splice(reportFailureIndex, 1);
82+
logger.debug(
83+
`Filtered out ${reportFailureTool.name} tool - no agent ID present (--id flag not provided)`,
84+
);
85+
}
86+
}
87+
6188
// If model is capable, exclude editTool in favor of multiEditTool
6289
const modelState = await serviceContainer.get<ModelServiceState>(
6390
SERVICE_NAMES.MODEL,

0 commit comments

Comments
 (0)