fire_hook() is the emission counterpart of add_hook(): a runtime component calls it at a real state transition so plugins subscribed to that HookEvent actually hear about it.
Quick Start
1
Subscribe with add_hook
Register a callback for the event you care about. This is all a plugin author needs for the SDK’s built-in events.
2
Emit from your own code
Call
fire_hook() at the moment your code changes state. Subscribers registered above run immediately.3
Emit from an async function
The same call works inside
async def. When a loop is already running, fire_hook schedules the subscribers fire-and-forget on that loop and returns [] without blocking.How It Works
A subscriber runs the moment a real user action triggers an emission.Arguments
fire_hook(event, data=None, *, target=None, registry=None) accepts these arguments.
Event ID Spellings
fire_hook() accepts three spellings for the same event, so legacy call sites using the member name reach the same subscribers.
Use
resolve_hook_event() to normalise an id without emitting:
Payload Shape
Keys that match a field on the event’s input dataclass are set directly; everything else is carried through inextra.
fire_hook builds the right subclass automatically — KanbanHookInput for KANBAN_TASK_*, JobCompletedInput for JOB_COMPLETED, and a plain HookInput otherwise.
Best-Effort Contract
Emitting an observability event must never break the operation that produced it, sofire_hook swallows and logs (logger.debug) these cases.
The return value is the list of hook results, or
[] in any of the cases above.
When To Call This Yourself
The SDK’s kanban store and background job manager already callfire_hook internally, so a plugin author subscribing to a built-in event does not need to emit anything.
Call fire_hook() yourself when:
- You expose a custom lifecycle event from a plugin and want subscribers to react to it.
- You wire a new runtime component that has its own state transitions worth observing.
Best Practices
Keep subscribers cheap and idempotent
Keep subscribers cheap and idempotent
A subscriber can be called again on retry or replay. Make it safe to run twice for the same payload — check before you insert, or upsert instead.
Never block an async emitter
Never block an async emitter
If the emitter runs on an event loop,
fire_hook schedules subscribers on that loop. Blocking I/O inside a hook body stalls the loop — offload to a thread pool or a queue instead.Normalise ids without emitting
Normalise ids without emitting
When you only need to canonicalise an event id (validation, routing), call
resolve_hook_event() rather than fire_hook() — it returns the HookEvent or None and never triggers subscribers.Scope with registry= when needed
Scope with registry= when needed
fire_hook() targets the process-wide default registry. Pass registry= to emit on a scoped registry — useful in tests or when isolating a subsystem’s hooks.Related
Hook Events
Every event you can subscribe to and its payload
Hooks
Register, remove, and inspect hooks

