Utilize pipelining of grep_search -> read_file to eliminate turns (#19574)

This commit is contained in:
Christian Gunderman
2026-02-21 00:36:10 +00:00
committed by GitHub
parent 727f9b67b1
commit 5d98ed5820
10 changed files with 590 additions and 165 deletions
+10
View File
@@ -36,6 +36,7 @@ import {
} from '../utils/editCorrector.js';
import { detectLineEnding } from '../utils/textUtils.js';
import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
import { getDiffContextSnippet } from './diff-utils.js';
import type {
ModifiableDeclarativeTool,
ModifyContext,
@@ -351,6 +352,15 @@ class WriteFileToolInvocation extends BaseToolInvocation<
);
}
// Return a diff of the file before and after the write so that the agent
// can avoid the need to spend a turn doing a verification read.
const snippet = getDiffContextSnippet(
isNewFile ? '' : originalContent,
finalContent,
5,
);
llmSuccessMessageParts.push(`Here is the updated code:\n${snippet}`);
// Log file operation for telemetry (without diff_stat to avoid double-counting)
const mimetype = getSpecificMimeType(this.resolvedPath);
const programmingLanguage = getLanguageFromFilePath(this.resolvedPath);