Skip to main content

hooks

AI Agent Hooks Module for PraisonAI Agents. Provides a powerful hook system for intercepting and modifying agent behavior at various lifecycle points. Unlike callbacks (which are for UI events), hooks can intercept, modify, or block tool execution. Features:
  • Event-based hook system (BeforeTool, AfterTool, BeforeAgent, etc.)
  • Shell command hooks for external integrations
  • Python function hooks for in-process customization
  • Matcher patterns for selective hook execution
  • Sequential and parallel hook execution
  • Decision outcomes (allow, deny, block, ask)
Zero Performance Impact:
  • All imports are lazy loaded via centralized _lazy.py utility
  • Hooks only execute when registered
  • No overhead when hooks are disabled
Usage:

Import

Constants


Hooks Concept

Hook Events

Callbacks