Hook Authoring
Hook Points
Meerkat provides 8 hook points in the agent lifecycle:
- •RunStarted — When the agent run begins
- •PreLlmRequest — Before sending to the LLM
- •PostLlmResponse — After receiving LLM response
- •PreToolExecution — Before executing a tool call
- •PostToolExecution — After tool execution completes
- •TurnBoundary — At the boundary between turns
- •RunCompleted — When the agent run completes successfully
- •RunFailed — When the agent run fails
Execution Modes
- •Foreground: Blocks execution, can modify/deny. Use for policy enforcement.
- •Background: Runs concurrently, fire-and-forget. Use for logging, analytics.
- •Observe: Receives events but cannot block. Use for monitoring.
Decision Semantics
Hooks return one of:
- •Allow: Proceed normally
- •Deny: Block the operation with a reason
- •Rewrite: Modify the operation (e.g., rewrite tool arguments)
Patch Format
For PreToolExecution, hooks can rewrite tool arguments using JSON patches.
Failure Policy
- •fail-closed: Hook failure blocks the operation (safer)
- •fail-open: Hook failure allows the operation (more resilient)