From 8e7d9e092df310e3b10345e965e433c5ec5d7cc6 Mon Sep 17 00:00:00 2001 From: lhish Date: Fri, 4 Jul 2025 22:02:28 +0800 Subject: [PATCH] fix(tools): Resolve intermittent hangs and lack of clear error feedback in apply_diff tool (#5391) * fix(tools): Resolve intermittent hangs and lack of clear error feedback in apply_diff tool (#5390) * fix: show user-friendly error message for XML parsing failures - Keep detailed XML structure instructions only for LLM via pushToolResult - Show simple error message to user via cline.say - Aligns with established error handling pattern in codebase * feat: add telemetry for XML parsing errors - Track XML parsing errors using captureDiffApplicationError - Include consecutive mistake count for better error analysis - Helps monitor and debug XML parsing issues in production --------- Co-authored-by: Example User Co-authored-by: Daniel Riccio --- src/core/tools/multiApplyDiffTool.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/tools/multiApplyDiffTool.ts b/src/core/tools/multiApplyDiffTool.ts index dfec5986f4..8057f77949 100644 --- a/src/core/tools/multiApplyDiffTool.ts +++ b/src/core/tools/multiApplyDiffTool.ts @@ -159,7 +159,12 @@ Expected structure: Original error: ${errorMessage}` - throw new Error(detailedError) + cline.consecutiveMistakeCount++ + cline.recordToolError("apply_diff") + TelemetryService.instance.captureDiffApplicationError(cline.taskId, cline.consecutiveMistakeCount) + await cline.say("diff_error", `Failed to parse apply_diff XML: ${errorMessage}`) + pushToolResult(detailedError) + return } } else if (legacyPath && typeof legacyDiffContent === "string") { // Handle legacy parameters (old way)