[Bug]: apply_patch Fails on Minor File Content Drift, Causing Retry-Until-Timeout

Author: cangcang9Created Jul 30, 2026Updated Sep 17, 2026
Labelsbughas-linked-pr

OpenSquilla version or commit

0.5.1

Area

Desktop app

Reproduction steps

Start a code-task that involves editing an existing file. Let the agent generate a diff via apply_patch. Ensure the target file on disk has minor drift compared to what the agent expects (e.g., an extra blank line, different line endings, or indentation variance). Observe the agent attempting apply_patch, failing with context mismatch, and retrying in a loop. The step eventually times out without the file being modified.

Expected behavior

apply_patch should tolerate minor whitespace/line-ending drift, or The tool chain should gracefully fall back to a direct file write when patch context mismatches persist.

Actual behavior

apply_patch fails on context mismatch. Agent retries indefinitely instead of falling back. Step times out; file remains unmodified.

Environment

win11

Diagnostic bundle and error reference

The apply_patch tool is unreliable when modifying existing files. Even when the agent produces a correct diff, applying it fails due to minor content driftbetween the diff and the current file on disk — such as: • Extra or missing blank lines • Encoding differences • Indentation whitespace changes When this context mismatch occurs, the agent does not fall back to writing the file directly. Instead, it repeatedly retries apply_patch until the step times out. This is not a model capability issue. deepseek-v4-pro can think correctly, write valid code, and run tests. The problem is that apply_patch itself lacks sufficient fault tolerance for real-world file states.