fix edit retrigger (#2306)

This commit is contained in:
Leo
2025-06-28 19:02:44 +01:00
committed by GitHub
parent 3518ff7663
commit 601d9ba36d
4 changed files with 142 additions and 9 deletions

View File

@@ -45,6 +45,11 @@ export interface WriteFileToolParams {
* The content to write to the file
*/
content: string;
/**
* Whether the proposed content was modified by the user.
*/
modified_by_user?: boolean;
}
interface GetCorrectedFileContentResult {
@@ -68,7 +73,9 @@ export class WriteFileTool
super(
WriteFileTool.Name,
'WriteFile',
'Writes content to a specified file in the local filesystem.',
`Writes content to a specified file in the local filesystem.
The user has the ability to modify \`content\`. If modified, this will be stated in the response.`,
{
properties: {
file_path: {
@@ -270,9 +277,16 @@ export class WriteFileTool
DEFAULT_DIFF_OPTIONS,
);
const llmSuccessMessage = isNewFile
? `Successfully created and wrote to new file: ${params.file_path}`
: `Successfully overwrote file: ${params.file_path}`;
const llmSuccessMessageParts = [
isNewFile
? `Successfully created and wrote to new file: ${params.file_path}.`
: `Successfully overwrote file: ${params.file_path}.`,
];
if (params.modified_by_user) {
llmSuccessMessageParts.push(
`User modified the \`content\` to be: ${params.content}`,
);
}
const displayResult: FileDiff = { fileDiff, fileName };
@@ -298,7 +312,7 @@ export class WriteFileTool
}
return {
llmContent: llmSuccessMessage,
llmContent: llmSuccessMessageParts.join(' '),
returnDisplay: displayResult,
};
} catch (error) {
@@ -395,6 +409,7 @@ export class WriteFileTool
) => ({
...originalParams,
content: modifiedProposedContent,
modified_by_user: true,
}),
};
}