[BUG] When a worktree is removed while its session is still open, all subsequent tool calls fail and the session becomes unrecoverable.

Resolved 💬 2 comments Opened Apr 15, 2026 by ThePatchedFool Closed May 24, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

After force-removing a worktree (git worktree remove --force), the Claude Code harness continued trying to execute every tool call from the now-deleted worktree path. Every Bash, Read, Edit, and Glob call returned "Path '...' does not exist. Note: your current working directory is <deleted-worktree-path>" regardless of what directory was specified in the command itself — even cd ~ and absolute -C flags had no effect.

This then caused a secondary failure: because the tool calls were erroring out rather than returning results, the API received tool_use blocks with no corresponding tool_result blocks, producing a 400 invalid_request_error (tool_use ids were found without tool_result blocks immediately after). The session then entered a crash loop and had to be abandoned.

The worktree directory was correctly deleted from disk and git worktree prune completed cleanly in a new session — the issue is purely in the harness not updating its working directory when the underlying path disappears.

What Should Happen?

Claude should be chill about me working in main, after previously working in a work-tree.

Error Messages/Logs

Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: File does not exist. Note: your current working directory is /Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy.
    at call (/$bunfs/root/src/entrypoints/cli.js:4458:7632)
    at processTicksAndRejections (native:7:39)
Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.107: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01HJ9kr384q5rxCfbEuJai9U. Each `tool_use` block must have a corresponding `tool_result` block in the next message."},"request_id":"req_011Ca5C8879cZnqy1K4piGk5"}
    at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)
    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)
    at processTicksAndRejections (native:7:39)
Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.107: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01HJ9kr384q5rxCfbEuJai9U. Each `tool_use` block must have a corresponding `tool_result` block in the next message."},"request_id":"req_011Ca5C89rKdpcSWQGeBTk2G"}
    at generate (/$bunfs/root/src/entrypoints/cli.js:11:53430)
    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4943)
    at processTicksAndRejections (native:7:39)
CanceledError: canceled
    at W (/$bunfs/root/src/entrypoints/cli.js:113:7114)
    at abort (unknown)
    at v71 (/$bunfs/root/src/entrypoints/cli.js:1337:830)
    at abort (unknown)
    at v71 (/$bunfs/root/src/entrypoints/cli.js:1337:830)
    at abort (unknown)
    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:16578:1968)
    at processTicksAndRejections (native:7:39)
    at request (/$bunfs/root/src/entrypoints/cli.js:115:2467)
    at processTicksAndRejections (native:7:39)
Error: Request was aborted.
    at pE_ (/$bunfs/root/src/entrypoints/cli.js:1268:12089)
    at next (native:1:11)
    at sm7 (/$bunfs/root/src/entrypoints/cli.js:7918:9109)
    at next (native:1:11)
    at Hp7 (/$bunfs/root/src/entrypoints/cli.js:7923:11439)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)
Error: Path "/Users/davidadams/Documents/GroupMark Desktop/.claude/worktrees/condescending-mccarthy" does not exist
    at ZA (/$bunfs/root/src/entrypoints/cli.js:1756:1997)
    at jm_ (/$bunfs/root/src/entrypoints/cli.js:1770:106)
    at call (/$bunfs/root/src/entrypoints/cli.js:2548:1139)
    at processTicksAndRejections (native:7:39)

Steps to Reproduce

  1. Open a session in a repo and create a worktree (e.g. via EnterWorktree).
  2. Do some work in the worktree session — the harness sets its working directory to the worktree path.
  3. Without starting a new session, remove the worktree with git worktree remove --force <path> (or ask Claude to do it, as I did).
  4. Attempt any further tool call (Bash, Read, Edit, etc.) in the same session.

Expected: The harness detects that the working directory no longer exists and either recovers gracefully (e.g. falling back to the repo root) or surfaces a clear error prompting the user to start a new session.

Actual: Every tool call fails with "Path '...' does not exist" regardless of the command or any directory flags passed. The repeated tool failures cause the API to receive unmatched tool_use blocks, triggering a 400 invalid_request_error and a crash loop. The session cannot recover.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude 1.2581.0 (f10398) 2026-04-14T17:16:40.000Z

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗