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."
755
+
},
756
+
"replacements": {
757
+
"type": "array",
758
+
"description": "An array of replacement operations to apply sequentially.",
759
+
"items": {
760
+
"type": "object",
761
+
"properties": {
762
+
"explanation": {
763
+
"type": "string",
764
+
"description": "A brief explanation of this specific replacement operation."
765
+
},
766
+
"filePath": {
767
+
"type": "string",
768
+
"description": "An absolute path to the file to edit."
769
+
},
770
+
"oldString": {
771
+
"type": "string",
772
+
"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."
773
+
},
774
+
"newString": {
775
+
"type": "string",
776
+
"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
+16-11Lines changed: 16 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -129,13 +129,15 @@ export class DefaultAgentPrompt extends PromptElement<DefaultAgentPromptProps> {
129
129
{tools[ToolName.ReplaceString] ?
130
130
<>
131
131
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/>
132
-
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/>
133
-
Use the {ToolName.EditFile} tool to insert code into a file ONLY if {ToolName.ReplaceString} has failed.<br/>
132
+
{tools[ToolName.MultiReplaceString]
133
+
? <>Use the {ToolName.ReplaceString} tool for single string replacements, paying attention to context to ensure your replacement is unique. 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/></>
134
+
: <>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/></>}
135
+
Use the {ToolName.EditFile} tool to insert code into a file ONLY if {tools[ToolName.MultiReplaceString] ? `${ToolName.MultiReplaceString}/` : ''}{ToolName.ReplaceString} has failed.<br/>
134
136
When editing files, group your changes by file.<br/>
135
137
{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/></>}
136
138
NEVER show the changes to the user, just call the tool, and the edits will be applied and shown to the user.<br/>
137
-
NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString} or {ToolName.EditFile} instead.<br/>
138
-
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/></>
139
+
NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString}{tools[ToolName.MultiReplaceString] ? `, ${ToolName.MultiReplaceString},` : ''} or {ToolName.EditFile} instead.<br/>
140
+
For each file, give a short description of what needs to be changed, then use the {ToolName.ReplaceString}{tools[ToolName.MultiReplaceString] ? `, ${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/></>
139
141
: <>
140
142
Don't try to edit an existing file without reading it first, so you can make changes properly.<br/>
141
143
Use the {ToolName.EditFile} tool to edit files. When editing files, group your changes by file.<br/>
@@ -655,20 +657,22 @@ export class AlternateGPTPrompt extends PromptElement<DefaultAgentPromptProps> {
655
657
{tools[ToolName.ReplaceString] ?
656
658
<>
657
659
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/>
658
-
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/>
659
-
Use the {ToolName.EditFile} tool to insert code into a file ONLY if {ToolName.ReplaceString} has failed.<br/>
660
+
{tools[ToolName.MultiReplaceString]
661
+
? <>Use the {ToolName.ReplaceString} tool for single string replacements, paying attention to context to ensure your replacement is unique. 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/></>
662
+
: <>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/></>}
663
+
Use the {ToolName.EditFile} tool to insert code into a file ONLY if {tools[ToolName.MultiReplaceString] ? `${ToolName.MultiReplaceString}/` : ''}{ToolName.ReplaceString} has failed.<br/>
660
664
When editing files, group your changes by file.<br/>
661
665
{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/></>}
662
666
NEVER show the changes to the user, just call the tool, and the edits will be applied and shown to the user.<br/>
663
-
NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString} or {ToolName.EditFile} instead.<br/>
664
-
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/></> :
667
+
NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString}{tools[ToolName.MultiReplaceString] ? `, ${ToolName.MultiReplaceString},` : ''} or {ToolName.EditFile} instead.<br/>
668
+
For each file, give a short description of what needs to be changed, then use the {ToolName.ReplaceString}{tools[ToolName.MultiReplaceString] ? `, ${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/></> :
665
669
<>
666
670
Don't try to edit an existing file without reading it first, so you can make changes properly.<br/>
667
-
Use the {ToolName.ReplaceString} tool to edit files. When editing files, group your changes by file.<br/>
671
+
Use the {ToolName.EditFile} tool to edit files. When editing files, group your changes by file.<br/>
668
672
{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/></>}
669
673
NEVER show the changes to the user, just call the tool, and the edits will be applied and shown to the user.<br/>
670
-
NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString} instead.<br/>
671
-
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/>
674
+
NEVER print a codeblock that represents a change to a file, use {ToolName.EditFile} instead.<br/>
675
+
For each file, give a short description of what needs to be changed, then use the {ToolName.EditFile} tool. You can use any tool multiple times in a response, and you can keep writing text after using a tool.<br/>
672
676
</>}
673
677
<GenericEditingTips{...this.props}/>
674
678
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/>
@@ -857,6 +861,7 @@ export class SweBenchAgentPrompt extends PromptElement<DefaultAgentPromptProps>
{ToolName.ReplaceString} tool is a tool for editing files. For moving or renaming files, you should generally use the {ToolName.CoreRunInTerminal} with the 'mv' command instead. For larger edits, split it into small edits and call the edit tool multiple times to finish the whole edit carefully.<br/>
864
+
{tools[ToolName.MultiReplaceString]&&<>Use the {ToolName.MultiReplaceString} tool when you need to make multiple string replacements across one or more files in a single operation.<br/></>}
860
865
Before using {ToolName.ReplaceString} tool, you must use {ToolName.ReadFile} tool to understand the file's contents and context you want to edit<br/>
861
866
To make a file edit, provide the following:<br/>
862
867
1. filePath: The absolute path to the file to modify (must be absolute, not relative)<br/>
0 commit comments