edit_file: Add diff-fenced output format (#32737)

This format is enabled for Google models as they seem to prefer it.
A relevant unit eval's pass rate has increased from 0.77 to 0.98.

Diff-fenced format looks like this (markdown fences and a line hint are
optional):

```diff
<<<<<<< SEARCH line=42
...
=======
...
>>>>>>> REPLACE
```

Release Notes:

- Agent: Gemini models now use the diff-fenced format when making edits
This commit is contained in:
Oleksiy Syvokon 2025-06-16 17:28:18 +03:00 committed by GitHub
parent 8df6ce2aac
commit fceba6c795
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 667 additions and 79 deletions

View file

@ -44,6 +44,10 @@ impl StreamingFuzzyMatcher {
/// Returns `Some(range)` if a match has been found with the accumulated
/// query so far, or `None` if no suitable match exists yet.
pub fn push(&mut self, chunk: &str, line_hint: Option<u32>) -> Option<Range<usize>> {
if line_hint.is_some() {
self.line_hint = line_hint;
}
// Add the chunk to our incomplete line buffer
self.incomplete_line.push_str(chunk);
self.line_hint = line_hint;