> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# hooks • Rust AI Agent SDK

> Hooks Module for PraisonAI Rust SDK.

# hooks

<Badge color="orange">Rust AI Agent SDK</Badge>

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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
use praisonai::hooks::*;
```

## Classes

<CardGroup cols={2}>
  <Card title="HookInput" icon="brackets-curly" href="../classes/HookInput">
    Input data for hooks
  </Card>

  <Card title="HookResult" icon="brackets-curly" href="../classes/HookResult">
    Result from a hook execution
  </Card>

  <Card title="HookDefinition" icon="brackets-curly" href="../classes/HookDefinition">
    Hook definition
  </Card>

  <Card title="HookRegistry" icon="brackets-curly" href="../classes/HookRegistry">
    Hook registry for managing hooks
  </Card>

  <Card title="HookRunner" icon="brackets-curly" href="../classes/HookRunner">
    Hook runner for executing hooks in a workflow
  </Card>

  <Card title="HookEvent" icon="brackets-curly" href="../classes/HookEvent">
    Event names for the hook system
  </Card>

  <Card title="HookDecision" icon="brackets-curly" href="../classes/HookDecision">
    Decision types for hook outputs
  </Card>
</CardGroup>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Hooks" icon="anchor" href="/docs/rust/hooks" />

  <Card title="Rust Events" icon="bolt" href="/docs/rust/events" />

  <Card title="Rust Callbacks" icon="phone" href="/docs/rust/callbacks" />
</CardGroup>
