Commit 3afa79b
committed
fix: Improve error message when apply_diff structure is invalid
Currently all errors in apply_diff diff structure are assumed to be
related to merge conflicts. This is unfortunate because it is way more
likely that LLM simply made an error structuring the diff. The LLM is
then directed to fix escaping in the diff from which it doesn't recover.
It is safe to assume that missing or extra "<<<<<<< SEARCH" or ">>>>>>>
REPLACE" strings are likely bad diff structure, because while "<<<<<<<"
and ">>>>>>>" are common merge conflict markers, no tools add "SEARCH"
and "REPLACE" strings after them. This is likely output of the LLM
itself.
LLM not recovering has been observed in Claude 3.5 Sonnet and Claude 3.7
Sonnet models.
To address the issue, error message now mentions merge conflict markers
and their escaping only if it's clear that errors may come from this
source. In the rest of cases the error message repeats the expected diff
structure back to the LLM.1 parent a3e6c91 commit 3afa79b
File tree
2 files changed
+84
-8
lines changed- src/core/diff/strategies
- __tests__
2 files changed
+84
-8
lines changedLines changed: 40 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
31 | 52 | | |
32 | 53 | | |
33 | 54 | | |
34 | 55 | | |
35 | 56 | | |
| 57 | + | |
36 | 58 | | |
37 | 59 | | |
38 | | - | |
| 60 | + | |
39 | 61 | | |
40 | 62 | | |
41 | 63 | | |
42 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
43 | 82 | | |
44 | 83 | | |
45 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
165 | 167 | | |
166 | | - | |
| 168 | + | |
167 | 169 | | |
168 | 170 | | |
169 | 171 | | |
| |||
187 | 189 | | |
188 | 190 | | |
189 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
190 | 215 | | |
191 | 216 | | |
192 | 217 | | |
193 | 218 | | |
194 | 219 | | |
195 | 220 | | |
196 | | - | |
197 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
198 | 227 | | |
| 228 | + | |
199 | 229 | | |
200 | 230 | | |
201 | 231 | | |
202 | | - | |
203 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
204 | 236 | | |
205 | 237 | | |
206 | 238 | | |
207 | 239 | | |
208 | | - | |
209 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
210 | 246 | | |
| 247 | + | |
211 | 248 | | |
212 | 249 | | |
213 | 250 | | |
| |||
0 commit comments