Skip to main content
For the full guide, see Hooks.
Start here after you understand the normal session/tool flow. If you are new to Meerkat overall, read Examples: Sessions first.

Post-commit application reaction

Use a committed-fact point when the handler updates UI or telemetry but must never affect the operation it observes:
The request carries HookInvocation.observation with observation_type = "runtime_input_accepted" and typed input id, kind, and handling mode. The operation has already committed. A denial-shaped response, hook failure, or timeout cannot change it.

Observer hook (background)

A post_tool_execution background hook that logs every tool call to a file. Background hooks run asynchronously and never block the agent loop.
Run-scoped hook override flags are not currently exposed on the normal rkat run surface. Use the JSON-RPC, REST, MCP, or SDK examples below for per-run hook override testing.

Guardrail hook (foreground)

A pre_tool_execution foreground hook that must approve each tool call before it runs. If the hook returns deny, the tool is not dispatched and the current run terminates with HookDenied. This is not an ordinary tool-error result that lets the agent continue.
Run-scoped hook override flags are not currently exposed on the normal rkat run surface. Use the JSON-RPC, REST, MCP, or SDK examples below for per-run hook override testing.

In-process hook (Rust only)

Register a Rust closure directly — no subprocess, no serialization overhead. Only available in the Rust SDK.
Hooks receive typed projections of the request, response, tool call, and tool result. They can allow, deny, or observe those facts; they cannot rewrite canonical LLM, tool, or run output.

Gate a tool by provenance

Tool names are not sufficient authority when several MCP servers or bundles can publish the same logical operation. A pre_tool_execution hook can inspect the winning tool definition’s typed provenance:
The same provenance is present on HookToolResult, so post-execution audit hooks can attribute outputs to the exact selected source without re-resolving a tool name.

HTTP hook

A hook that POSTs the invocation payload to a remote URL. Useful for centralized policy servers.
Run-scoped hook override flags are not currently exposed on the normal rkat run surface. Use the JSON-RPC, REST, MCP, or SDK examples below for per-run hook override testing.

All 14 hook points

Foreground hooks halt loop progression until they return. Every hook in background mode is limited to observe capability, including post points. The six post-commit points are always dispatched asynchronously and require observe, regardless of their configured execution mode.

Disable a hook

Use the disable list to turn off hooks defined in the realm config without removing them.
Run-scoped hook override flags are not currently exposed on the normal rkat run surface. Use JSON-RPC, REST, MCP, or SDK/embedded surfaces for per-run hook override testing.

Hook events

Ordinary foreground hooks report lifecycle events in the session event stream. These examples show possible outcomes for the foreground safety-gate hook, not a single execution that both succeeds and fails.
An ordinary background hook such as audit-log may produce HookStarted when actually launched. Capacity skips and later failures are recorded in the in-process background dispatch ledger and tracing; a terminal HookCompleted or HookFailed session event is not promised for that asynchronous work. Post-commit reactions use a separate isolated dispatch path and do not promise these normal lifecycle session events.

Next step