All code being randomly deleted in my source files

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

I am constantly getting existing code blocks (like the entire contents) deleted or duplicated.
See example chat below after I restore a source file and try the same prompt.
---->
Good! The file is intact. Let me carefully add the new constants:
Good! Now let me add the P/Invoke declarations. First, let me find the existing SendMessage:
:stop_sign: STOPPING IMMEDIATELY - FILE CORRUPTED
Critical Issue Detected: Shared/NativeMethods.cs has been reduced to 1 line (should be ~676 lines)
My last edit somehow corrupted the file. This is exactly what you warned about.
:wrench: MANUAL ASSISTANCE REQUIRED
Please restore Shared/NativeMethods.cs from:
Git/version control (git checkout Shared/NativeMethods.cs), OR
Undo in your IDE (Ctrl+Z), OR
Tell me to provide the complete file content to recreate it
Once the file is restored, I need you to manually add these lines:


I am going in circles and burning tokens!

Steps to Reproduce

I am just using iterating over my code - it is happening regularly. Manually merging the first few changes seems to allow it push on.

Expected Behavior

Not delete entire source code - at least comment it out so I can get it back quickly - or manually merge.

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.7.54 (user setup)
VSCode Version: 1.99.3
Commit: 5c17eb2968a37f66bc6662f48d6356a100b67be0
Date: 2025-10-21T19:07:38.476Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Windows_NT arm64 10.0.26100

For AI issues: which model did you use?

I think its an editor issue - i am using claude 4.5 sonnet thinking MAX

Additional Information

I am having to repeat the same task over and over which is burning tokens and costing me $ for no result, having to roll back and start again.

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

NEW INFO…
And now I am getting this error
Request ID: 2ba04884-2219-43fa-8e96-797ed96b20bc
{“error”:“ERROR_OPENAI”,“details”:{“title”:“Unable to reach the model provider”,“detail”:“We’re having trouble connecting to the model provider. This might be temporary - please try again in a moment.”,“additionalInfo”:{},“buttons”:,“planChoices”:},“isExpected”:false}
ConnectError: [unavailable] Error
at t7l.$endAiConnectTransportReportError (vscode-file://vscode-app/c:/Users/adam/AppData/Local/Programs/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js:7337:375292)
at TMr._doInvokeHandler (vscode-file://vscode-app/c:/Users/adam/AppData/Local/Programs/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js:489:35946)
at TMr._invokeHandler (vscode-file://vscode-app/c:/Users/adam/AppData/Local/Programs/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js:489:35688)
at TMr._receiveRequest (vscode-file://vscode-app/c:/Users/adam/AppData/Local/Programs/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js:489:34453)
at TMr._receiveOneMessage (vscode-file://vscode-app/c:/Users/adam/AppData/Local/Programs/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js:489:33275)
at cEt.value (vscode-file://vscode-app/c:/Users/adam/AppData/Local/Programs/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js:489:31369)
at _e._deliver (vscode-file://vscode-app/c:/Users/adam/AppData/Local/Programs/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js:49:2962)
at _e.fire (vscode-file://vscode-app/c:/Users/adam/AppData/Local/Programs/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js:49:3283)
at cdt.fire (vscode-file://vscode-app/c:/Users/adam/AppData/Local/Programs/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js:7322:12154)
at MessagePort. (vscode-file://vscode-app/c:/Users/adam/AppData/Local/Programs/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js:9402:18292)

Hey, thanks for the report. Sorry you’re running into this, I can see you’re losing time and tokens.

This appears to be a known issue the team is investigating. A few questions to narrow it down:

  1. Which Cursor feature are you using? Inline chat(Cmd+K), Agent, or Ask mode?
  2. Does it happen when you accept AI edits, or are files corrupted before you review/accept them?
  3. Can you reproduce it with a specific file size or a particular prompt pattern?

Workarounds to try:

  • Use Timeline (File → View Timeline) to quickly restore deleted code instead of git/undo
  • Review AI edits in the diff view before accepting, don’t auto‑accept large changes
  • Break prompts into smaller, incremental changes
  • Temporarily switch to a different model (e.g., GPT‑4o) to see if behavior differs

About the ERROR_OPENAI error: It’s usually temporary, try starting a fresh chat when it appears. If it persists across new chats, restart Cursor.

Let me know your answers and whether the workarounds help.