hooks • Rust AI Agent SDK

Hooks Module for PraisonAI Rust SDK.

hooks

Rust AI Agent SDK

Hooks Module for PraisonAI Rust SDK.

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.)
  • Function hooks for in-process customization
  • Matcher patterns for selective hook execution
  • Decision outcomes (allow, deny, block)

Usage

rust,ignore
use praisonai::hooks::{HookRegistry, HookEvent, HookResult};

let mut registry = HookRegistry::new();

registry.add_hook(HookEvent::BeforeTool, |input| {
if input.tool_name == Some("dangerous_tool".to_string()) {
return HookResult::deny("Tool blocked by policy");
}
HookResult::allow()
});

let agent = Agent::new()
.hooks(registry)
.build()?;

Import

rust
use praisonai::hooks::*;

Classes


Related Documentation