Agent or Team object as well. Inside the tool hook, you have to call the function call and return the result.
It is important to use exact parameter names when defining a tool hook.
agent, team, run_context, function_name, function_call, and arguments are available parameters.RunContext object in the tool hook. Inside the run context, you will find the session state, dependencies, and metadata.
Multiple Tool Hooks
You can also assign multiple tool hooks at once. They will be applied in the order they are assigned.Pre and Post Hooks
Pre and post hooks let’s you modify what happens before and after a tool is called. It is an alternative to tool hooks. Set thepre_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.
Here’s a demo example of using a pre_hook, post_hook along with Agent Context.
pre_and_post_hooks.py