hook
A hook is a pre-set, automatic step that always runs at a specific point in an AI agent's workflow, regardless of what the agent is thinking.
In plain terms
A hook (literally: a hook) is a rule you "hang" on a specific point in the agent's operation. When the work reaches that point, the hook runs, for example before the agent deletes a file or after it finishes the task.
It is like the anti-theft gate at a store exit. Whether it sounds does not depend on the shopper's good intentions: anyone passing through is definitely checked. Similarly, a hook is not a request to the agent, but a checkpoint built into the system.
This differs from an instruction. If you ask an agent in text to 'always run the check,' it usually does so but may forget or misunderstand. A hook is not executed by the language model but by the framework running the agent, so it runs every time.
Typically used as a guardrail, quality check, logging and notification: to stop a prohibited action, apply automatic formatting, or signal when the agent has finished.
How it works
- The program running the agent signals events during work: the session started, the agent is about to use a tool, the tool finished, the agent completed the response.
- You act as the administrator: in a configuration file, you specify which command or small program corresponds to each event.
- When the event occurs, the framework runs the hook and passes the details to it, such as which file the agent wants to modify. It usually waits for the result before proceeding.
- The hook responds by either allowing the operation to proceed, blocking it, or sending a message back to the agent—for example, stating that the test failed and requires correction. Only actions that have not yet occurred can be blocked; a hook triggered after tool execution can only signal.
- The agent continues the work accordingly; the hook execution is usually logged, making it reviewable afterward.
An everyday example
At a company, a coding agent helps developers, and the team sets up a hook that checks before every command whether it would affect the live database. If so, the operation does not happen, and the agent receives a message that it cannot do this. Another hook gives an audio signal when the agent finishes, so you do not need to watch the screen.
Who is affected
A common misconception
Limits and risks
- The hook checks only what it was written for: a poorly formulated rule gives a false sense of security while the dangerous operation slips through another path.
- The hook can also fail: if the program breaks, runs too long, or is misconfigured, the check might be skipped, so it is worth testing from time to time whether it actually works.
- A hook is itself a program that typically runs on your machine with your permissions, so do not install a hook from an unknown source without inspection.
- Too many or slow hooks noticeably slow down the agent, while overly strict ones constantly halt the work.
- Hook settings vary by tool with no unified standard, so what you write for one agent may not work for another.
Similar, but not the same
- system prompt – The system prompt is a text instruction that the model interprets and may follow or miss. A hook, however, is a program step that the framework executes regardless of the model's decision.
- webhook – A webhook is an automatic notification between two internet services, while a hook is an intervention point within the agent's own workflow.
- guardrail – Guardrails represent the broader goal of constraining AI behavior, while a hook is one technical tool to achieve this.
Related concepts
AI-agent, agentkeret, automation, guardrail
pre-tool-call hook, post-tool-call hook, stop hook
tool calling, authorization management, human approval, system prompt, webhook
A brief history
A hook is an old programming technique: for decades, this term has referred to points where custom code can be inserted into a program's operation. Similar intervention points existed in earlier agent-building frameworks, but the concept became widely known in mid-2025 when Anthropic's coding agent, Claude Code, introduced configurable hooks. Since then, similar solutions have appeared in several other coding tools.
Where things stand
As of late 2026, the hook is a common element of coding agents, and development teams regularly use it to enforce and check rules. Outside the developer world it is still little known, and there is no unified standard.
Also known as
hook · hookok · hooks · agent hook · horog · hook · lifecycle hook · agent hook
Sources
This entry was machine-edited and has undergone machine expert review; the “In the news” section updates automatically from Agent Age stories.