Skip to content

Claude Code mod: hook tool.run by name; the mod needs Claude Code 2.1.326+ - #4222

Merged
backnotprop merged 15 commits into
mainfrom
fix/claude-code-tool-run-hook
Nov 29, 2026
Merged

backnotprop merged 15 commits into
mainfrom
fix/claude-code-tool-run-hook

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Fixes #3915.

The bug

From Claude Code 2.1.329, on logins where Claude Code's own guard holds tool calls first (Team and Enterprise), the tool.run event reaches only a hook registered under that exact name. The mod registered tool.*, so it never heard the event: the plannotator tool's annotate, review and last answered "registered the tool plannotator but no hook answered this call", and a plannotator annotate|review|last run through Bash fell back to the blocking CLI.

The fix

The mod registers one hook on tool.run by name. The earlier tool.* hook served that event and nothing else, so it is removed.

The mod now needs Claude Code 2.1.326 or later

Claude Code before 2.1.326 has no tool.run event and refuses a hooks module that names it. We found no way for one module to serve both ranges, so on Claude Code 2.1.287 to 2.1.325 the mod no longer loads: no plannotator tool, no plannotator_inbox tool, no Inbox reply wake. The /plannotator-* skills (installed outside the plugin) and the CLI are unaffected. The plugin's classic plan-review hook is expected to keep running there, but no test covers that.

Every place that states the mod's minimum version now says 2.1.326 (README, docs site, the Inbox's setup hint, plannotator inbox --help).

Tests

  • Unit: the by-name registration is guarded (the tests fail with tool.* put back).
  • Engine harness: 2.1.327 and 2.1.330 run the full suite, with a stand-in guard that holds the tool's call and checks annotate, review and last each open once at tool.run. On 2.1.287 and 2.1.325 the job checks that the run fails with the module's "tool.run" is not an event refusal and that no module is refused for another reason.

Not proven

  • A real guarded Team or Enterprise session (the issue's reporter confirmed the same change by hand on 2.1.330).
  • What a real Claude Code before 2.1.326 does with the plugin's command hooks once it has refused the module.

From Claude Code 2.1.329 the engine no longer raises tool.run for a hook
registered as tool.*; it still raises tool.call and tool.check there. Behind
the guard's early-run rule (Team/Enterprise logins) the mod passes a held
plannotator tool call or taken-over Bash command on at tool.call and opens it
at tool.run, so every such open fell through to "no hook answered this call"
(#3915).

The run hook is now registered as tool.run, inside a try: an engine before
2.1.326 refuses the name, and there no call is ever passed on to tool.run.
The tool.* glob is gone, and with it the mod's place in every tool.* chain
(the "its tool.describe hook was skipped" line behind the guard).

The bun test raises tool.run only to a hook registered by that name, and
loads the module through an on() that refuses the name. The engine harness
stand-in guard hooks tool.call and tool.run by name, and CI's harness matrix
adds 2.1.330.
An engine before 2.1.326 refuses to load a module whose source names
tool.run, so the literal on('tool.run') in register.ts took every
Plannotator feature away there. run.ts holds only that hook and calls
the one register.ts hands over (setRunHook); an older engine refuses
run.ts alone and keeps register.ts. No tool.* glob remains, so one hook
hears tool.run on every engine.
Not the final change. One hooks module again (run.ts removed: 2.1.287
refuses a plugin with two modules). The run hook stands on the patterns
the engine's grammar allows that could select tool.run without naming it,
first outermost: `*`, `!engine.create`, `tool.*`, each matched on
RUN_MATCHER. The first registration to hear a call owns it (keyed by
tool_use_id); later ones pass it on, so an engine where several hear it
opens the call once. Each hearing is recorded (early-run.ts runHeard) and
written to the mod's debug log when it is on.

The engine harness gets one probe per pattern (a Bash command the mod
passes on) that prints what heard tool.run and asserts its pattern did.
The Claude Code mod guide is now stale.
…iment

From Claude Code 2.1.329 no glob hears tool.run, so the run hook is
registered as on('tool.run', RUN_MATCHER, <function literal>), the one hook
on that event. Claude Code before 2.1.326 refuses the module for it, so the
mod now needs 2.1.326 or later (#3915). The bun tests hold the registration
to one hook with a literal name in the source.
On 2.1.287 and 2.1.325 the script now expects the hooks module refused for
naming tool.run: every test must fail with that refusal and none pass. On
2.1.327 and 2.1.330 a second stand-in guard, refusing every launch while
the tool's call is held, checks annotate, review and last opened at
tool.run.
@backnotprop backnotprop changed the title Claude Code mod: hook tool.run by its name (Claude Code 2.1.329+) Claude Code mod: hook tool.run by name; the mod needs Claude Code 2.1.326+ Nov 29, 2026
@backnotprop
backnotprop marked this pull request as ready for review November 29, 2026 21:43
@backnotprop backnotprop added the ci:e2e Run the full browser suite (Inbox window e2e) on this PR label Nov 29, 2026
@backnotprop
backnotprop merged commit fad8d7c into main Nov 29, 2026
68 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:e2e Run the full browser suite (Inbox window e2e) on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code 2.1.329+: plannotator tool annotate/review never opens — tool.run no longer reaches the tool.* glob hook

1 participant