How do the top AI agent harnesses handle hooks?

Six of the seven harnesses document a way to run your own code before a tool call and block it; Antigravity documents lifecycle hooks in its SDK. Where they differ is failure: in Claude Code, Codex and Cursor a hook that errors lets the action proceed unless it is set to fail closed. Read 2026-11-06.

By Mackenzie Bowes · mackenzie@mackenziebowes.com · @_mackenziebowes on X

Contents

Short answer, from the docs read: a hook is the same idea everywhere, your code running at a fixed point in the agent loop, and six of the seven document a point before a tool call; Antigravity's documented hooks run around a turn and on tool errors. Claude Code, Codex and Cursor take a command that reads JSON on stdin and signals a block with an exit code or a JSON decision.[1][2][3] OpenCode and pi take code in a plugin or extension file.[4][5] Hermes Agent has four separate hook systems.[6] Antigravity documents lifecycle hooks in its SDK as Python decorators.[7] The sharpest difference is what a failing hook does: Claude Code, Codex and Cursor let the action go ahead when a hook crashes or times out, unless the hook is set to fail closed.[1][2][3] This is the fourth page in a series that began with a survey of the harnesses, then memory and tool calls.

Where a hook attaches

Which hooks can block

What happens when a hook fails

Who can add a hook and who has to approve it

What the comparison rules out

These are consequences of the docs read, not findings from a test.

Terms

Not yet proven

If you rely on a hook to stop an action and it failed open on you, I would like to hear it: mackenzie@mackenziebowes.com.

Sources

  1. Claude Code Docs, Hooks reference. Read in Rotunda 2026-11-06. code.claude.com/docs/en/hooks
  2. OpenAI, Codex docs, Hooks. Read in Rotunda 2026-11-06. learn.chatgpt.com/docs/hooks
  3. Cursor Docs, Hooks. Read in Rotunda 2026-11-06. cursor.com/docs/hooks
  4. OpenCode docs, Plugins. Read in Rotunda 2026-11-06. opencode.ai/docs/plugins/
  5. Pi docs, Extensions. Read in Rotunda 2026-11-06. pi.dev/docs/latest/extensions
  6. Hermes Agent docs, Event Hooks. Read in Rotunda 2026-11-06. hermes-agent.nousresearch.com/docs/user-guide/features/hooks
  7. Google Antigravity Docs, Lifecycle hooks, triggers and session persistence. Read in Rotunda 2026-11-06. antigravity.google/docs/sdk/lifecycle/
  8. Google Antigravity Docs, overview. Read in Rotunda 2026-11-06. antigravity.google/docs/overview/

Terms on this page

  • Hook: A command that an AI coding agent runs automatically at a set point in its work.
  • Model Context Protocol: An open standard for connecting AI applications to outside tools and data.
  • Tool call: A request from an AI model to run one action, such as a search or a file write, which the surrounding program carries out.