rtk icon indicating copy to clipboard operation
rtk copied to clipboard

Claude Code auto mode: each Bash call the hook rewrites loses the server-side review and gets its own local classifier request

Open HetCreep opened this issue 1 month ago • 11 comments

Thanks for RTK and for the Claude Code hook. We traced one interaction between the hook and Claude Code's auto mode that RTK users on auto mode probably want to know about. It is not a bug in RTK's rewrite: the hook does what it should. It is a cost that the rewrite moves onto the user, it is recent (about two weeks old, see the timeline below), and RTK may want to document it or offer a way around it.

Summary

In auto mode, Claude Code can have the server review a Bash call as part of the model's own response, with no separate classifier request. When a PreToolUse hook changes the call's input after that review, Claude Code no longer trusts it and sends the rewritten call to its own local classifier instead: a separate request on Claude Sonnet 5. RTK's hook rewrites most eligible Bash calls, so on auto mode each rewritten call that needs review gets one extra classifier request.

The second check appears because the call is rewritten: in our control run the hook was installed but did not rewrite, and there was none (one run per arm, below). Any hook that rewrites a Bash call triggers it, not RTK alone, so on RTK's side the lever is how and when the hook rewrites.

On one working day of real auto-mode sessions with the RTK hook installed, on a Claude API account, these requests came to 14.7% of the day's bill, or 17.3% on top of what the sessions themselves cost. None of the in-session meters shows them. On a Max plan the same re-check happens on every rewritten call too; there it costs about two seconds of waiting per call, and its effect on the usage limits was too small for the usage gauge to show in our run.

The same behaviour, seen from a Max plan with a stand-in rewrite hook, is reported on the Claude Code side in anthropics/claude-code#102469 (bug) and anthropics/claude-code#102471 (feature request: a cheaper re-check for rewritten calls). We are adding a note there separately; this issue is about what RTK users see.

Timeline (Claude Code CHANGELOG and releases)

  • 2.1.210 (2026-07-14): the auto-mode classifier defaults to Sonnet 5.
  • 2.1.278 (2026-09-19): Claude API and Enterprise sessions default to "the server-side classifier, which does not charge for classifier overhead".
  • 2.1.287 (2026-10-01): the rewrite fallback starts, per the bisect in #102469; the CHANGELOG has no entry for it.
  • 2.1.290 (2026-10-05): "Fixed some permission rules and safety checks not being applied to a tool call after a PreToolUse hook rewrote its input".
  • 2.1.302 (2026-10-16): adds CLAUDE_CODE_AUTO_MODE_MODEL to choose the client-side classifier's model (not yet on the environment-variables page).

So the hook's behaviour did not change: what changed is Claude Code's handling of a rewritten call, two weeks ago. RTK's CHANGELOG through 1.0.1 has no entry on auto mode, the classifier or server-side review, which fits.

Steps to reproduce

  1. Install the hook with the factory entry: {"matcher":"Bash","hooks":[{"type":"command","command":"rtk hook claude"}]} in user settings.
  2. In an empty folder outside any git tree, run one prompt in auto mode with a debug log, asking for one network command: claude -p "<ask for the command below>" --model sonnet --permission-mode auto --debug-file a.log Command: curl -sS -o /dev/null -w "%{http_code}" https://example.com
  3. Repeat with a command the hook leaves alone, for example echo $((1+1)); curl ... (an $(( line, one of the hook's early exits).
  4. In each log, look for [server-classifier] and classifier_request_started.

Expected vs actual

  • Expected (what a user would assume): the rewrite saves tokens and otherwise changes nothing about how the call is reviewed.
  • Actual, run A (rewritten to rtk curl ...):
[DEBUG] Hook PreToolUse (rtk hook claude) modified tool input keys: [command, description]
[DEBUG] [server-classifier] Bash: after the server reviewed the response a hook rewrote this call's input, or that of a call before it; the local classifier judges this one call
[DEBUG] [auto-mode] context comparison: mainLoopTokens=[REDACTED] classifierChars=139467 classifierTokensEst=[REDACTED] (sys=139181 tools=77 user=209) transcriptEntries=1 messages=37
[INFO] [Stall] classifier_request_started reqId=... tool=Bash model=claude-sonnet-5[1m] stage=xml_s1 promptTokensEst=[REDACTED]
  • Control, run C (the hook ran and did not rewrite): Hooks: PreToolUse:Bash [rtk hook claude] finished with status 0 (201ms), then no [server-classifier] line and no classifier_request_started.
  • Run B, the same as A with CLAUDE_CODE_AUTO_MODE_SERVER=1, matched A line for line, so turning server review on explicitly does not avoid it.

One run per arm; A and B agree, and C differs from them only in the rewrite. In run A the hook's answer carried updatedInput and permissionDecisionReason and no permissionDecision, so the call went through Claude Code's normal permission flow, as the hooks reference describes.

Why it matters: the cost moves to the user, out of sight

Claude Code's permission-modes page (code.claude.com/docs/en/permission-modes, read 2026-10-17) says the classifier runs on Claude Sonnet 5 by default, and that "on Enterprise plans and on accounts that use the Claude API ... classifier calls count toward your token usage". Its classifier-billing page says server-side checks run "at no charge", while Claude Code's own classifier requests are "billed as token usage". So on those account types, a rewrite turns a free review into a billed one.

Field measurement. One working day of several auto-mode sessions with the RTK hook installed, on a Claude API account, with main loops on Fable 5.1, Opus 5.5 and Sonnet 5.5: the provider console's cost-by-model view shows a claude-sonnet-5 line, a model none of those sessions ran on, at 14.7% of the day's bill (17.3% on top of the sessions' own cost). We attribute it to the rewrite because of the controlled runs above, and because rtk hook claude was the only PreToolUse hook on Bash that returns updatedInput.

Image

Figure 1: the console's cost-by-model view for that day (UTC). Every non-zero amount and the total are hidden; the rows that read $0 are left as shown.

The re-check rarely reuses its cache. The console's cache view (figure 2: all workspaces, the last 7 days, data as of Oct 17 04:00 UTC; in that window Claude Code ran on this account only on the field day, and its other use that week was direct API calls on other models) shows Sonnet 5's input with no uncached part and a write amortization of 2.41×, against 12.3× for Sonnet 5.5, 3.01× for Opus 5.5 and 3.07× for Fable 5.1; about 29% of Sonnet 5's input tokens were cache writes. So a typical re-check sits well above the all-cache-hits floor used below: at that mix and list prices, about $0.87 per million input tokens, roughly four times the floor.

Image

Figure 2: the console's cache usage breakdown by model. The input-token column is hidden; the bars and ratios are as shown.

Where it weighs most. The re-check always runs on Sonnet 5, whatever the session's model. A cached token costs $0.20/M on Sonnet 5, against $0.10 on Sonnet 5.5, $0.20 on Opus 5.5 and $0.25 on Fable 5.1 (platform.claude.com pricing page, read 2026-10-17). So, token for token, a re-check's context read costs about twice a main turn's in a Sonnet 5.5 session, about the same in Opus 5.5 and about 0.8 of it in Fable 5.1: the relative overhead is largest for users on the cheaper main model.

Nothing in the session shows it. The requests are not in the -p result's modelUsage or total_cost_usd (#102469 found the same), and with Claude Code's OpenTelemetry on, a repeat of run A emitted api_request events only for the session's own turns: the classifier request emitted none. A user sees them only in a debug log or in the provider's console. This may also explain part of what #3175 describes.

When RTK still comes out ahead. It depends on how often a rewritten call needs review. Per command, both sides in dollars:

  • RTK's saving for a command whose output it trims by S tokens: about S × (cache write + T × cache hit) at the main model's prices, since a token kept out of context is not written once and then read on each of the T remaining turns.
  • One reviewed rewrite costs one classifier request of P tokens on Sonnet 5: between P × $0.20/M (all cache hits) and P × $2.50/M (all fresh cache writes), at list prices.
  • RTK comes out ahead only while the share f of rewritten calls that need review stays under f* = saving / cost.

Illustrative numbers, not measurements of anyone's usage: P = 35,000 tokens (the request above, at a rough 4 characters per token), T = 100 turns left.

Main model S trimmed Saving per command Cost per reviewed rewrite f*
Sonnet 5.5 ($2.50 write, $0.10 hit) 100 tokens $0.00125 $0.007 to $0.0875 18% to 1.4%
Sonnet 5.5 1,000 tokens $0.0125 $0.007 to $0.0875 always ahead to 14%
Opus 5.5 ($5 write, $0.20 hit) 100 tokens $0.0025 $0.007 to $0.0875 36% to 2.9%

At the cache mix of figure 2 (about $0.87/M), the cost per reviewed rewrite is about $0.03, which puts f* near 4% for the first row, 41% for the second and 8% for the third.

So for small trims, a few reviewed rewrites can cost more than RTK saves; for large trims RTK can still come out ahead.

On a Max plan it costs time. We ran the same 40 network calls twice in fresh claude -p --model sonnet --permission-mode auto sessions on a Max plan: once as plain curl (the hook rewrote all 40) and once behind echo $((n)); (no rewrite). The rewritten arm made 40 local classifier requests on claude-sonnet-5[1m], the other none. The requests took a median of 2.1 s each (n = 40, min 1.9 s, max 3.0 s), and the rewritten arm took about twice as long overall, 237 s against 117 s. The five-hour and seven-day usage gauges (rate_limit_event, reported in whole percentage points) did not move during either arm, so the re-checks' share of the usage limits stayed below the gauge's resolution; it is not shown to be zero.

What this does not prove

  • The field share is one day of data (n = 1).
  • The effect on the usage limits of Pro and Max plans is bounded only by the gauge's resolution (one run of 40 re-checks, no visible move); the docs say nothing about how these requests count there.
  • The cache mix comes from the console's 7-day view, not from the requests themselves (the debug log redacts their token counts).
  • A local classifier request can also come from a session the server does not review at all. The controlled runs did not see that, but the field day's sessions ran without debug logs, so it cannot be ruled out for them.
  • The share f of rewritten calls that need review was not measured, nor how much of P is fixed and how much grows with the session (#102469 saw a similar size, sys=149300, in a minimal setup).
  • Windows and Claude Code 2.1.302 only.

Environment

  • Claude Code 2.1.302, claude -p, --permission-mode auto, main model Sonnet 5.5
  • RTK 1.0.1, user-scope hook as above
  • Windows 11, Git Bash
  • A Claude API account (Console sign-in); the OpenTelemetry repeat and the 40-call timing runs ran on a Max plan

What RTK could do

Your call on all of these; listed in order of effort:

  1. Document it in hooks/claude/README.md and in what rtk init prints for Claude Code: in auto mode, each rewritten call that needs review gets a separate classifier request, billed on Claude API and Enterprise accounts and invisible to Claude Code's own meters.

  2. Point auto-mode users at the existing knob: [hooks] exclude_commands in config.toml already lets a user keep RTK away from the commands most likely to need review, such as network commands ("^curl", "^wget", as in the configuration guide).

  3. Skip the rewrite in auto mode, or let users opt out of rewriting there: the PreToolUse input carries permission_mode, one of "default", "plan", "acceptEdits", "auto", "dontAsk" or "bypassPermissions" (code.claude.com/docs/en/hooks, the common input fields and the PreToolUse example on stdin). The Codex handler already passes a call through for modes it does not support (is_supported_codex_permission_mode in src/hooks/hook_cmd.rs at 7bff768), so a setting such as [hooks] skip_in_auto_mode = true could use the same shape for Claude Code. Whether it should be the default is a trade-off you can judge better than we can.

  4. The longer road, which needs both projects: a narrow wrapper contract, which RTK could propose in anthropics/claude-code#102471 (https://github.com/anthropics/claude-code/issues/102471). Claude Code could reuse the server's verdict on the original command, instead of running a new client-side check, when two things hold: the rewrite is a pure prefix wrapper that Claude Code verifies mechanically (the rewritten command equals rtk plus the original command, character for character), and the wrapper is one the user or Claude Code lists as running the original command verbatim and only filtering its output, the way timeout or nice leave a command's meaning alone. Trusting every rewrite is not the ask: that would let any hook carry a command past review, which is why the re-check exists.

    From RTK's code at 7bff768, most rewrites today would not qualify, because the filtered subcommands change the command they run: rtk curl adds -s before the user's arguments (src/cmds/cloud/curl_cmd.rs), and rtk git log adds a default limit (-10, or -50 with a format flag) and --no-merges unless the user asked otherwise (src/cmds/git/git_cmd.rs). #3611 (since fixed) showed a rewrite that changed the program itself, rg to rtk grep. The form that runs a command unchanged, rtk bypass (alias rtk proxy), does no filtering. So the contract would first need a mode on RTK's side that runs the original argv exactly and filters only the output; rewrites that change the program or its flags would still need the re-check.

We are not asking for permissionDecision: "allow" to skip the review. The hook emits it today only for simple Copilot CLI rewrites (0.44.0, #3037), and as #3018 settled, approving every rewritten call is not RTK's decision: the re-check is the safe design on Claude Code's side, otherwise any hook could pass a command around review.

Happy to run a build or a different probe on this setup if that helps.

cc @KuSh, since you maintain the Claude Code hook and settled the permissionDecision question in #3018.

HetCreep avatar Oct 17 '26 08:10 HetCreep

wshm · Automated triage by AI

🔍 Automated Triage

🐛 Category bug
🟡 Priority medium
🎯 Confidence 82%

Summary

PreToolUse hook rewrites cause Claude Code to fall back from free server-side Bash review to a billed local Sonnet-5 classifier request per rewritten call, hiddenly inflating cost on API/Enterprise accounts; RTK should document/mitigate (upstream bug anthropics/claude-code#102469, feature anthropics/claude-code#102471).

📁 Relevant files
  • docs/hooks.md
  • src/hook/claude.rs

Suggested Actions

  1. Cross-reference anthropics/claude-code#102469 and #102471 for upstream fix/feature status before acting
  2. Consider documenting this cost tradeoff in RTK's Claude Code hook docs
  3. Evaluate whether RTK can reduce unnecessary rewrites to minimize re-classifier triggers
  4. Compare with prior cost-report issue #582 for related historical context

Triaged automatically by wshm · This is an automated analysis, not a human review.

rtk-wshm-sync-bot avatar Oct 17 '26 08:10 rtk-wshm-sync-bot

Confirmed on rtk 0.51.0 with Claude Code 2.1.303 (macOS, interactive session in auto mode).

The problem

In auto mode, the server reviews the model's response before any hook runs. When rtk hook claude returns updatedInput, Claude Code no longer trusts that review and sends the rewritten call to its local classifier. On my machine this means, for every rewritten Bash call:

  • 2.4–3.2 s of extra wait (Slow permission decision: 3165ms for Bash (mode=auto, behavior=allow)).
  • A request that grows with the session: classifierChars=252417 in a long session, against about 149K in the minimal repro in anthropics/claude-code#102469.
  • Sometimes a denial. The local classifier denied a read-only git status ...; grep ... | tail (rewritten to rtk git status ...) as [Modify Shared Resources].

I agree with #3018 that the re-check is Claude Code's call to make, and the real fix belongs upstream (anthropics/claude-code#102469, #102471). Until that lands, rtk could limit the damage.

Suggestions for rtk

  1. Do not rewrite in auto mode, as an option. The PreToolUse hook input carries permission_mode. A setting such as [hooks] skip_permission_modes = ["auto"], or a flag on rtk hook claude, would return no updatedInput when permission_mode is "auto". Users keep rtk's savings in the other modes and lose only the compaction in auto mode.
  2. Document the trade-off in the Claude Code hook docs and in rtk init output: in auto mode each rewrite costs one local classifier request and can turn an allowed call into a denial. Point auto-mode users to rtk init --claude-md (the model types the prefix, so the server reviews the rtk command itself), and to [hooks] exclude_commands to keep rewrites to the commands that save the most.

NateCC0902 avatar Oct 19 '26 15:10 NateCC0902

Thanks for confirming this on macOS and for the denial case. We have not seen a denial here, so we can't confirm it, but if the re-check can turn an allowed read-only call into a failure, the impact goes beyond cost and latency.

Your setup and ours cover two versions on each side: rtk 0.51.0 with Claude Code 2.1.303 (yours), rtk 1.0.1 with Claude Code 2.1.302 (ours, Windows). The fallback is the same on both.

On suggestion 1: the skip can be narrower than every rewrite in auto mode. In our probes (Max plan, auto mode, Claude Code 2.1.302, rtk 1.0.1, 2026-10-17), a rewrite whose rewritten rtk ... command matched a Bash allow rule (such as Bash(rtk git status*)) cost no local classifier request: 9 of 9 (rtk git status, git log, git diff, git branch, ls, wc, grep, find, read). A rewrite that no allow rule covered cost one each: 5 of 5 read-only ones (rtk git stash, du, rg, diff, stat) and 2 of 2 curl.

So a skip keyed on permission_mode == "auto" could also check the rewritten command against the allow rules, and return no updatedInput only when none covers it. Covered rewrites keep their savings. We run this as a local wrapper around rtk hook claude. Under it, the same five uncovered calls ran unrewritten with no local classifier request, and the covered ones were still rewritten.

Two limits we found:

  • The wrapper sees only the allow rules in the settings files, not --allowedTools or managed settings.
  • It treats a compound command (;, |, &&, substitutions) as uncovered, because Claude Code checks those part by part. Your denied call was compound, so under that rule it would have run unrewritten.

If it helps, we can re-run the probes on a newer rtk or Claude Code release.

HetCreep avatar Oct 19 '26 17:10 HetCreep

Also reproduced on Claude Code 2.1.312 (rtk 1.1.0 with pre tool use command hook), it is a denail, not a re-check.

"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."

It happens whenever no allow rule covers the command, so rtk returns the rewrite with no permissionDecision. Compound read-only commands like git log ... | head; echo ...; grep ... | head are hit too. The Claude docs say a settings command hook should be exempt, so I'm not sure why mine isn't.

galshi avatar Nov 05 '26 15:11 galshi

Reproduced on rtk 1.2.0 (Homebrew) with Claude Code 2.1.322 on macOS 26.6, in auto mode. I saw the same results on rtk 0.50.0 before the upgrade, so the upgrade does not change the behavior. As in the 1.1.0 report above, the result is a denial, not a slower second review.

Setup

  • rtk init -g, which installs rtk hook claude as a PreToolUse command hook with the matcher Bash in ~/.claude/settings.json.
  • Claude Code in auto mode.
  • Allow rules that include Bash(grep:*), Bash(ls:*), Bash(rtk grep *) and Bash(rtk ls *). No rule covers head or python3.

What the hook returns

This part needs no Claude Code session. The output is the same on 0.50.0 and 1.2.0, and the hook ignores permission_mode:

$ printf '%s' '{"hook_event_name":"PreToolUse","tool_name":"Bash","permission_mode":"auto","tool_input":{"command":"grep -rn foo . | head -5"}}' | rtk hook claude
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk grep -rn foo . | head -5"}}}

$ printf '%s' '{"hook_event_name":"PreToolUse","tool_name":"Bash","permission_mode":"auto","tool_input":{"command":"python3 -c \"print(2)\""}}' | rtk hook claude
$

Result 1: the rewritten call is denied

Ask the model to run this command:

grep -rn --include='*.md' "foo" <dir> | head -5

Claude Code denies the 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. This is not a judgment that the action is unsafe. The hook produced this input: {"command":"rtk grep -rn --include='*.md' \"foo\" <dir> | head -5", ...}. In your next response, issue the Bash call once more with exactly that input so auto mode reviews it.

The model then sends the rtk grep ... command as its own call, and that call runs. Each such command costs one failed call and one more model turn.

Result 2: a call that the hook did not change is denied too

This effect is not in the thread yet. Ask the model to send these two Bash calls in one response:

grep -c "rtk" ~/.claude/settings.json | head -1
python3 -c "print(1+1)"

The first call runs. The second call is denied, although the hook returns nothing for it:

The server-side auto mode classifier gave no verdict for Bash: 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. This is not a judgment that the action is unsafe. Issue the Bash call again in a response of its own, exactly as this conversation records it, after you have seen the results of the other calls.

Sent alone in the next response, python3 -c "print(1+1)" runs. So one rewrite in a response can remove the review of the other Bash calls in that response, and the model must send them again one at a time.

Not each rewrite is denied

In the same response as the command of result 1, ls -lt <dir> and git -C <repo> status were rewritten and ran without a denial.

Request

Suggestion 1 above (return no updatedInput when permission_mode is "auto", as a setting) removes both results. In 1.2.0 the [hooks] section has exclude_commands, transparent_prefixes, suppress_hook_warning and wrap_fish_scripts, and none of them depends on the permission mode.

robertocaldas avatar Nov 12 '26 09:11 robertocaldas

Data point in support of suggestion 1 (skip the rewrite when permission_mode is "auto"), on rtk 1.2.0 (rtk-oss build, Linux):

  • Cost side. In one long auto-mode session, roughly 14 of about 45 Bash calls were rewritten, and each rewritten call was refused once and had to be re-issued verbatim. Every refusal costs a full extra model turn, plus the classifier wait described above.
  • Benefit side. rtk gain reports ~106 tokens saved per rewritten command on average (2.3M saved over ~21.6k commands). Most of that comes from large outputs, not the short git status / grep -n calls that dominate in an agent loop.

So in auto mode the rewrite is a net loss by about two orders of magnitude for us.

The workaround works today. A small PreToolUse wrapper reads the hook JSON and checks permission_mode:

  • if it is "auto", it exits 0 with no output, so the call passes through untouched;
  • otherwise it pipes the same stdin to rtk hook claude.

It is fail-open: any parse error means no rewrite. Over several hundred calls since, every auto-mode call carried permission_mode: "auto" (subagents included) and none was refused. Other modes (default, acceptEdits) still get rtk's rewrites.

A built-in option along the lines of [hooks] skip_permission_modes = ["auto"] would make the wrapper unnecessary. Related: #3230 (the command prefix rewrite) is the other case we hit, where the rewritten command rtk grep … output broke scripts that parse grep output.

theja0143 avatar Nov 12 '26 11:11 theja0143

Data point from one Claude Code session in auto mode (rtk 1.1.0 hook, rtk hook claude): about 14 of 45 Bash calls were rewritten and each was refused once by the auto-mode review ("a hook changed this call's input after auto mode reviewed it") and had to be re-issued. Each re-issue is a full extra model turn, which costs far more than the ~100 tokens the rewrite saves per call (our rtk gain average). We now skip the rewrite while the permission mode is auto (wrapper hook reading permission_mode from the hook input) and call rtk explicitly for large outputs.

theja0143 avatar Nov 14 '26 17:11 theja0143

Data point from ~25 days of agent-heavy auto-mode use (rtk 1.2.x, Claude Code 2.1.3xx, macOS, mostly sub-agents):

  • 74,454 rewritten Bash calls; 2,221 were refused with "a hook changed this call's input after auto mode reviewed it" (3.0%). Median retry 3.8 s.
  • By rtk's decision: ask rewrites refused at 1.8% (1,316 / 72,959); allow rewrites 0 / 1,518. So the allow path does avoid the re-check.
  • 1,314 of the 1,316 refused ask calls were compound commands (cd … && …, … | head). rtk returns allow only when every segment matches an allow rule, so adding allow rules covers very little: simulating ten extra read-only rules flipped 15 of 1,316.
  • Net effect is still clearly positive for us. Cap-adjusted savings ≈ 18.5M tokens vs ≈ 1.2M direct tokens spent on retries (≈ 9:1 for the heaviest single project). So "skip the rewrite in auto mode" would throw away most of the benefit for agent-heavy workloads. The rtk gain per-command average understates this, because savings concentrate in large ls/grep outputs.
  • What works for us: a small wrapper around rtk hook claude that adds permissionDecision: "allow" only when every segment of the rewritten command is on a strict read-only list (no redirection to files, no $(…), no background, no --write-style flags, no sed/find/xargs), and passes everything else through. Settings deny/ask rules still apply on top. With #4644 in mind, a built-in version would need the same strictness: an opt-in "read-only compound allow" mode rather than allowing every rewrite.

AxGord avatar Nov 28 '26 10:11 AxGord

Thank you all for the reports and counts in this thread. The refusals described from 2.1.312 on are not what we saw on 2.1.302, so below we say what our numbers cover and what they do not. Everything here is a count from our own logs; none of it is a new measurement of the re-check.

Versions. The probes and figures in the issue body and in our comment of 2026-10-19 were taken on Claude Code 2.1.302 and rtk 1.0.1. Our machine now runs Claude Code 2.1.332 and rtk 1.2.1. We have not re-run the probes on these versions, so those figures stand for the versions they name only. We cannot say whether a re-check that costs time, which is what we measured, still happens on current builds, or whether it is now the refusal that @galshi (2.1.312) and @robertocaldas (2.1.322) describe.

A correction to our own comment. We wrote that our wrapper treats a compound command as uncovered. That was true then. Since 2026-10-20 it splits a command on &&, ||, ;, | and line breaks, reads quotes, and counts a rewrite as covered only when an allow rule matches every part. It still treats an expansion ($, backticks), a redirection and a lone & as uncovered.

What the wrapper decided. From its decision log, 2026-11-18 to the evening of 2026-11-29 UTC (the log keeps two rolled files, so that is all there is): 21,672 decisions in auto mode. 19,820 were skipped (91.5%), 1,846 were passed on for rewriting, and in 6 the hook failed to run. The log records the decision and the rtk subcommand, not the reason, so we cannot yet say how much of the nine in ten is compound and how much is a command no allow rule covers.

Refusals in our own transcripts, counted by a small script that prints counts only: 2026-11-25 to 2026-11-29, 1,721 transcripts, 20 auto-mode "no verdict" refusals.

  • 0 say a hook changed the call's input, in a period in which the wrapper passed 734 rewrites on.
  • 12 say another call in the same response was changed or could not be confirmed unchanged.
  • 8 mention a leading cd.
  • 18 of the 20 were compound commands.

We cannot tell which rewrite, if any, caused the 12 sibling cases, because our log does not link the calls of one response.

@AxGord, on your 25 days:

1,314 of the 1,316 refused ask calls were compound commands (cd … && …, … | head).

Our 18 of 20 points the same way, but the two sets differ: our wrapper leaves uncovered rewrites unrewritten, so the refusals you counted should not occur for us. One question, since it decides what "compound" means in your numbers: does your check read quotes? Our wrapper counted a quoted | (a grep alternation) as a pipeline until we fixed that on 2026-10-20, and it skipped rewrites it should not have.

@robertocaldas, on your second result:

So one rewrite in a response can remove the review of the other Bash calls in that response, and the model must send them again one at a time.

Our 12 sibling refusals fit that, but our data cannot show it. In your response, did an allow rule cover the rewritten call?

What would settle it, for anyone on current versions: a compound command whose every part an allow rule covers. If it passes unrefused, what is left to explain is why nine in ten calls still do not qualify. We have not run it on 2.1.332.

Thanks to @NateCC0902, @galshi, @robertocaldas, @theja0143 and @AxGord for reproducing this and for the numbers.

HetCreep avatar Nov 29 '26 18:11 HetCreep

@HetCreep thanks. Answers to both questions, from our transcripts.

Quotes. I re-ran the count with a quote-aware split (the same segments() our wrapper uses: &&, ||, ;, | and newlines outside quotes). Of 1,374 "a hook changed this call's input" refusals (2026-11-03..29) with the command found, 1,355 are compound (98.6%); a naive operator match says 1,372. The 17 difference are all jq filters with a quoted |. So quoting does not change the picture. (My 2,221 earlier counted every no-verdict refusal: ~1,320 "hook changed this call's input", ~850 "another call in the same response", the rest other.)

What would settle it, on 2.1.332. Since 2026-11-28 our wrapper has answered allow 1,458 times (1,434 distinct commands, 1,320 of them compound), only when every segment is on a strict read-only list. None of those rewritten inputs was refused: 0 matches among the refusals whose quoted hook input could be parsed (1,353 of 1,363). Every refusal in that period was recorded by Claude Code 2.1.332. So a compound command whose every part is covered does pass unrefused on 2.1.332. The refusals that remain (46 since then) are the wrapper's pass-through cases, mostly compound with a leading cd, and the sibling-call variant.

Caveat: the wrapper does not check the permission mode, so a share of those 1,458 may come from non-auto sessions; nearly all of ours run in auto.

AxGord avatar Nov 29 '26 19:11 AxGord

@AxGord thank you, that settles both. With quotes read the picture holds, and your 1,458 covered rewrites with no refusal on 2.1.332 answer the question we left open better than a probe of ours would have. Our wrapper does not answer allow, so our remaining refusals are the pass-through cases you describe, mostly a leading cd and the sibling variant.

HetCreep avatar Nov 29 '26 19:11 HetCreep