uv pip install agno openai
Set your OpenAI API key:
Agent, Team, or RunContext. Call the wrapped function with the arguments to continue the chain. Raise an exception or return another result to stop or replace the call.
Use a supported parameter name when defining a tool hook:
agent, team, run_context; name or function_name; function, func, or function_call; and args or arguments.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 you modify what happens before and after a tool is called. They are 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 an example that uses a pre_hook and post_hook along with agent dependencies.
pre_and_post_hooks.py