---
title: "Hooks"
url: https://www.daytona.com/definitions/h/hooks
---

# Hooks

Hooks are commands that an agent harness runs automatically at set points, such as before or after a tool call, to check, block, or extend the agent's actions.

Hooks are scripts or commands that run when specific events happen in an agent harness. Common events are the start of a session, a prompt from the user, the moment before a tool runs, and the moment after it finishes. The harness passes details of the event to the hook, such as the tool name and its arguments. The hook can then act on them.

Hooks give users control that does not depend on the model following instructions. A hook before a tool call can block a dangerous command or require approval. A hook after a file edit can run a formatter or the tests. Hooks can also log actions, send notifications, or add context to the agent's next step.

Because hooks run code automatically, they need the same care as any automation. They work as guardrails, but only for the actions the harness sees. Running the agent in a sandbox adds a limit that holds even for actions a hook does not catch. Hooks and sandboxes are often used together: hooks for policy and convenience, the sandbox for isolation.

## Related terms

- [Agent harness](https://www.daytona.com/definitions/a/agent-harness.md)
- [Guardrails](https://www.daytona.com/definitions/g/guardrails.md)
- [Tool call](https://www.daytona.com/definitions/t/tool-call.md)
- [Policy](https://www.daytona.com/definitions/p/policy.md)
- [Coding agent](https://www.daytona.com/definitions/c/coding-agent.md)
- [Harness engineering](https://www.daytona.com/definitions/h/harness-engineering.md)
