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
fix: improve diff editing error messages for Qwen3 model compatibility
- Clarified error messages to distinguish between diff structure markers and file content
- Added explicit guidance that diff markers should NEVER be escaped in the structure
- Emphasized that escaping is only needed for markers within file content being modified
- Maintained backward compatibility with existing test expectations
This fixes issue #7247 where Qwen3 235B model was confused by error messages
and tried to escape diff structure markers, causing diff editing to fail.
Copy file name to clipboardExpand all lines: src/core/diff/strategies/multi-file-search-replace.ts
+24-13Lines changed: 24 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -104,6 +104,12 @@ If you're not confident in the exact content to search for, use the read_file to
104
104
When applying the diffs, be extra careful to remember to change any closing brackets or other syntax that may be affected by the diff farther down in the file.
105
105
ALWAYS make as many changes in a single 'apply_diff' request as possible using multiple SEARCH/REPLACE blocks
106
106
107
+
**IMPORTANT ESCAPING RULES:**
108
+
- The diff structure markers (<<<<<<< SEARCH, =======, >>>>>>> REPLACE) should NEVER be escaped - they define the diff structure
109
+
- ONLY escape these patterns when they appear in the actual file content you're searching for or replacing
110
+
- Example: If you're removing merge conflict markers from a file, escape them in the SEARCH content: \\=======
111
+
- Do NOT escape the ======= that separates your SEARCH and REPLACE sections
112
+
107
113
Parameters:
108
114
- args: Contains one or more file elements, where each file contains:
109
115
- path: (required) The path of the file to modify (relative to the current workspace directory ${args.cwd})
@@ -266,37 +272,42 @@ Each file requires its own path, start_line, and diff elements.
266
272
`ERROR: Special marker '${found}' found in your diff content at line ${state.line}:\n`+
267
273
"\n"+
268
274
`When removing merge conflict markers like '${found}' from files, you MUST escape them\n`+
269
-
"in your SEARCH section by prepending a backslash (\\) at the beginning of the line:\n"+
275
+
"in your SEARCH section by prepending a backslash (\\) at the beginning of the line.\n"+
276
+
"\n"+
277
+
"IMPORTANT CLARIFICATION:\n"+
278
+
"- ONLY escape these patterns when they appear in the actual file content you're modifying\n"+
279
+
"- The diff structure markers themselves (<<<<<<< SEARCH, =======, >>>>>>> REPLACE) should NEVER be escaped\n"+
270
280
"\n"+
271
281
"CORRECT FORMAT:\n\n"+
272
282
"<<<<<<< SEARCH\n"+
273
283
"content before\n"+
274
-
`\\${found} <-- Note the backslash here in this example\n`+
284
+
`\\${found} <-- Escape ONLY when this is part of the file content\n`+
275
285
"content after\n"+
276
286
"=======\n"+
277
287
"replacement content\n"+
278
288
">>>>>>> REPLACE\n"+
279
289
"\n"+
280
-
"Without escaping, the system confuses your content with diff syntax markers.\n"+
281
-
"You may use multiple diff blocks in a single diff request, but ANY of ONLY the following separators that occur within SEARCH or REPLACE content must be escaped, as follows:\n"+
282
-
`\\${SEARCH}\n`+
283
-
`\\${SEP}\n`+
284
-
`\\${REPLACE}\n`,
290
+
"Without escaping, the system confuses your content with diff syntax markers.",
Copy file name to clipboardExpand all lines: src/core/diff/strategies/multi-search-replace.ts
+24-13Lines changed: 24 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,12 @@ If you're not confident in the exact content to search for, use the read_file to
99
99
When applying the diffs, be extra careful to remember to change any closing brackets or other syntax that may be affected by the diff farther down in the file.
100
100
ALWAYS make as many changes in a single 'apply_diff' request as possible using multiple SEARCH/REPLACE blocks
101
101
102
+
**IMPORTANT ESCAPING RULES:**
103
+
- The diff structure markers (<<<<<<< SEARCH, =======, >>>>>>> REPLACE) should NEVER be escaped - they define the diff structure
104
+
- ONLY escape these patterns when they appear in the actual file content you're searching for or replacing
105
+
- Example: If you're removing merge conflict markers from a file, escape them in the SEARCH content: \\=======
106
+
- Do NOT escape the ======= that separates your SEARCH and REPLACE sections
107
+
102
108
Parameters:
103
109
- path: (required) The path of the file to modify (relative to the current workspace directory ${args.cwd})
104
110
- diff: (required) The search/replace block defining the changes.
@@ -213,37 +219,42 @@ Only use a single line of '=======' between search and replacement content, beca
213
219
`ERROR: Special marker '${found}' found in your diff content at line ${state.line}:\n`+
214
220
"\n"+
215
221
`When removing merge conflict markers like '${found}' from files, you MUST escape them\n`+
216
-
"in your SEARCH section by prepending a backslash (\\) at the beginning of the line:\n"+
222
+
"in your SEARCH section by prepending a backslash (\\) at the beginning of the line.\n"+
223
+
"\n"+
224
+
"IMPORTANT CLARIFICATION:\n"+
225
+
"- ONLY escape these patterns when they appear in the actual file content you're modifying\n"+
226
+
"- The diff structure markers themselves (<<<<<<< SEARCH, =======, >>>>>>> REPLACE) should NEVER be escaped\n"+
217
227
"\n"+
218
228
"CORRECT FORMAT:\n\n"+
219
229
"<<<<<<< SEARCH\n"+
220
230
"content before\n"+
221
-
`\\${found} <-- Note the backslash here in this example\n`+
231
+
`\\${found} <-- Escape ONLY when this is part of the file content\n`+
222
232
"content after\n"+
223
233
"=======\n"+
224
234
"replacement content\n"+
225
235
">>>>>>> REPLACE\n"+
226
236
"\n"+
227
-
"Without escaping, the system confuses your content with diff syntax markers.\n"+
228
-
"You may use multiple diff blocks in a single diff request, but ANY of ONLY the following separators that occur within SEARCH or REPLACE content must be escaped, as follows:\n"+
229
-
`\\${SEARCH}\n`+
230
-
`\\${SEP}\n`+
231
-
`\\${REPLACE}\n`,
237
+
"Without escaping, the system confuses your content with diff syntax markers.",
0 commit comments