PreToolUse Hook
Agent SDKDefinition
An Agent SDK lifecycle hook that intercepts tool calls before execution. Can inspect, modify, or block the call. Used for access control, parameter sanitization, rate limiting, and audit logging. Runs synchronously before the tool executes.
Example Usage
Use PreToolUse to block any file write operations outside the designated working directory, regardless of what the agent requests.