Skip to content

fix: reduce redundant context in apply_diff error messages #5797

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

roomote[bot]
Copy link

@roomote roomote bot commented Jul 16, 2025

This PR addresses issue #5795 by reducing redundant and verbose context in apply_diff error messages.

Changes Made

  • Removed redundant "Search Content" section that repeats what the model just sent
  • Removed verbose "Original Content" section that consumes valuable context window space
  • Kept essential "Best Match Found" section for effective debugging
  • Preserved similarity score, threshold, and helpful tip to use read_file

Problem Solved

When apply_diff fails to find a match, it previously returned an excessively verbose error message that included:

  1. The search content that was just sent by the model (redundant)
  2. A large snippet of the original file content (noisy and context-consuming)
  3. The "Best Match Found" section (the key debugging information)

This created unnecessary noise in conversation history and wasted valuable context window space.

Solution

The error message now only includes the most relevant information for debugging:

  • The similarity score and threshold
  • The "Best Match Found" section showing what was actually found in the file
  • A tip to use read_file if needed

Testing

  • ✅ All existing tests pass
  • ✅ Linting passes
  • ✅ Type checking passes
  • ✅ No breaking changes to existing functionality

The model already has the search content it just sent, so repeating it provides no value. The large original content section forced the model to re-process irrelevant code. The "Best Match" section is the key piece of information that helps the model understand exactly what diverged and correct its next attempt.

Fixes #5795


Important

Reduces verbosity in apply_diff error messages by removing redundant sections and retaining essential debugging information in multi-file-search-replace.ts and multi-search-replace.ts.

  • Error Message Changes:
    • Removed redundant "Search Content" and "Original Content" sections in multi-file-search-replace.ts and multi-search-replace.ts.
    • Retained "Best Match Found" section for debugging purposes.
    • Preserved similarity score, threshold, and a tip to use read_file.
  • Files Affected:
    • multi-file-search-replace.ts: Adjusted error message construction in applyDiff().
    • multi-search-replace.ts: Adjusted error message construction in applyDiff().
  • Testing:
    • All existing tests pass.
    • Linting and type checking pass.
    • No breaking changes introduced.

This description was created by Ellipsis for f3d0f4e. You can customize this summary. It will automatically update as commits are pushed.

- Remove redundant "Search Content" section that repeats what the model just sent
- Remove verbose "Original Content" section that consumes context window space
- Keep only the essential "Best Match Found" section for debugging
- Maintains similarity score, threshold, and helpful tip to use read_file

Fixes #5795
@roomote roomote bot requested review from mrubens, cte and jr as code owners July 16, 2025 21:35
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jul 16, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 16, 2025
@daniel-lxs daniel-lxs moved this from Triage to Roomote/renovate BOT in Roo Code Roadmap Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Roomote/renovate BOT
Development

Successfully merging this pull request may close these issues.

fix: reduce redundant context in apply_diff error messages
2 participants