Skip to content

v0.2.4 - Hooks System

Choose a tag to compare

@slb350 slb350 released this 18 Oct 08:31
· 40 commits to main since this release

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 Client and standalone query() 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)

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