Hooks
Hooks let you enforce cross-cutting behavior without rewriting tool or model implementations.
Hook surfaces
Section titled “Hook surfaces”The current runtime exposes hook contexts for:
- tools
- models
- sessions
- user prompts
- sub-agents
Relevant types include:
ToolHookContextModelHookContextSessionHookContextUserPromptHookContextSubagentHookContext
Fluent extensions
Section titled “Fluent extensions”Useful extensions include:
BlockTool(...)BlockToolPattern(...)OnBeforeToolUse(...)OnAfterToolUse(...)
Command hooks
Section titled “Command hooks”CommandHook supports external process hooks when policy or logging should run outside the main runtime process.
Common use cases
Section titled “Common use cases”- approval gates before risky tools
- audit logging
- cost tracking
- security policy enforcement
- custom prompt enrichment