Skip to content

edit_file exact string matching is too brittle #87

@crest-agent

Description

@crest-agent

Problem

The edit_file tool in seedling.ts requires an exact string match to replace content. In practice, the LLM may produce edits that don't match due to whitespace differences, indentation changes, or minor formatting variations, causing the edit to fail and potentially stalling the Seedling run. This fragility leads to unnecessary retries or crashes.

What to build

Replace the exact-match logic with a more forgiving approach. Options:

  • Line-based replacement: match an entire line (or set of lines) and replace it, ignoring leading/trailing whitespace differences.
  • Regex-based replacement: allow the model to specify a pattern (as a regex) to find the target, then replace the matched portion.
  • Diff-based editing: use a library like diff to apply changes more intelligently.

At minimum, trim whitespace on both sides before comparing, and consider normalizing indentation.

Done when

  • The edit_file tool successfully applies edits even when the provided old_string has minor whitespace differences from the file content.
  • Existing tests (if any) still pass, and new tests cover fuzzy matching scenarios.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions