diff --git a/src/core/prompts/responses.ts b/src/core/prompts/responses.ts
index 21703684b8..e25b99d5f7 100644
--- a/src/core/prompts/responses.ts
+++ b/src/core/prompts/responses.ts
@@ -36,6 +36,64 @@ Otherwise, if you have not completed the task and do not need additional informa
missingToolParameterError: (paramName: string) =>
`Missing value for required parameter '${paramName}'. Please retry with complete response.\n\n${toolUseInstructionsReminder}`,
+ applyDiffMissingParamError: (isLegacyMode: boolean) => {
+ const errorType = isLegacyMode
+ ? "legacy 'path' and 'diff' (must be valid and non-empty)"
+ : "args (must contain at least one valid file element)"
+
+ const example = isLegacyMode
+ ? `# Example for apply_diff (legacy mode):
+
+
+src/example.js
+
+<<<<<<< SEARCH
+:start_line:10
+-------
+const oldFunction = () => {
+ return "old value";
+};
+=======
+const newFunction = () => {
+ return "new value";
+};
+>>>>>>> REPLACE
+
+`
+ : `# Example for apply_diff:
+
+
+
+
+ src/example.js
+
+
+<<<<<<< SEARCH
+:start_line:10
+-------
+const oldFunction = () => {
+ return "old value";
+};
+=======
+const newFunction = () => {
+ return "new value";
+};
+>>>>>>> REPLACE
+
+ 10
+
+
+
+`
+
+ return `Missing value for required parameter '${errorType}'. Please retry with complete response.
+
+${example}
+
+Note: The search content must match the file content EXACTLY, including whitespace and indentation.
+Use the read_file tool first if you need to verify the current file content.`
+ },
+
lineCountTruncationError: (actualLineCount: number, isNewFile: boolean, diffStrategyEnabled: boolean = false) => {
const truncationMessage = `Note: Your response may have been truncated because it exceeded your output limit. You wrote ${actualLineCount} lines of content, but the line_count parameter was either missing or not included in your response.`
diff --git a/src/core/tools/multiApplyDiffTool.ts b/src/core/tools/multiApplyDiffTool.ts
index 08bce08ede..0450f31833 100644
--- a/src/core/tools/multiApplyDiffTool.ts
+++ b/src/core/tools/multiApplyDiffTool.ts
@@ -192,11 +192,7 @@ Original error: ${errorMessage}`
// Neither new XML args nor old path/diff params are sufficient
cline.consecutiveMistakeCount++
cline.recordToolError("apply_diff")
- const errorMsg = await cline.sayAndCreateMissingParamError(
- "apply_diff",
- "args (or legacy 'path' and 'diff' parameters)",
- )
- pushToolResult(errorMsg)
+ pushToolResult(formatResponse.applyDiffMissingParamError(false))
cline.processQueuedMessages()
return
}
@@ -205,14 +201,7 @@ Original error: ${errorMessage}`
if (Object.keys(operationsMap).length === 0) {
cline.consecutiveMistakeCount++
cline.recordToolError("apply_diff")
- pushToolResult(
- await cline.sayAndCreateMissingParamError(
- "apply_diff",
- usingLegacyParams
- ? "legacy 'path' and 'diff' (must be valid and non-empty)"
- : "args (must contain at least one valid file element)",
- ),
- )
+ pushToolResult(formatResponse.applyDiffMissingParamError(usingLegacyParams))
cline.processQueuedMessages()
return
}