Has Hook • AI Agent SDK
has_hook: Check if any hooks are registered for an event. Simplified API.
has_hook
Function
</div>
This function is defined in the registry module.
Check if any hooks are registered for an event. Simplified API.
Accepts both string event names and HookEvent enums: has_hook(‘before_tool’) # String has_hook(HookEvent.BEFORE_TOOL) # Enum
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%
graph TD
event["Event Trigger"] --> hook["Hook: has_hook"]
hook --> decision{"Decision"}
decision -- "Allow" --> proc["Process"]
decision -- "Deny" --> block["Block"]
style hook fill:#189AB4,color:#fff
style event fill:#8B0000,color:#fff
style proc fill:#8B0000,color:#fff
style block fill:#8B0000,color:#fffSignature
def has_hook(event: Union[str, HookEvent]) -> boolParameters
ParamField
Union[str, HookEvent]Hook event name or HookEvent enum
Returns
ResponseField
boolTrue if hooks are registered for this event
Exceptions
ValueError
If event string is not a valid HookEvent
Uses
HookEventValueErrorhas_hooksget_default_registry
Source
View on GitHubpraisonaiagents/hooks/registry.py at line 462