claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Auto mode refuses tool calls after a PreToolUse hook returns updatedInput, and invalidates the whole batch

Open mikekaranja opened this issue 3 weeks ago • 4 comments

What happens

In auto mode, the classifier refuses a tool call when a PreToolUse hook rewrites the call's input with updatedInput. The model has to send the call again. A rewrite of one call also invalidates every other call in the same response, including Write and Edit calls that no hook touched.

Error on the rewritten call:

The server-side auto mode classifier gave no verdict for Bash: a hook changed this call's input after auto mode reviewed it, so the review does not cover what would run.

Error on the other calls in the same response:

The server-side auto mode classifier gave no verdict for Edit: another call in this response was changed after auto mode reviewed it, or could not be confirmed unchanged, so this call's review no longer applies.

Repro

  1. Set permissions.defaultMode to auto.
  2. Add a PreToolUse hook on Bash that returns updatedInput, for example a command-prefixing proxy such as rtk (rtk hook claude), which rewrites jq ... to rtk jq ....
  3. In one response, have the model send a Write, three Edits and one Bash call that the hook rewrites.
  4. All five calls are refused. The model must resend the Write and Edits in one response and the Bash call in another.

Expected

Auto mode reviews the input that will actually run, after PreToolUse hooks have applied updatedInput, or it re-reviews the rewritten input without a round trip through the model. A rewrite of one call does not invalidate unrelated calls in the same response.

Impact

13 of these refusals across 5 of my last 50 sessions. Each refusal costs a resend. A batch refusal costs a resend of every call in the batch. The only local workaround is to remove the rewriting hook, which loses what it does (about 18% of Bash output tokens in this case).

Environment

  • Claude Code 2.1.322, native install, macOS
  • permissions.defaultMode: "auto"

mikekaranja avatar Nov 12 '26 14:11 mikekaranja

Same behaviour here, same kind of hook (a PreToolUse Bash hook that returns updatedInput to prefix the command), on Claude Code 2.1.322 to 2.1.325, Linux, permissions.defaultMode: "auto".

Frequency, counted from local transcripts:

  • 2026-11-03 to 2026-11-16 (14 days): 193 refused tool calls. 104 were the rewritten Bash call itself, 89 were other calls in the same response (Bash, MCP tools, WebFetch, SendMessage).
  • In the most active project that is about 1 % of all Bash calls.
  • In the 16 days before 2026-11-03, with the same hook and settings: 2. So it arrived with an update around that date.

A workaround we measured: dropping the hook and instructing the model to type the prefix itself. Over 18 short headless sessions the model typed the prefix on 16 of 29 commands the hook would have rewritten (55 %), so it does not replace the hook.

eljasdistance avatar Nov 17 '26 14:11 eljasdistance

A related case: the recovery path fails for good when the hook is not idempotent.

When auto mode refuses a rewritten call, it tells the model to issue the call once more with exactly the input the hook produced. That works only if the hook leaves already-rewritten input alone. A PreToolUse hook on Agent that appends a block to the prompt (context-mode 1.0.x did this; it was fixed upstream in 2.x by no longer hooking Agent) appends a second copy to the resent prompt. The input that would run never matches the input auto mode reviewed, so every resend is refused, and after the second refusal the model is told to stop. The subagent cannot be started in auto mode at all.

Repro:

  1. Set permissions.defaultMode to auto.
  2. Add a PreToolUse hook on Agent that returns updatedInput with prompt + "\n<extra/>" (no check for an existing <extra/>).
  3. Ask the model to start any subagent. The first call is refused; the model resends with one <extra/>; the hook makes it two; refused again.

Expected: auto mode reviews the post-hook input (as this issue asks), or at least the refusal message should not prescribe a resend that a non-idempotent hook makes impossible.

Seen in the Claude desktop app (Code tab), November 2026.

outlawpractice avatar Nov 18 '26 00:11 outlawpractice

Same here (Claude Code 2.1.328 to 2.1.332, macOS, auto mode, RTK 1.2.1 on Bash). Counted from transcripts of headless agents on Opus 5.5:

Bash calls Refused
22 Nov, from noon UTC 2,483 20 (0.8%)
23 Nov, from noon 880 100 (11%)
24 Nov, from noon 3,932 419 (11%)

The jump comes with a change in how Opus 5.5 works, not with a Claude Code update (2.1.330 on both sides): from 23 November the median went from 1.00 to 1.54 tool calls per request, so one rewritten call now takes others in the same response with it. Of the refusals on 24 November, about 300 of 500 were "another call in this response", against 9 of 25 on 22 November. Agents then route round the hook (rtk proxy: 9% to about 40-45% of Bash calls), which loses what it is for.

Workaround that held in one test: tell the agent to send one shell command per reply. Reviewing the input after PreToolUse hooks would fix it properly.

DannyGoodall avatar Nov 25 '26 18:11 DannyGoodall

Same here: macOS, auto mode, a PreToolUse hook on Bash that only prefixes sandboxed read-only commands with an output compressor (git status -> rtk git status).

Matched against our PermissionDenied log and the hook's own log, 2026-11-29 to 2026-12-01: the hook rewrote 442 calls, and 29 calls lost their verdict and had to be resent (about 6.6% of rewrites). 12 of them were rewritten calls, 17 were untouched calls in the same response. 13 of the 29 were in subagents, which resend on their own, so the user never sees why their run took longer.

For anyone logging denials: the PermissionDenied hook gets reason: "Classifier unavailable" for these, the same as a real classifier outage. The actual cause is only in the tool result text in the transcript, so we read it from there (related: #72589).

4lemon avatar Dec 01 '26 22:12 4lemon