Skip to main content

fire_hook

Function
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

Parameters

Union[str, HookEvent]
required
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

List
The hook execution results, or [] when there are no subscribers or the emission was scheduled on a already-running event loop.

Uses

  • resolve_hook_event
  • logger.debug
  • get_default_registry
  • reg.get_hooks
  • HookRunner
  • asyncio.get_running_loop
  • loop.is_running
  • loop.create_task
  • runner.execute
  • _PENDING_HOOK_TASKS.add

Source

View on GitHub

praisonaiagents/hooks/registry.py at line 548

Hooks Concept

Hook Events

Callbacks