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

python
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) -> str

Parameters

ParamField HookEvent

The event to hook

ParamField Callable

The 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 bool

Whether to run sequentially

ParamField float

Timeout in seconds

ParamField bool

Whether the function is async

ParamField int

Execution order (lower runs earlier). Default 100

Returns

ResponseField str

The hook ID

Uses

  • FunctionHook
  • register

Used By

Source

View on GitHub

praisonaiagents/hooks/registry.py at line 92