memory.HooksManager runs pre/post scripts from .praisonai/hooks.json when you call .execute() — it does not fire automatically inside an Agent.
Two Hook Systems
PraisonAI has two hook systems with the same short name. Pick the right one.Quick Start
1
Create the manager
Use the correct import from
praisonaiagents.memory:2
Call .execute() yourself
Nothing calls this for you — invoke it from your own code:
How It Works
The “event” is triggered by whoever calls.execute() — not by the Agent lifecycle.
Hook Events
All ten events from theHookEvent type in praisonaiagents/memory/hooks.py:
HookResult
execute() returns a HookResult dataclass:
HookConfig
Each configured hook loads into aHookConfig:
Configuration File
Configure scripts in.praisonai/hooks.json:
create_config:
praisonai hooks list, praisonai hooks stats, and praisonai hooks init CLI commands read this same file — see CLI Hooks.
Common Patterns
Gate a write inside your own tool
The way to makeHooksManager “gate” an operation is to call .execute() inside your tool — the Agent framework will not do it for you.
Register a Python callable
Best Practices
Use the live hooks package for automatic gating
Use the live hooks package for automatic gating
If you want a hook to fire automatically before every tool call, use
praisonaiagents.hooks with Agent(hooks=registry). memory.HooksManager never runs on its own.Call .execute() at the exact point you want to gate
Call .execute() at the exact point you want to gate
Put the
.execute() call inside the tool or wrapper that performs the operation, so the hook runs at the right moment with the right context.Keep hook scripts fast
Keep hook scripts fast
Scripts run inline via
subprocess with a per-hook timeout (default 30s). Slow scripts delay your own code.Handle blocked results explicitly
Handle blocked results explicitly
Check
result.blocked and stop the operation yourself — nothing downstream enforces it.Related
Live Agent Hooks
Hooks that fire automatically around Agent tool and LLM calls.
Hooks CLI
List, inspect, and initialize
.praisonai/hooks.json.
