Skip to content
0%
0% of stage
Concept 2 min

Hooks

Automate governance without relying on the model to remember.

In one sentence

Interception points in the agent cycle where custom code runs automatically: before a tool, after an edit, at the end of the turn. They are used for validation, formatting, and blocking prohibited actions, and they automate governance without relying on the model to remember.

Before

Agent is about to execute an action

What it does

Code intercepts and validates

After

Proceeds, is corrected, or is blocked

Example

A hook runs before any sending tool: it scans the text for CPF, address, and school name. If it finds them, it blocks the action and returns the reason. The LGPD rule is enforced by code on every execution, whether or not the model remembers it.

In practice

  • Use it for anything that cannot depend on the model remembering: LGPD, limits, format.
  • A hook that blocks needs to return the reason; otherwise, the agent will try again the same way.
  • Keep the hook fast, because it runs on every execution and, if slow, becomes a bottleneck.

How to make it tangible

Code that runs before or after a tool, validating or blocking the action.

Translated from Portuguese with AI assistance.

To discuss

Is this already in place in your company? Compare with the criterion:

Done when: When the critical rule is followed even if the prompt is forgotten or ignored.