Skip to content

enhancement(apply_diff): fuzzy-match success warning, file-changed signal, large-file perf guard (trial agent feedback, epic #1375) #1418

Description

@easonLiangWorldedtech

Observed by the trial agent (epic #1375 trial build, #1413) while running a parallel-writer read-modify-write experiment on apply_diff (two writers on one file + a looping anchored edit).

Working well (no action needed)

  1. The mismatch error payload (Best Match Found + Original Content) gives the agent everything it needs to re-anchor in a single round-trip - no extra read_file required.
  2. The fuzzy threshold correctly failed loud instead of silently mis-hitting (LOOP_70 vs LOOP_72 under a 92% threshold). Default exact (1.0) + diffFuzzyThreshold opt-in + clamp to [0.5, 1.0] is the right shape.
  3. Atomicity held: a two-block diff with one bad block failed as a whole - no partial application.

Suggested follow-ups

  1. Fuzzy success warning. A successful match below 100% similarity is applied silently today. Suggestion: include one line in the success result, e.g. "applied at 94% similarity (anchor line 70 -> actual line 72)", so the model can decide to verify.
  2. Explicit file-changed signal. Today the agent must infer a concurrent writer from the Original Content payload. An explicit mtime/hash-comparison flag in the error (e.g. "file changed since last read: true") lets the agent pick the right retry strategy: "my diff is wrong" vs "file changed externally, re-anchor".
  3. Performance guard for large files. The sliding-window + per-block Levenshtein is O(n*m); on multi-thousand-line files with large search blocks this may be noticeably slow. Suggestion: a window cap, or an exact quick-pass before the fuzzy pass.
  4. Document the all-or-nothing block guarantee in the tool/README copy (it is the right behavior for a "surgical edits" tool).

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions