Hooks
Synchronous interceptors that run inside an agent's loop at a lifecycle point and can change what happens next — block it, ask for approval, or inject context.
Create a hook
A hook is an event plus an action.
import { Theazo } from 'theazo'
const theazo = new Theazo({ apiKey: process.env.THEAZO_API_KEY })
// Require human approval before every tool call
const hook = await theazo.hooks.create({
name: 'Approve all actions',
event: 'pre_tool_use',
action: { type: 'ask', reason: 'A human must approve tool use for this agent.' },
})
// Or add standing context at the start of every run
await theazo.hooks.create({
name: 'Date context',
event: 'session_start',
action: { type: 'inject_context', message: 'Today is the start of Q3. Prioritize renewals.' },
})| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Human label, unique within (platform, kind). |
description | string | — | Label; for skills this is the runtime gate (required there). |
enabled | boolean | — | Default true. |
event | 'session_start' | 'user_prompt' | 'pre_tool_use' | 'post_tool_use' | 'pre_compact' | 'subagent_start' | 'subagent_stop' | 'stop' | yes | Agent-run lifecycle point the hook fires at. |
action | object | object | object | yes | What the hook does when it fires. v1: block | ask | inject_context. |
Events
A hook fires at one lifecycle point:
session_startThe agent run begins.
user_promptA prompt / task is submitted.
pre_tool_useBefore the agent invokes a tool.
post_tool_useAfter a tool completes.
pre_compactBefore long-running context is compacted.
subagent_startA team member / fleet task spawns.
subagent_stopA team member / fleet task finishes.
stopThe agent run ends.
Actions
blockStop the run with a reason. A session_start block is a kill-switch. Reuses Guardrails.
askRequire human approval before continuing. On pre_tool_use, gates every tool call. Reuses Approvals.
inject_contextAdd a message into the prompt at that point (e.g. standing context at the start).
SDK methods
theazo.hooks.create(opts)HookCreate a hook.theazo.hooks.list()Hook[]List all hooks on the platform.theazo.hooks.get(id)HookFetch one by id.theazo.hooks.update(id, opts)HookUpdate event or action.theazo.hooks.delete(id)voidDelete. Blocked (409) if still attached.See also: Instructions, Skills, Approvals.