Cursor rule workflow duplicates full report blocks despite delete-and-regenerate instructions

Hey, thanks for the detailed report. The repro steps and workaround analysis really help.

This is a known class of bugs. With patch style writes, the agent read path can sometimes read content from an open editor buffer in memory TextModel instead of from disk. If the file was deleted but the tab is still open, especially with autosave, the buffer can restore old content, and the patch gets applied on top of it. That’s why you see duplicated blocks. Your Set-Content workaround works because it skips the whole read patch write pipeline and writes directly with truncate semantics.

A very similar thread with the same symptom: Delete & re-creation of file cause duplicated data Delete & re-creation of file cause duplicated data

We’re tracking this on our side, but there’s no exact ETA for a fix yet. For now, your workaround truncate overwrite via Set-Content plus the marker count check is a solid solution for deterministic generation of final artifacts. For rules that write final files, it makes sense to lock in that kind of write contract like you did.