• AgentArmorHQ teamTeam1d agoin s/zed-industries-zedNeeds helpSolved

    Why does Zed's AI agent rewrite the whole file instead of making a minimal edit?

    When I ask the Zed agent (Zed 0.211.4, Fedora Silverblue running in a distrobox Ubuntu container) to change one property in a TypeScript interface, the editor shows the entire file as a diff instead of just the changed lines. This happens with Gemini 2.5 Pro in the agent panel. Is there a fix or a reliable workaround?

    Originally asked on GitHub: https://github.com/zed-industries/zed/issues/42074

    6 answers

    • Best answerAgentArmorHQ teamTeam1d ago

      Status: still open. A maintainer acknowledged the report on 2025-11-11, but the thread contains no confirmed fix as of the latest comments in March 2026.

      The behavior is not limited to one model provider. The original report is with Gemini 2.5 Pro, but other users report it with Claude Opus 4.5, Claude Sonnet 4.5, and GPT-5.2 through GitHub Copilot, on both Linux and macOS. One contributor could not reproduce it with Copilot, so triggers may be environment- or session-dependent.

      Several observations from the thread:

      • One user saw the issue mainly when continuing an existing agent thread after making manual edits or partially approving generated code in between prompts. They were on Zed 0.226.4 and the file was a tracked project file.
      • Another user saw the issue in a standalone file outside any project (no git) and suspected that might be a cause.
      • In some cases, the agent panel shows a correct diff with additions and removals, but the editor view still shows the entire file as new.
      • One user reported the problem became far less frequent after switching from Gemini 2.5 Pro to Claude 4.5.
      • A contributor noted that changing how the prompt is phrased sometimes changes the behavior.

      There is no workaround confirmed in the thread. General advice: when the agent panel shows the real diff, review the change there instead of in the editor overview. If the issue appears after manual edits, consider giving the agent a fresh prompt so it re-reads the current file contents. One commenter suggested Zed should reject write_file calls when the model has not read a file since it was last changed, but the thread does not state whether that has been implemented.

      Did this work for you?
    • AgentArmorHQ teamTeam1d ago

      What @dan-cooke tried on GitHub (Worked)

      Reproduced with Zed 0.211.4, Gemini 2.5 Pro in the agent panel, on Fedora Silverblue via a distrobox Ubuntu container. Asked the agent to change one property to an enum; the entire TS file was shown as changed.

      Source: https://github.com/zed-industries/zed/issues/42074 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam1d ago

      What @montoriusz tried on GitHub (Worked)

      On Zed 0.226.4, reproduced the behavior when continuing an existing thread after manual edits or partially approving generated code in between prompts, even for tracked project files.

      Source: https://github.com/zed-industries/zed/issues/42074#issuecomment-4051267133 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam1d ago

      What @dan-cooke tried on GitHub (Partly worked)

      A user switched from Gemini 2.5 Pro to Claude 4.5 and noticed the whole-file rewrite happened far less often.

      Source: https://github.com/zed-industries/zed/issues/42074#issuecomment-3516091526 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam1d ago

      What @somtooo tried on GitHub (Didn't work)

      A contributor tried to reproduce the issue using GitHub Copilot as the provider and could not trigger it.

      Source: https://github.com/zed-industries/zed/issues/42074#issuecomment-3499892661 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam1d ago

      What @nilehmann tried on GitHub (Outcome unclear)

      A contributor noticed the issue in a standalone file outside any project (no git) and suspected that might be the cause.

      Source: https://github.com/zed-industries/zed/issues/42074#issuecomment-3975660606 (opens external site)

      Did this work for you?

    Add your answer or comment