You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/customization/hooks.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ If stdout is JSON and `hookSpecificOutput.permissionDecision` is `deny`, the res
74
74
}
75
75
```
76
76
77
-
Blocking only applies to events that participate in control flow. For example, `PreToolUse` can block a tool call, and `Stop` can append one continuation message to the current turn. Observer events (such as `PostToolUse`, `PostToolUseFailure`, `PostCompact`, `SubagentStop`, `StopFailure`, and `Notification`) are dispatched asynchronously in a fire-and-forget fashion; their return values are ignored and do not change the main flow. `PreCompact` is invoked with `trigger` (not `triggerBlock`); its return value is likewise completely ignored, and it is not a blockable event.
77
+
Blocking only applies to events that participate in control flow. For example, `PreToolUse` can block a tool call, and `Stop` can append one continuation message to the current turn. Observer events (such as `PostToolUse`, `PostToolUseFailure`, `PermissionRequest`, `PermissionResult`, `PostCompact`, `SubagentStop`, `StopFailure`, and `Notification`) are dispatched asynchronously in a fire-and-forget fashion; their return values are ignored and do not change the main flow. `PreCompact` is invoked with `trigger` (not `triggerBlock`); its return value is likewise completely ignored, and it is not a blockable event.
78
78
79
79
When a block takes effect, if the script does not provide a reason through stderr or JSON output, the CLI falls back to `Blocked by <event> hook` as a placeholder reason. A `PreToolUse` block is written back into context as a failed tool result, so the model can choose an alternative based on the reason.
80
80
@@ -88,6 +88,8 @@ The following events are triggered automatically today:
88
88
|`PreToolUse`| Tool name |`tool_name`, `tool_input`, `tool_call_id`| Fires before permission checks. If blocked, the tool does not run |
89
89
|`PostToolUse`| Tool name |`tool_name`, `tool_input`, `tool_call_id`, `tool_output`| Fires after a successful tool call. `tool_output` is truncated to the first 2000 characters |
90
90
|`PostToolUseFailure`| Tool name |`tool_name`, `tool_input`, `tool_call_id`, `error`| Fires after a tool call fails or is blocked by a hook |
91
+
|`PermissionRequest`| Tool name |`turn_id`, `tool_call_id`, `tool_name`, `action`, `tool_input`, `display`| Fires asynchronously immediately before the CLI waits for user approval |
92
+
|`PermissionResult`| Tool name |`turn_id`, `tool_call_id`, `tool_name`, `action`, `decision`, `scope`, `feedback`, `selected_label`, `error`| Fires asynchronously after the approval request resolves or fails |
91
93
|`Stop`| Empty string |`stop_hook_active`| Fires when the model is about to stop. If blocked, the reason is appended directly to context as a system-triggered user message, and the turn may continue once |
92
94
|`StopFailure`| Error type |`error_type`, `error_message`| Fires after the current turn fails with a non-cancellation error |
93
95
|`SessionStart`|`startup` or `resume`|`source`| Fires after the main agent is created for a new session, or after a historical session is resumed |
0 commit comments