-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: add re-read after edit experiment for automatic review suggestions #8928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implements issue #8927 - Add option to suggest reviewing changes after file edits. - Added RE_READ_AFTER_EDIT experiment configuration - Updated all file editing tools to suggest review when experiment is enabled - Added UI setting with English translation - Added tests for the new experiment When enabled, the AI will suggest using the read_file tool to review changes after editing files, helping catch errors that might be introduced during editing.
Review CompleteI've reviewed the changes in this PR and found 1 issue that should be addressed: Issues Found
|
| // Count how many files were successfully edited | ||
| const editedFiles = operationResults.filter((op) => op.status === "approved").length | ||
| const reReadSuggestion = | ||
| isReReadAfterEditEnabled && editedFiles > 0 | ||
| ? `\n\n<review_suggestion>${editedFiles === 1 ? "The file has" : `${editedFiles} files have`} been edited. Consider using the read_file tool to review the changes and ensure they are correct and complete.</review_suggestion>` | ||
| : "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The review suggestion count may be inaccurate. When a file is approved but all its diffs fail to apply (successCount === 0 at line 494), the code continues without saving changes (line 514), but the file remains with status "approved". Later at line 688, the code counts all "approved" files for the review suggestion, incorrectly including files that were approved but never actually edited. This could result in suggestions like "2 files have been edited" when only 1 file was successfully modified.
This PR implements #8927 - Add option to suggest reviewing changes after file edits.
Summary
Adds an experimental feature that prompts the AI to review changes after editing files, helping catch errors that might be introduced during editing.
Changes
RE_READ_AFTER_EDITexperiment configuration to types and experiments systemapplyDiffTool.ts- Single file diff applicationsmultiApplyDiffTool.ts- Multi-file diff applicationswriteToFileTool.ts- File writesinsertContentTool.ts- Content insertionsearchAndReplaceTool.ts- Search and replace operationsHow it works
When the experiment is enabled, after any file editing operation, the AI will receive a
<review_suggestion>message suggesting to use theread_filetool to review the changes. The suggestions are contextual (e.g., "The file has been edited" vs "2 files have been edited").Trade-offs
As mentioned in the issue, this feature will:
This is why it's implemented as an opt-in experiment, allowing users to decide based on their needs.
Testing
Closes #8927
Important
Introduces
RE_READ_AFTER_EDITexperiment to suggest reviewing changes after file edits, with updates to tools, configuration, and tests.RE_READ_AFTER_EDITexperiment to suggest reviewing changes after file edits.applyDiffTool.ts,multiApplyDiffTool.ts,writeToFileTool.ts,insertContentTool.ts, andsearchAndReplaceTool.tsto include review suggestions when the experiment is enabled.reReadAfterEdittoexperiment.tsandexperiments.ts.RE_READ_AFTER_EDITinsettings.json.experiments-reReadAfterEdit.spec.tsfor testing the new experiment.experiments.spec.tsandExtensionStateContext.spec.tsxto include the new experiment.This description was created by
for f86af76. You can customize this summary. It will automatically update as commits are pushed.