Agent edit tool fails with "Invalid arguments" on Windows when editing open files in the editor

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Actual behavior: Two errors appear:

“Edit attempted — Invalid arguments” popup when the agent’s edit tool tries to apply the change through the editor’s document model. The edit does not appear in the editor buffer. The agent falls back to writing via shell commands, which succeeds on disk but leaves the editor buffer stale.

“Received change text document command for closed file file:///c%3A/oooo/oooot/control.py” — appears intermittently alongside or instead of the first error, suggesting the editor’s internal document handle was recycled/closed before the edit command arrived.

After either error, the file on disk is correct (the fallback write works), but the editor tab shows stale content until manually reverted (Ctrl+Shift+P > Revert File).

Additional context:

The workspace uses Ruff with native server (“ruff.nativeServer”: “on”) and “files.autoSave”: “afterDelay”. Disabling the Ruff native server does not fix the “Invalid arguments” error — only suppresses the “closed file” popup while introducing a deprecation warning (legacy ruff-lsp is deprecated).
The file path on disk is a normal file — no symlinks, junctions, subst drives, or mapped drives. Path casing is consistent (C:\ooooo).
The error appears to be in the editor’s URI resolution layer when mapping the tool’s file path to the internal file:/// URI for the open document buffer on Windows.

Steps to Reproduce

Steps to reproduce:
Open a workspace on Windows (local, not remote) — e.g. C:\oooo
Open a Python file in the editor
Start an Agent session and ask it to edit the open file
The agent uses the StrReplace / edit tool targeting the file

Expected Behavior

Expected behavior: The edit is applied cleanly in the editor buffer. No error popups.

Operating System

MacOS

Version Information

Version: 2.6.19 (Universal)
VSCode Version: 1.105.1
Commit: 224838f96445be37e3db643a163a817c15b36060
Date: 2026-03-12T04:07:27.435Z (3 days ago)
Build Type: Stable
Release Track: Default
Electron: 39.4.0
Chromium: 142.0.7444.265
Node.js: 22.22.0
V8: 14.2.231.22-electron.0
OS: Darwin arm64 25.2.0

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report.

There’s an important mismatch. Your version info shows OS: Darwin arm64 25.2.0, which is macOS, but the bug description and file paths like C:\opti and file:///c%3A/ point to Windows. Are you connecting to a Windows machine via Remote-SSH from your Mac?

If yes, this is a known issue with how the agent resolves file URIs over Remote-SSH to Windows hosts. Several users have reported the same Invalid arguments error in this setup. Write and StrReplace tools return "Invalid arguments" when workspace is opened via Remote-SSH (Mac → Windows)

One workaround some users found helpful is adding a Cursor rule that tells the agent to fall back to PowerShell commands like Set-Content and Get-Content -replace when StrReplace or Write fails. There’s a detailed rule example in the thread above in post #5.

If this is actually a local Windows machine, can you share the version info from that machine? You can find it in Help > About in Cursor on the Windows box. That would help narrow this down.

Let me know which case applies.

Thanks, man! Good catch - I am connecting to windows machine via Remote-SSH from my Mac. I’ll give the workaround a shot. Hope they patch this, though.

Cheers!

1 Like