Skip to content

fix(hooks): stop recording Claude Code decisions and denials nobody made - #513

Closed
zedoraps wants to merge 1 commit into
blitzcrieg1:masterfrom
zedoraps:fix/claude-hook-approval-requests
Closed

zedoraps wants to merge 1 commit into
blitzcrieg1:masterfrom
zedoraps:fix/claude-hook-approval-requests

Conversation

@zedoraps

Copy link
Copy Markdown
Contributor

What and why

Three fixes in the Claude Code hook adapter, found while mapping Agentmetry events to OCSF for the Tenzir package.

  • Every tool call looked like an approval prompt. Claude Code sends no decision to PreToolUse (permissionDecision is a field of the hook's output), so the adapter's default recorded every call as decision:ask. The reason is now hook:PreToolUse, plus permission_mode:<mode> when the harness reports one. A caller that sends permissionDecision keeps the old form.
  • Notifications turned into denials. Every Notification became an approval request without a tool, which no call could answer, so the session end recorded it as an inferred denial. Only notification_type: permission_prompt is recorded now, and ingest no longer infers an answer for it. On one machine over a week, 1,360 of 3,026 inferred Claude denials came from notifications.
  • Subagent starts were never recorded. Claude Code renamed Task to Agent, so subagent_start never fired and subagent-swarm-burst could not match. Both names count now.

Checks

  • python -m pytest -q and python -m ruff check agentmetry tests pass (from apps/orchestrator)
  • agentmetry benchmark still reports 0 missed and 0 false positives, if detection, hooks or ingest changed
  • No secrets, .env, or real trail data in the diff
  • Docs or CHANGELOG updated if behaviour changed

## Testing in the Agent

claude --permission-mode default

  1. Permission prompt. Type: Run touch hello.txt. Claude Code asks for permission; approve it.
    • Tests that the call is recorded without decision:ask, and that the prompt is recorded as a permission prompt.
  2. Idle notification. Wait about 60 seconds without typing until Claude Code notifies you that it's waiting for input.
    • Tests that this notice is not recorded.
  3. Subagent. Type: Use a subagent to list the files in this folder.
    • Tests that a subagent start is recorded for the Agent tool.
  4. End the session. Type /exit.
    • Tests that no inferred "denied" answer appears.

The detection ruleset is under a freeze: rules.py, traits.py, engine.py, mitre.py and
policies/detection/manifest.yaml are hashed into a published fingerprint. A change to any of
them is welcome as an issue first; CONTRIBUTING.md says why.

@zedoraps
zedoraps force-pushed the fix/claude-hook-approval-requests branch from 9085d25 to 3a51292 Compare November 27, 2026 18:13
Claude Code sends no decision to PreToolUse: permissionDecision is a
field of the hook's output, so the adapter's default recorded every
call as `decision:ask`. The reason is now `hook:PreToolUse`, plus
`permission_mode:<mode>` when the harness reports one. A mode that is
not a plain identifier becomes `unknown`, so it cannot add fields to
the reason. A caller that sends permissionDecision keeps the old form.

Every Notification became an approval request without a tool, which no
call could answer, so the session end recorded it as an inferred
denial. Only a Notification of type `permission_prompt` is recorded
now, and ingest does not infer an answer for it. Notifications that
ask nothing, such as `idle_prompt` or `auth_success`, are not recorded.

Claude Code renamed its subagent tool from Task to Agent, so
`subagent_start` never fired on current versions. Both names count.
@blitzcrieg1

Copy link
Copy Markdown
Owner

Reopening as #515 from a same-repo branch: first-time-contributor fork PRs need workflow approval here, and the branch was rebased onto current master anyway (README count fix). Same commits, author preserved. Closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants