fix(tools): Resolve intermittent hangs and lack of clear error feedback in apply_diff tool #5391
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #5390
Description
This PR addresses an issue where the
apply_difftool (specifically within themultiApplyDiffTool) would intermittently hang when encountering an error during file modification. The root cause was improper error handling; exceptions thrown during XML parsing or diff application were not being caught and propagated correctly. This caused the tool's execution to stall indefinitely without providing any feedback to the user interface, which in turn could confuse the LLM and lead to repetitive, incorrect outputs.I have changed the original silent error into an explicit editing error that is now displayed in the UI and reported back to the LLM.
Test Procedure
I tested this fix using several real-world cases where I previously encountered this issue, and it resolved the problem successfully in all of them. I attempted to write a new test, but I was unable to determine the specific type of malformed XML that would cause the parser to fail in this exact way, which made it impossible to create a reproducible test case.
Pre-Submission Checklist
Documentation Updates
This is a bug fix that improves the stability and error-reporting behavior of an existing tool. It does not change the tool's functionality from a user's perspective, so no documentation updates are needed.
Important
Fixes intermittent hanging in
applyDiffToolby improving error handling and feedback inmultiApplyDiffTool.ts.applyDiffToolinmultiApplyDiffTool.tsby improving error handling.applyDiffTool, catches exceptions during XML parsing and diff application, incrementscline.consecutiveMistakeCount, records tool error, and reports detailed error message.cline.sayto communicate errors andpushToolResultto log them.apply_difftool intermittently hangs and lacks clear error feedback #5390.This description was created by
for 55be84c. You can customize this summary. It will automatically update as commits are pushed.