VS Code extension: Read/Write/Edit fail with "The user doesn't want to take this action right now" after the extension's control stream closes (no user action)
Version: Claude Code VS Code extension 2.1.281 (bundled CLI), Linux (code-server).
What happens
The extension registers SDK PreToolUse hooks for Edit|Write|Read. When its control stream closes (chat panel or session closed while a background agent keeps running in the CLI process), every later Read/Write/Edit fails immediately (under 1 s) with:
The user doesn't want to take this action right now. STOP what you are doing and wait for the user to tell you how to proceed.
The tool result carries toolDenialKind: "cancelled". Internally the hook callback throws "Stream closed", the hook run reports "PreToolUse hook cancelled (control stream closed)", and that is mapped to the generic user-rejection text. The user did nothing. Bash, Grep and Glob are unaffected (no hook). The tool call is lost, and the model is falsely told that the user declined. In our logs the model usually continued in the same turn (83 of 83 cases on one workspace), but without the file content and with a wrong statement about the user in the transcript.
Observed: 86 cases in 14 days across 3 workspaces, 85 of them Read/Write/Edit, 72 inside background agents (sidechains), 58 under 1 s.
Reproduction
- Run
claude -p --input-format stream-json --output-format stream-jsonand register an SDK PreToolUse hook with matcherEdit|Write|Readover the control protocol, the same way the extension does. - Ask the model to run one Bash command and then read a file.
- Close the input/control stream after the Bash call.
- The Read fails after about 0 ms with the text above and
toolDenialKind: "cancelled". With the stream open, the same Read succeeds.
A real user interrupt looks different: it ends the turn and returns "doesn't want to proceed" with error_during_execution.
Expected
If the control stream for an SDK hook is closed, do not report a user rejection. Either skip the hook (fail open, as for a hook that is no longer registered) or return a distinct, truthful error such as "PreToolUse hook unavailable: control stream closed", so the agent can continue or retry. Ideally the extension deregisters its hooks when its panel closes.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗