Every agent follows a lifecycle: receiving a message, thinking, executing actions, formulating a response. Until now, this cycle was fixed. With the hook system, you can inject your own logic at every step.

A hook is a function automatically triggered when a specific event occurs. Want to log every command executed? Hook on_tool_call. Want to check every response before sending? Hook pre_response.

The system supports 15+ events covering the agent's entire lifecycle. Hooks can be defined in JSON within the agent's configuration, without writing server code.

1

Declaration

You define your hooks in the agent's configuration: which event, which action, which conditions.

2

Event

When the event occurs in the agent's lifecycle, the hook is triggered.

3

Conditions

Optional filters limit execution (e.g., only for messages containing code).

4

Action

The hook executes its action: API call, context modification, skill trigger, notification.

5

Chaining

Multiple hooks can listen to the same event. They execute in the defined priority order.

Security audit

An on_tool_call hook records every system action in an audit log. Complete traceability without modifying the agent's code.

Context enrichment

An on_message_received hook queries an internal database and injects relevant information into context.

Notification

A post_response hook sends a Slack alert when the agent produces a response containing a warning or error.

featurePages.hooks.config
  • Available for all EasyClaw v2 agents
  • No hooks active by default (opt-in)
  • Complete documentation for each event available in the toolkit
Hook System -- EasyClaw v2