# dispatch_hook

> **Function** in `deepagents_cli`

📖 [View in docs](https://reference.langchain.com/python/deepagents-cli/hooks/dispatch_hook)

Fire matching hook commands with `payload` serialized as JSON on stdin.

The `event` name is automatically injected into the payload under the
`"event"` key so callers don't need to duplicate it.

The blocking subprocess work is offloaded to a thread so the caller's
event loop is never stalled. Matching hooks run concurrently, each with
a 5-second timeout. Errors are logged and never propagated.

## Signature

```python
dispatch_hook(
    event: str,
    payload: dict[str, Any],
) -> None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `event` | `str` | Yes | Dotted event name (e.g. `'session.start'`). |
| `payload` | `dict[str, Any]` | Yes | Arbitrary JSON-serializable dict sent on the command's stdin. |

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/b710a69b12e49479045eaa54dfb709326473500b/libs/cli/deepagents_cli/hooks.py#L158)