Fire Hook • AI Agent SDK
fire_hook: Emit a lifecycle event to every hook registered for it.
fire_hook
Function
</div>
This function is defined in the registry module.
Emit a lifecycle event to every hook registered for it.
The emitting counterpart to :func:add_hook. Runtime components call this at a real state transition (a kanban task created, a background job finishing) so plugins subscribed to that :class:HookEvent actually hear about it.
Best-effort by contract: an unknown event id, a malformed payload or a raising subscriber is logged and swallowed — emitting an observability event must never break the operation that produced it.
Signature
def fire_hook(event: Union[str, HookEvent], data: Optional[Dict]) -> ListParameters
Union[str, HookEvent]`HookEvent`, its canonical value, or its member name.
Optional[Dict]Payload; recognised keys populate the event’s input dataclass and the remainder is carried through in `extra`.
Returns
ListThe hook execution results, or `[]` when there are no subscribers or the emission was scheduled on a already-running event loop.
Uses
resolve_hook_eventlogger.debugget_default_registryreg.get_hooksHookRunnerasyncio.get_running_looploop.is_runningloop.create_taskrunner.execute_PENDING_HOOK_TASKS.add
Source
View on GitHubpraisonaiagents/hooks/registry.py at line 580