Agent stops execution after git checkout failure in worktree scenario

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When the agent attempts to check out a branch and Git returns an error (for example, when the branch is already checked out in another worktree), the agent aborts all remaining work. After the failure, the UI resets back to the initial prompt state instead of preserving the current session context or surfacing a recoverable error state.

Steps to Reproduce

  • Check a branch in a separate worktree
  • Start an agent in the default worktree
  • Ask the agent to checkout the branch

Expected Behavior

The agent should report the failure and provide options to the user what to do next.

Operating System

MacOS

Version Information

Version: 3.3.30 (Universal)
VSCode Version: 1.105.1
Commit: 3dc559280adc5f931ade8e25c7b85393842acf30
Date: 2026-05-09T18:28:42.332Z
Layout: glass
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Darwin arm64 25.4.0

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hi Ilan!
This looks like bug in the worktree checkout flow. When the target branch is already checked out in another worktree, Cursor should preserve the agent state and offer a recovery path instead of dropping you back to the initial prompt.

The safest workaround for now is to switch or close the other worktree that already owns the branch, then retry the agent action. You can also use git worktree list in your repo to find which path has the branch checked out.

Our team is tracking this class of worktree checkout failures.