Hooks

Examples for pre-hooks, post-hooks, tool hooks, stream hooks, and agent context management.

ExampleDescription
Post Hook OutputExample demonstrating output validation using post-hooks with Agno Agent.
Pre Hook InputExample demonstrating how to use a pre_hook to perform comprehensive input validation for your Agno Agent.
Session State HooksExample demonstrating how to use a pre_hook to update the session_state.
Stream HookExample demonstrating sending a notification to the user after an agent generates a response.
Tool HooksUse tool_hooks to add middleware that wraps every tool call.
Few Shot LearningUse additional_input with an Agent.
Filter Tool Calls From HistoryDemonstrates max_tool_calls_from_history by showing that tool-call filtering only affects model input history while full run history remains in storage.
Instructions With StateExample demonstrating how to use a function as instructions for an agent.
InstructionsAdd the current date and time to the agent's context with add_datetime_to_context and a timezone.
Introduction MessageUse the introduction parameter to set an initial greeting message.
System MessageCustomize the agent's system message and role.
Custom Datetime FormatCustomize the datetime format injected into the agent's system context.
Message History HooksAccess the current run's message history inside tool pre/post hooks via run_context.messages.