@@ -40,6 +40,18 @@ import { writeFileTool } from "./writeFile.js";
4040
4141export 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
4456const 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