fix: filter out failure tool if no --id (#8754)

* fix: filter out failure tool if no `--id`

* Update index.tsx
This commit is contained in:
Patrick Erichsen 2025-11-17 11:20:05 -08:00 • committed by GitHub
parent d8cc0b69d2
commit 9bb396b0f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<Tool[]> {
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<ModelServiceState>(
SERVICE_NAMES.MODEL,