Skip to main content
Plugins can register hooks to intercept and modify messages, tool calls, and lifecycle events.

Available Hooks

Execution Order

Hooks execute sequentially in plugin config order. If you have:
Then logger’s hooks run before filter’s hooks.

Hook Flow

Channel plugins (Telegram, etc.)

For channels that run in-process with the gateway, hooks execute as part of the AgentManager.prompt() / promptStreaming() call:

TUI (separate process)

For the TUI, LLM calls are proxied through the gateway’s /api/chat/stream endpoint. Hooks execute server-side in the gateway, not in the TUI process:
Note: preToolExec/postToolExec hooks run on tool calls made through the AgentManager path (channel plugins). For TUI tool calls (which go through /api/agents/:name/exec), tools execute directly in the sandbox — preToolExec/postToolExec hooks apply to plugin tool calls routed through the Unix socket, not to core tool execution.

Registering Hooks

Hook Event Types

prePrompt

postResponse

preToolExec / postToolExec

Lifecycle hooks

modelSwitched

Fired when a session uses a different model than the primary — either due to automatic fallback (rate limit, error, timeout) or an explicit user override (e.g. /model command).
Example: send a Telegram notification when a fallback occurs: