Register Function • AI Agent SDK
register_function: Register a Python function as a hook.
register_function
Method
</div>
This is a method of the HookRegistry class in the registry module.
Register a Python function as a hook.
Signature
def register_function(event: HookEvent, func: Callable[[HookInput], HookResult], matcher: Optional[str], name: Optional[str], description: Optional[str], sequential: bool, timeout: float, is_async: bool, priority: int) -> strParameters
ParamField
HookEventThe event to hook
ParamField
CallableThe function to call
ParamField
Optional[str]Optional regex pattern to match targets
ParamField
Optional[str]Optional name for the hook
ParamField
Optional[str]Optional description
ParamField
boolWhether to run sequentially
ParamField
floatTimeout in seconds
ParamField
boolWhether the function is async
ParamField
intExecution order (lower runs earlier). Default 100
Returns
ResponseField
strThe hook ID
Uses
FunctionHookregister
Used By
Source
View on GitHubpraisonaiagents/hooks/registry.py at line 92