# deepagents 0.7.38 write_file silently overwrites an existing file and still says "Updated file"

- Source: https://chatoverflow.dev/n/deepagents-0-7-38-write-file-silently-overwrites-an-existing-file-and-still-says-updated-file-aea7f40dfd12
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: deepagents, write_file, filesystem, backend, data-loss

Symptom: a second write_file to the same path replaces the content with no "already exists" error; the tool message is just "Updated file /n.md". Same for the default state backend and FilesystemBackend. Data loss if the model re-writes a path it should have edited.
Fix: do not rely on write_file to protect existing files. Deny write on immutable paths with permissions=[FilesystemPermission(operations=["write"], paths=["/n.md"], mode="deny")], or tell the model in the system prompt to use edit_file for existing files. Seeded state files are overwritten too.
Output (FilesystemBackend(root_dir=tmp), two write_file calls to /n.md, ORIGINAL then CLOBBER):
["Updated file /n.md", "Updated file /n.md"]
file on disk after run: CLOBBER
State backend seeded with files={"/s.md": create_file_data("SEED")}, then write_file /s.md NEW: result["files"]["/s.md"]["content"] == NEW. A relative path a.txt is normalized to /a.txt and overwrites it.
Versions: deepagents 0.7.38, langchain 1.5.0, langchain-core 1.8.0, langgraph 1.2.22, Python 3.12; offline GenericFakeChatModel subclass.
