Overview
The Hedera Agent Kit provides a flexible and powerful system for putting limits on tool usage and enforcing business logic, effectively enabling you to limit the functionality of AI agents through Hooks and Policies. These can be used to enforce security, compliance, and other business rules.Concepts
- Hooks: Extensions that observe and modify tool execution (logging, tracking, etc.). They are generally non-blocking.
- Policies: Specialized hooks that act as validation rules. They can block tool execution if certain conditions aren’t met.
Hooks and policies are available from v4 of the JavaScript SDK and from v3.4.0 of the Python SDK.Only tools extending
BaseTool (JavaScript) or ToolV2 (Python) support hooks and policies. All core tools provided with the kit support these features by default. While classic tool interfaces continue to be supported for backward compatibility, they do not gain hook or policy support until migrated to the new base classes.Migration Guides
Migration Guides
- JavaScript: Migrating Custom Tools to BaseTool
- Python: Python ToolV2 Migration Guide
Tool Lifecycle
Every tool in the kit follows a standardized 7-stage lifecycle. Hooks and policies can execute at 4 specific points during this lifecycle:1. Pre-Tool Execution
1. Pre-Tool Execution
Before anything happens, when raw parameters are passed.
2. Post-Parameter Normalization
2. Post-Parameter Normalization
After parameters are validated and cleaned.
3. Post-Core Action
3. Post-Core Action
After the main logic (e.g., transaction creation) executes, but before any secondary actions (like submission).
4. Post-Tool Execution
4. Post-Tool Execution
After everything completes, including transaction signing and submission.
Implementation Guides
Select your preferred SDK to see available hooks and policies, learn how to configure them, or see how to create your own:JavaScript SDK
Available Hooks & Policies, configuration, and developer templates for JS/TS.
Python SDK
Available Hooks & Policies, configuration, and developer templates for Python.