You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
packages/core/src/tool/write.ts uses writeTextPreservingBom() which has NO stale-content check. edit uses writeIfUnchanged() (compares bytes before writing, file-mutation.ts:158-167), but write silently overwrites existing files with zero protection.
Chain from #30376 — at least edit checks content hasn't changed. write doesn't.
Also edit.ts:127-131 error says "oldString must not be empty. Use write to create or overwrite a file." — instructs AI to use the unsafe tool.
Also file-mutation.ts:137-138: writeTextPreservingBom reads the entire existing file just to check first 3 bytes for UTF-8 BOM (hasUtf8Bom), then immediately overwrites it. Wasteful on large files.
Consolidated findings (merged from closed issues):
Activity
github-actions commentedon Jun 4, 2026
This issue might be a duplicate of existing issues. Please check:
write.tsclaims it will fail if not read first but never performs the check. That issue also covers the broader context of read-before-edit enforcement acrossedit,write, andapply_patch.edittool error message that directs AI to usewrite(the unsafe tool).