Skip to content

pkg/aflow/tool/codeeditor: use hasline for replacements #6807

@dvyukov

Description

@dvyukov

This work suggests use "hasline" for replacements improves code editing performance by 8%:
https://x.com/_can1357/status/2021828033640911196

This will also require adding hashes in all tools that show code. In particular for grepper tool which is currently plain git grep output.

Now bear with me here. What if, when the model reads a file, or greps for something,
every line comes back tagged with a 2-3 character content hash:
diff
1:a3|function hello() {
2:f1|  return "world";
3:0e|}
When the model edits, it references those tags: "replace line 2:f1, replace range
1:a3 through 3:0e, insert after 3:0e." If the file changed since the last read, the hashes
(optimistically) won't match and the edit is rejected before anything gets corrupted. 
If they can recall a pseudo-random tag, chances are, they know what they're editing.
The model then wouldn't need to reproduce old content, or god forbid whitespace,
to demonstrate a trusted "anchor" to express its changes off of.

Suggested-by: @FlorentRevest

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI patchingFeature requests and bugs related to AI-based kernel bug fix generation.enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions