测试与安全

Hedera Hook Creation

hedera-dev/hedera-skills

This skill should be used when the user asks to "create a hedera hook", "write an agent kit hook", "extend AbstractHook", "add a tool lifecycle hook", "log tool executions", "audit trail hook", "track tool calls", or needs guidance on building observation/logging/metrics extensions for Hedera Agent Kit tools. Hooks are non-blocking — for blocking validation rules use the policy skill instead.

  • 0 次安装
  • 28 星标

安装命令

npx skills add https://github.com/hedera-dev/hedera-skills --skill 'Hedera Hook Creation'

SKILL.md

Creating Hedera Agent Kit Hooks

Hooks are non-blocking extensions that run around the BaseTool lifecycle. They observe and can enrich execution: log calls, write audit trails, track metrics, persist state on Context. They do not block tool execution — that's the job of policies (see agent-kit-policy skill).

Hooks fire only for tools that extend BaseTool. A tool that implements the Tool interface directly without extending BaseTool bypasses the hook system entirely.

When to write a hook vs. a policy

If you want to… Use
Log/audit/track tool calls Hook
Enrich Context (counters, session state) Hook
Stop a call from happening when a condition holds Policy (see agent-kit-policy)
Reject specific tool methods Policy

Built-in hooks include HcsAuditTrailHook and HolAuditTrailHook (HCS-backed audit trails) — both live in @hashgraph/hedera-agent-kit/hooks.

The 7-stage lifecycle