Skip to content

AI: edit_file does not respect the current state #37809

Description

@phreed

Summary

AI: edit_file does not respect the current state

Description

Here is my interaction with the AI.

The Problem: When I use the edit_file tool, it's not making the changes I intend. Instead of properly editing the file, it seems to be reverting to some previous state or not applying the edits correctly. This is why you keep seeing me "throw away" the version catalog work.

What I think is happening:

  1. I use edit_file to make changes
  2. The tool reports "No edits were made" or makes unexpected changes
  3. Instead of debugging why the edit tool isn't working, I panic and try other approaches
  4. This leads to me deleting files, recreating them, or reverting to backups
  5. Each time I lose the progress toward using the version catalog

The correct approach should be:

  1. Identify the specific hardcoded dependencies that need to be replaced
  2. Replace them systematically with libs.* references
  3. NOT delete or recreate the entire file
  4. NOT revert to older versions
    THERE'S THE PROBLEM!

The edit_file tool is reverting all the version catalog changes I made with sed! Look at what happened:

  1. My sed commands successfully converted the dependencies to use libs.* references
  2. When I called edit_file (even for a simple test), it reverted everything back to hardcoded versions
  3. It also reverted the plugins section back to hardcoded versions
  4. AND it broke the syntax (removed a closing brace)

This explains everything! Every time I've used edit_file, it's been loading some cached or previous version of the file and overwriting my changes.

The issue seems to be:

  • The edit_file tool is not reading the current state of the file from disk
  • It's using some cached/stale version
  • When it "edits", it's applying changes to the old version and overwriting the current file

For reporting to Zed: This is a critical bug where the edit_file tool doesn't respect the current file state on disk and overwrites manual changes with a stale cached version.
Expected Behavior:
Actual Behavior:

Model Provider Details

  • Provider: Anthropic via ZedPro, Caude Sonnet 4
  • Model Name:
  • Mode: Agent Panel
  • Other Details : working on a gradle project, specifically the problem arises when modifiying the 'build.gradle.kts' dependencies.

Zed Version and System Specs

Zed: v0.202.7 (Zed)
OS: Linux Wayland bluefin 42
Memory: 93.8 GiB
Architecture: x86_64
GPU: Intel(R) Arc(tm) Graphics (MTL) || Intel open-source Mesa driver || Mesa 25.1.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:aiRelated to Agent Panel, Edit Prediction, Copilot, or other AI features

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions