A Hook component packages logic that fires automatically when the agent runtime reaches a specific lifecycle event. Unlike Commands (user-triggered) or Tools (agent-triggered), hooks are reactive — the runtime invokes them in response to events like session start, tool use, or file changes. You don’t call a hook directly; you configure it for an event and the runtime fires it when that event occurs.Documentation Index
Fetch the complete documentation index at: https://agentvolumes.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Entrypoint format
Hook entrypoints can be:- Markdown (
.md) — with YAML frontmatter describing the event and hook type - YAML (
.yaml) — a descriptor with event and type fields - Executable script — any regular executable file
- The entrypoint file exists and is a regular file.
- The descriptor declares or implies a canonical lifecycle event from the vocabulary below.
- The descriptor declares one of the three valid hook types:
command,script, ormodule.
Lifecycle events
Hooks can fire on any of the following canonical lifecycle events:Session events
SessionStart, SessionEnd, SetupUser interaction events
UserPromptSubmit, Stop, StopFailureTool events
PreToolUse, PostToolUse, PostToolUseFailure, PostToolBatchAgent events
SubagentStart, SubagentStop, TaskCreated, TaskCompletedContext events
InstructionsLoaded, PreCompact, PostCompactEnvironment events
ConfigChange, CwdChanged, FileChangedHook types
Three hook types define how the hook executes:| Type | Description |
|---|---|
command | A shell command string executed by the runtime. |
script | An executable file run as a subprocess. |
module | A Node.js or Python module loaded and called. |
Required descriptor fields
For Markdown and YAML hook entrypoints, the descriptor must include:| Field | Required | Description |
|---|---|---|
event | Yes | One canonical lifecycle event from the vocabulary above. |
type | Yes | One of: command, script, module. |
Markdown hook with frontmatter
YAML hook descriptor
Declaring a hook in volume.toml
Add a [[components]] entry with type = "hook" and point entrypoint to your hook file.
Common hook patterns
- SessionStart
- PreToolUse
- PostToolUse
- FileChanged
Run setup logic when a new session begins — initialize state, load configuration, or log the session.
Validation requirements
A hook entrypoint fails portable validation if any of these conditions are true:- The file does not exist or is not a regular file.
- The descriptor cannot be parsed.
- The
eventfield declares a lifecycle event outside the canonical vocabulary. - The
typefield declares a hook type other thancommand,script, ormodule.