Commit 99ae673
authored
feat: Edit with self correcting patches (#441)
The problem: Line editing is unreliable, full writes work but can have
side effects and devour tokens.
Main challenge is that LLMs suck at counting reliably. This solution
removes the need for counting and builds on the assumption that there is
plenty of patch data an LLM trained on.
But, likely the numbers are still close, which helps us deal with any
ambiguity in the patch. Bonus is that with this we can support multiple
edits in a file with a single LLM call and minimal tokens.
How it works:
* First parse the patch into a loosy format we can work with
* Iterate over the lines in the target file, if there is a match with a
hunk, create a candidate
* If that line matches with the next line for any current candidate,
keep the candidate, otherwise ditch
* Finally, we can recalculate the source and dest lines and ranges, and
re-render the patch.
The algorithm supports ambiguity (multiple hunks matching). Still needs
to be dealt with.
TODO:
- [x] Deal with ambiguity
- [x] More tests for multiple hunks
- [x] Test with diffy if the regenerated patches are correct
- [x] Add it all to the tool
- [x] Run some evals
If the evals pass we'll keep it in. After we run a set of SWE, if we see
no issues, as far as I'm concerned we can make it the default (and write
a cool blog article).
Aside, it should also be possible to Cow/borrow most of the inner values
and have this be near zero copy. The way it will be used however it's no
where near a bottleneck. Cool exercise though.1 parent e70c871 commit 99ae673
File tree
22 files changed
+1132
-42
lines changed- src
- agent
- agents
- tools
- snapshots
- config
- evaluations
- tests
22 files changed
+1132
-42
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| 150 | + | |
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
| |||
376 | 378 | | |
377 | 379 | | |
378 | 380 | | |
379 | | - | |
| 381 | + | |
380 | 382 | | |
381 | 383 | | |
382 | 384 | | |
| |||
386 | 388 | | |
387 | 389 | | |
388 | 390 | | |
389 | | - | |
| 391 | + | |
390 | 392 | | |
391 | 393 | | |
392 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
216 | 223 | | |
217 | 224 | | |
218 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
405 | 409 | | |
406 | 410 | | |
407 | 411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
0 commit comments