Skip to main content

Simplified API Reference

PraisonAI provides simplified helper functions following consistent naming patterns for common operations.

Naming Convention


Hooks

Intercept and modify agent behavior at lifecycle points.

add_hook

Register a hook for an event.
Parameters:
  • event (str | HookEvent): Event name like 'before_tool', 'after_tool', 'before_llm', etc.
  • callback (callable, optional): Hook function. If omitted, returns decorator.
  • priority (int): Hook priority (lower = runs first). Default: 10
  • matcher (str, optional): Pattern to match (e.g., 'write_*')
Events: before_tool, after_tool, before_llm, after_llm, before_agent, after_agent, session_start, session_end, on_error, on_retry Lifecycle events (on_retry, on_error, before_llm, after_llm) fire on both sync and async LLM paths.

has_hook

Check if hooks exist for an event.

remove_hook

Remove a hook by ID.

Tools

Manage tool registration.

add_tool

Register a tool function.

has_tool

Check if a tool exists.

get_tool

Get a tool by name.

remove_tool

Remove a tool.

list_tools

List all registered tools.

Agent Profiles

Pre-configured agent personas.

add_profile

Register a custom profile.

get_profile

Get a profile by name.

has_profile

Check if profile exists.

remove_profile

Remove a profile.

list_profiles

List all profiles.
Built-in Profiles: general, coder, planner, reviewer, explorer, debugger

Display Callbacks

Hook into agent display output for custom UIs.

add_display_callback

Register a callback for display events.
Display Types: interaction, tool_call, error, instruction, self_reflection, generating

Agent Approval

Control tool approval directly on the agent:

Hook Return Values

Hooks can return simple values instead of HookResult:

Quick Import Examples


Hooks Guide

Complete hooks documentation

Tools Guide

Tool system documentation

Agent Profiles

Built-in agent profiles

Callbacks

Display callbacks guide