`move_agent_to_root` fails with opaque git error when a workspace root has no origin remote

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Failed to move agent root: Failed to checkout migrated branch 'master'
Command failed: git fetch origin +refs/heads/master:refs/remotes/origin/master ...
fatal: 'origin' does not appear to be a git repository

Steps to Reproduce

  1. Open a local agent chat in a folder that is a git repo without any remote (e.g. git init, commits on master, no origin).

  2. Have a second folder to add (git or non-git).

  3. Agent calls move_agent_to_root with:

    { "rootPaths": ["C:\\work\\Projects\\folder1", "C:\\work\\Projects\\folder2"] }
    
  4. Approve the tool if Smart Mode asks.

Expected Behavior

Multi-root workspace opens with both folders; chat continues

Operating System

Windows 10/11

Version Information

Version: 3.21.16 (user setup)
VS Code Extension API: 1.128.0
Commit: 8ae78e8eee1e63479c7e0504b664bc0a80c68000
Date: 2026-09-19T06:43:22.276Z
Layout: Agent Window
Build Type: Stable
Release Track: Default
Electron: 42.10.0
Chromium: 148.0.7778.280
Node.js: 24.18.1
V8: 14.8.178.38-electron.0
xterm.js: 6.1.0-beta.291
OS: Windows_NT x64 10.0.26200

Additional Information

The failure was on the primary repo (folder1), which had commits on master but no origin remote at all. The error does not say which repo/path failed.

After adding a local bare origin and pushing master, the same call succeeded:

Moved agent root to ...\glassMultiRootWorkspaces\folder1-2.code-workspace

Also:

  • move_agent_to_cloned_root failed with the same error in this setup; the “skips git fetch” behavior did not help.
  • This is agent migration (beginMigration + branch checkout), not the same as File → Add Folder to Workspace (IDE-only).

Suggested fixes

  1. Error message should include repo path that failed fetch/checkout.
  2. Document that every rootPaths entry needs a git repo with origin and branch master (or whatever the agent tracks).
  3. Optionally: skip git checkout for non-git folders; or a flag to add folders without full migration.

Workaround

Add a local bare remote and push master on each root before calling the tool.

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Also, AI agents think that IDE workspace and Agent root is same and recommends wrong instructions…

Hey @psydvl, thanks for the report, and for the clear repro.

You’ve read it right. When the agent switches workspace root, Cursor first tries to sync the chat’s branch from a remote called origin in the first folder of the new workspace. If that folder has no origin remote (or isn’t a git repo), the switch fails with the error you saw. This is a known issue we’re already tracking, and I’ve added your report to it.

A few ways around it for now:

  1. If folder1 does have a remote under a different name, git remote rename <name> origin in folder1 lets the switch go through.
  2. If it has no remote at all, add a user rule (Cursor Settings → Rules) such as “Do not call move_agent_to_root or move_agent_to_cloned_root. Use working_directory or absolute paths when you need to work in another folder.” The agent can then work across both folders without re-rooting.
  3. Or open the multi-root workspace yourself first (File → Add Folder to Workspace, save the .code-workspace) and start the chat from there, so no root switch is needed mid-conversation.