Claude Code✓ Confirmed in official docsAdded Oct 23
How to see which rule, hook or sandbox blocked a Claude Code tool call with safety_event
Since Claude Code v2.1.307, OpenTelemetry logs include a claude_code.safety_event event. Its category tells you whether a permission rule, a hook, the auto mode classifier or the sandbox refused a tool call or asked for approval. Use it to find where and why an unattended run stopped.
- Turn on telemetry and export log events. The event has no separate setting; it exports with the other events.
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=console
claude
- In records whose
event.nameissafety_event, readcategoryanddecision. Common values:
permission_ruleandmanaged_policyare deny or ask permission rules.rule_sourcesays which settings they came from.hookmeans a hook such asPreToolUseorPermissionRequeststepped in.auto_mode_blockmeans the auto mode classifier blocked the call.safety_checkis a built-in check, such as reading or writing outside your working directories.circuit_breakernames the check.sandbox_networkmeans the sandbox's network proxy refused a connection;sandbox_violation_countgives the number of refusals.
- A safety event holds no command text, file paths or host names. To see the blocked command, turn on tool details and read
tool_parameterson thetool_decisionevent with the sametool_use_id. This setting puts Bash commands and file paths in your logs, so check where they go first.
export OTEL_LOG_TOOL_DETAILS=1
In a -p run with neither --permission-prompt-tool nor --permission-prompts none, a call refused because nobody could answer the prompt leaves no safety event. Look for a tool_decision event with decision reject and source config instead.
Sources
Get notified when a new tip lands
Tip alerts only go out in the app. Install it and turn notifications on.