-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: prevent dump of an entire file into the context on user edit #3654
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
base: main
Are you sure you want to change the base?
Conversation
Previously, each tool file contained duplicate code for formatting file write responses and conditionally sending user_feedback_diff messages. This led to inconsistent implementations and made changes difficult to maintain. This refactoring centralizes the response formatting and messaging logic in the DiffViewProvider class, which now: - Stores results from saveChanges() in class properties - Only sends user_feedback_diff when user edits exist - Configures XMLBuilder with no indentation for cleaner output Tool files now make a single method call instead of duplicating logic. Fixes: cline#3647 Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
|
Make the 'If the user's edits have addressed part of the task...' message conditional based on whether there are actual user edits. This prevents showing irrelevant guidance when no user edits were made to the file. Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
given https://www.reddit.com/r/RooCode/comments/1kn6xwj/pruning_ai_turn_from_context/ : I think this should be manually tested for regression and then merged quickly. This is intended to be a simple refactor that centralizes file modification responses to the model and removes I have had the model test each tool and various scenarios along with testing user modifications and I have not found any issues with it. |
@samhvw8 can you set your multi-file PR to "draft" until this lands? |
@KJ7LNW i will put multi-write pr into draft mode, i think multi-read not related to this |
true |
This PR should merge as preparatory standardization for #3342, #3055, #1899, #2955 and it fixes #3647:
Thus, If we can push this out soon, then it will simplify development on other fronts. As you can see it substantially reduces the footprint of each tool that modifies files by replacing common call paths with a single function call: ]$ git diff origin/main... --stat
src/core/tools/applyDiffTool.ts | 36 ++++------------
src/core/tools/insertContentTool.ts | 35 ++++------------
src/core/tools/searchAndReplaceTool.ts | 35 ++++------------
src/core/tools/writeToFileTool.ts | 32 +++------------
src/integrations/editor/DiffViewProvider.ts | 86 ++++++++++++++++++++++++++++++++++++++-
5 files changed, 115 insertions(+), 109 deletions(-) |
Problem fixed by this PR
This pull request fixes the problem of dumping an entire file into the context under the following condition:
After the user clicks save,
<final_file_content>[entire file]</final_file_content>
is dumped into the conversation even for a one-line change, which is a severe problem because it:Fixes: #3647
The fix
The change by the user shown in Step-3, above, is provided to the model in the existing implementation using the standard
diff
format, so it understands the change that was made. All we are doing here is omitting<final_file_content>[entire file]</final_file_content>
to prevent context bloat and maintain model focus.Because this issue exists in all tools that modify files, this pull request is also a refactor to standardize the tool response for file modifications across
write_to_file
,apply_diff
,search_and_replace
, andinsert_content
:History
The
final_file_content
feature was introduced by Saoud Rizwan and copy-pasted across all file modification tools as new tools were added.Important
Refactored to centralize response formatting and messaging in
DiffViewProvider
, addingpushToolWriteResult
for XML response and user feedback, affecting multiple tool files.DiffViewProvider
.pushToolWriteResult
method toDiffViewProvider
for XML response formatting and user feedback messaging.saveChanges
in class properties.applyDiffTool.ts
,insertContentTool.ts
,searchAndReplaceTool.ts
,writeToFileTool.ts
) now callpushToolWriteResult
instead of duplicating logic.user_feedback_diff
only when user edits exist.XMLBuilder
with no indentation for cleaner output.addLineNumbers
import fromapplyDiffTool.ts
andwriteToFileTool.ts
.This description was created by
for a119ca4. You can customize this summary. It will automatically update as commits are pushed.