Agent SDK reference - Python changedagent-sdk/python
Nearest release: v2.1.319, published 3 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 6 Nov 2026 04:20 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 6 Nov 2026 04:37 UTC.
Upstream edited
Recorded here
Lines+1added
Lines−1removed
From line
2,513
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits70to this page, all time
The whole hunk
from line 2513, old and new numbered
/
from line 2513
25132513
25142514### Hook Usage Example
25152515
2516This example registers two hooks: one that blocks dangerous Bash commands like `rm -rf /`, and another that logs all tool usage for auditing. The security hook only runs on Bash commands (via the `matcher`), while the logging hook runs on all tools.
2516This example registers two hooks: one that blocks dangerous Bash commands like `rm -rf /`, and another that logs all tool usage for auditing. With its [`Bash` matcher](https://code.claude.com/docs/en/agent-sdk/hooks#matchers), the security hook runs on Bash tool calls. The logging hook has no matcher, so it runs on every tool call.
25172517
25182518```python theme={null}
25192519import asyncio
No line in this hunk matches that.