Docs sectionsHooks
Docs › Extending agents

Hooks

A hook is a piece of logic that runs automatically at fixed points in a session. Create one by hand in Settings › Hooks or ask Assistant to write it.

On tool useBefore or after the agent calls a tool, for example to block dangerous commands.
On message sendWhen you send a message, for example to inject context.
On session startPrepares the environment when a session begins.
At the end of each turnAfter the agent finishes a turn, for example to run lint.
Command hooks must be approved on the machineA hook that runs a script only works after you read the script and click Approve in Settings › Hooks on that same machine. Saving a hook doesn't approve it, and you can't approve one from your phone.

Every hook run is logged in the session: when it ran, its input, its result and how long it took.