@@ -27,7 +27,7 @@ import { multiEditTool } from "./multiEdit.js";
2727import { readFileTool } from "./readFile.js" ;
2828import { reportFailureTool } from "./reportFailure.js" ;
2929import { runTerminalCommandTool } from "./runTerminalCommand.js" ;
30- import { searchCodeTool } from "./searchCode.js" ;
30+ import { checkIfRipgrepIsInstalled , searchCodeTool } from "./searchCode.js" ;
3131import {
3232 type Tool ,
3333 type ToolCall ,
@@ -57,32 +57,29 @@ const BASE_BUILTIN_TOOLS: Tool[] = [
5757 readFileTool ,
5858 writeFileTool ,
5959 listFilesTool ,
60- searchCodeTool ,
6160 runTerminalCommandTool ,
6261 fetchTool ,
6362 writeChecklistTool ,
64- reportFailureTool ,
6563] ;
6664
65+ const BUILTIN_SEARCH_TOOLS : Tool [ ] = [ searchCodeTool ] ;
66+
6767// Get all builtin tools including dynamic ones, with capability-based filtering
6868export async function getAllAvailableTools (
6969 isHeadless : boolean ,
7070) : Promise < Tool [ ] > {
7171 const tools = [ ...BASE_BUILTIN_TOOLS ] ;
7272
73- // Filter out ReportFailure tool if no agent ID is present
73+ const isRipgrepInstalled = await checkIfRipgrepIsInstalled ( ) ;
74+ if ( isRipgrepInstalled ) {
75+ tools . push ( ...BUILTIN_SEARCH_TOOLS ) ;
76+ }
77+
78+ // Add ReportFailure tool if no agent ID is present
7479 // (it requires --id to function and will confuse the agent if unavailable)
7580 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- }
81+ if ( agentId ) {
82+ tools . push ( reportFailureTool ) ;
8683 }
8784
8885 // If model is capable, exclude editTool in favor of multiEditTool
0 commit comments