Tools
Pre and post hooks
Pre and post hooks are a powerful feature that let’s us modify what happens before and after a tool is called.
Set the pre_hook
in the @tool
decorator to run a function before the tool call.
Set the post_hook
in the @tool
decorator to run a function after the tool call.
Example: Pre/Post Hooks + Agent Context
Here’s a demo example of using a pre_hook
, post_hook
along with Agent Context.
pre_and_post_hooks.py