Repository navigation
v0.2.4 - Hooks System
Added
- Hooks System - Pythonic lifecycle hooks for monitoring and controlling agent execution
- PreToolUse hook - Intercept tool execution before it happens (block dangerous operations, modify tool inputs)
- PostToolUse hook - Monitor tool results after execution (audit logging, error monitoring)
- UserPromptSubmit hook - Intercept user input before processing (input sanitization, content filtering)
- Pythonic design: Clean event dataclasses, simple return types
- No JSON envelopes or matcher DSL - handlers branch inside coroutines
- Works with both
Clientand standalonequery()function
- New example:
examples/hooks_example.py- 4 comprehensive patterns
Changed
Client.add_tool_result()is now async (breaking change for PostToolUse hook support)- Old:
client.add_tool_result(tool_id, result) - New:
await client.add_tool_result(tool_id, result)
- Old:
Technical
- All 118 tests passing (14 new hook tests)
Install: pip install open-agent-sdk==0.2.4
Full Changelog: https://github.com/slb350/open-agent-sdk/blob/main/CHANGELOG.md