hooks.base
Hook event types and data models.
HookEvent Objects
class HookEvent(str, Enum)
Events that can trigger hooks.
PRE_TOOL_USE
Before tool execution. Can allow, deny, or modify arguments.
POST_TOOL_USE
After successful execution. Can modify the result.
POST_TOOL_USE_FAILURE
After failed execution. For error reporting/recovery.
HookInput Objects
@dataclass
class HookInput()
Input passed to a hook handler.
Parameters
event : HookEvent The event that triggered this hook. tool_name : str Name of the tool being executed. tool_args : dict Tool call arguments (for PRE hooks, may be modified). tool_result : str | None Tool execution result (POST hooks only). error : Exception | None Tool execution error (POST_TOOL_USE_FAILURE only). agent_id : str | None The agent ID. user_id : str | None The requesting user ID. metadata : dict Additional context (turn number, token count, etc.).
HookResult Objects
@dataclass
class HookResult()
Result returned from a hook handler.
Parameters
allow : bool PRE_TOOL_USE: False → deny the tool call. reason : str | None Explanation (shown to agent if denied). modified_args : dict | None PRE: Replace tool arguments. modified_result : str | None POST: Replace tool output.