You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"modelDescription": "This tool allows you to apply multiple replace_string_in_file operations in a single call, which is more efficient than calling replace_string_in_file multiple times. It takes an array of replacement operations and applies them sequentially. Each replacement operation has the same parameters as replace_string_in_file: filePath, oldString, newString, and explanation. This tool is ideal when you need to make multiple edits across different files or multiple edits in the same file. The tool will provide a summary of successful and failed operations.",
"description": "A brief explanation of what the multi-replace operation will accomplish."
773
+
},
774
+
"replacements": {
775
+
"type": "array",
776
+
"description": "An array of replacement operations to apply sequentially.",
777
+
"items": {
778
+
"type": "object",
779
+
"properties": {
780
+
"explanation": {
781
+
"type": "string",
782
+
"description": "A brief explanation of this specific replacement operation."
783
+
},
784
+
"filePath": {
785
+
"type": "string",
786
+
"description": "An absolute path to the file to edit."
787
+
},
788
+
"oldString": {
789
+
"type": "string",
790
+
"description": "The exact literal text to replace, preferably unescaped. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string is not the exact literal text or does not match exactly, this replacement will fail."
791
+
},
792
+
"newString": {
793
+
"type": "string",
794
+
"description": "The exact literal text to replace `oldString` with, preferably unescaped. Provide the EXACT text. Ensure the resulting code is correct and idiomatic."
Copy file name to clipboardExpand all lines: src/extension/prompts/node/agent/agentInstructions.tsx
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,8 @@ export class DefaultAgentPrompt extends PromptElement<DefaultAgentPromptProps> {
143
143
{tools.hasReplaceStringTool ?
144
144
<>
145
145
Before you edit an existing file, make sure you either already have it in the provided context, or read it with the {ToolName.ReadFile} tool, so that you can make proper changes.<br/>
146
-
Use the {ToolName.ReplaceString} tool to edit files, paying attention to context to ensure your replacement is unique. You can use this tool multiple times per file.<br/>
146
+
{hasMultiReplaceStringTool&&<>Prefer the {ToolName.MultiReplaceString} tool when you need to make multiple string replacements across one or more files in a single operation. This is significantly more efficient than calling {ToolName.ReplaceString} multiple times and should be your first choice for: fixing similar patterns across files, applying consistent formatting changes, bulk refactoring operations, or any scenario where you need to make the same type of change in multiple places.<br/></>}
147
+
Use the {ToolName.ReplaceString} tool for single string replacements, paying attention to context to ensure your replacement is unique.<br/>
147
148
Use the {ToolName.EditFile} tool to insert code into a file ONLY if {ToolName.ReplaceString} has failed.<br/>
148
149
When editing files, group your changes by file.<br/>
149
150
{isGpt5&&<>Make the smallest set of edits needed and avoid reformatting or moving unrelated code. Preserve existing style and conventions, and keep imports, exports, and public APIs stable unless the task requires changes. Prefer completing all edits for a file within a single message when practical.<br/></>}
@@ -313,15 +314,16 @@ export class AlternateGPTPrompt extends PromptElement<DefaultAgentPromptProps> {
313
314
When editing files, group your changes by file.<br/>
314
315
{isGpt5&&<>Make the smallest set of edits needed and avoid reformatting or moving unrelated code. Preserve existing style and conventions, and keep imports, exports, and public APIs stable unless the task requires changes. Prefer completing all edits for a file within a single message when practical.<br/></>}
315
316
NEVER show the changes to the user, just call the tool, and the edits will be applied and shown to the user.<br/>
316
-
NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString} or {ToolName.EditFile} instead.<br/>
317
-
For each file, give a short description of what needs to be changed, then use the {ToolName.ReplaceString} or {ToolName.EditFile} tools. You can use any tool multiple times in a response, and you can keep writing text after using a tool.<br/></> :
317
+
NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString}, {ToolName.MultiReplaceString}, or {ToolName.EditFile} instead.<br/>
318
+
For each file, give a short description of what needs to be changed, then use the {ToolName.ReplaceString}, {ToolName.MultiReplaceString}, or {ToolName.EditFile} tools. You can use any tool multiple times in a response, and you can keep writing text after using a tool.<br/></> :
318
319
<>
319
320
Don't try to edit an existing file without reading it first, so you can make changes properly.<br/>
321
+
{hasMultiReplaceStringTool&&<>Prefer the {ToolName.MultiReplaceString} tool when you need to make multiple string replacements across one or more files in a single operation. This should be your first choice for bulk edits.<br/></>}
320
322
Use the {ToolName.ReplaceString} tool to edit files. When editing files, group your changes by file.<br/>
321
323
{isGpt5&&<>Make the smallest set of edits needed and avoid reformatting or moving unrelated code. Preserve existing style and conventions, and keep imports, exports, and public APIs stable unless the task requires changes. Prefer completing all edits for a file within a single message when practical.<br/></>}
322
324
NEVER show the changes to the user, just call the tool, and the edits will be applied and shown to the user.<br/>
323
-
NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString} instead.<br/>
324
-
For each file, give a short description of what needs to be changed, then use the {ToolName.ReplaceString} tool. You can use any tool multiple times in a response, and you can keep writing text after using a tool.<br/>
325
+
NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString}or {ToolName.MultiReplaceString}instead.<br/>
326
+
For each file, give a short description of what needs to be changed, then use the {ToolName.ReplaceString}or {ToolName.MultiReplaceString}tool. You can use any tool multiple times in a response, and you can keep writing text after using a tool.<br/>
325
327
</>}
326
328
<GenericEditingTips{...this.props}/>
327
329
The {ToolName.EditFile} tool is very smart and can understand how to apply your edits to the user's files, you just need to provide minimal hints.<br/>
this.logService.logger.info('Found "replace_string_in_file" in next_tool_prediction, adding reminder');
230
+
//reminderText = '\n\n<reminder>\nIf you need to make multiple edits using replace_string_in_file tool, consider making them in parallel whenever possible.\n</reminder>';
231
+
reminderText='';
232
+
}else{
233
+
this.logService.logger.info('No "replace_string_in_file" found in next_tool_prediction');
234
+
}
235
+
}else{
236
+
this.logService.logger.info('No next_tool_prediction found or not an array');
237
+
}
238
+
}catch(error){
239
+
// If parsing fails, continue with original result
240
+
this.logService.logger.warn('Failed to parse tool arguments for next_tool_prediction check');
0 commit comments